diff options
Diffstat (limited to 'src/backend/access/tablesample/system.c')
-rw-r--r-- | src/backend/access/tablesample/system.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/backend/access/tablesample/system.c b/src/backend/access/tablesample/system.c index 43c5dab7161..080a3121141 100644 --- a/src/backend/access/tablesample/system.c +++ b/src/backend/access/tablesample/system.c @@ -148,6 +148,7 @@ system_beginsamplescan(SampleScanState *node, { SystemSamplerData *sampler = (SystemSamplerData *) node->tsm_state; double percent = DatumGetFloat4(params[0]); + double dcutoff; if (percent < 0 || percent > 100 || isnan(percent)) ereport(ERROR, @@ -159,7 +160,8 @@ system_beginsamplescan(SampleScanState *node, * store that as a uint64, of course. Note that this gives strictly * correct behavior at the limits of zero or one probability. */ - sampler->cutoff = rint(((double) PG_UINT32_MAX + 1) * percent / 100); + dcutoff = rint(((double) PG_UINT32_MAX + 1) * percent / 100); + sampler->cutoff = (uint64) dcutoff; sampler->seed = seed; sampler->nextblock = 0; sampler->lt = InvalidOffsetNumber; |