Skip to content

Commit

Permalink
allow fractional percentage values
Browse files Browse the repository at this point in the history
  • Loading branch information
michaele-blend committed Oct 2, 2022
1 parent c9665a9 commit 8017700
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pg_sample
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ while (my $row = lower_keys($sth->fetchrow_hashref)) {
my $percent = 100 * $_->[1] / $table_num_rows;
$tablesample = "TABLESAMPLE BERNOULLI ($percent)";
}
} elsif ($_->[1] =~ /^\d+%$/) { # percent value turned into LIMIT
} elsif ($_->[1] =~ /^\d+(\.\d+)?%$/) { # percent value turned into LIMIT
if (not $opt{random} or $pg_version < version->declare('9.5')) {
my ($table_num_rows) = $dbh->selectrow_array(qq{ SELECT count(*) FROM $table });
my $percent = (substr $_->[1], 0, (length $_->[1]) - 1) / 100;
Expand Down

0 comments on commit 8017700

Please sign in to comment.