Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd5b132b

Browse files
committed
Dodge portability issue (apparent compiler bug) in new tablesample code.
Some of the older OS X critters in the buildfarm are failing regression,with symptoms showing that a request for 100% sampling in BERNOULLI orSYSTEM methods actually gets only around 50% of the table. gdb revealedthat the computation of the "cutoff" number was producing 0x7FFFFFFFrather than the expected 0x100000000. Inspecting the assembly code,it looks like gcc is trying to use lrint() instead of rint() and thenfumbling the conversion from long double to uint64. This seems like aclear compiler bug, but assigning the intermediate result into a plaindouble variable works around it, so let's just do that. (Another ideawould be to give up one bit of hash width so that we don't need to usea uint64 cutoff, but let's see if this is enough.)
1 parent0801245 commitd5b132b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

‎src/backend/access/tablesample/bernoulli.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ bernoulli_beginsamplescan(SampleScanState *node,
144144
{
145145
BernoulliSamplerData*sampler= (BernoulliSamplerData*)node->tsm_state;
146146
doublepercent=DatumGetFloat4(params[0]);
147+
doubledcutoff;
147148

148149
if (percent<0||percent>100||isnan(percent))
149150
ereport(ERROR,
@@ -155,7 +156,8 @@ bernoulli_beginsamplescan(SampleScanState *node,
155156
* store that as a uint64, of course. Note that this gives strictly
156157
* correct behavior at the limits of zero or one probability.
157158
*/
158-
sampler->cutoff=rint(((double)PG_UINT32_MAX+1)*percent /100);
159+
dcutoff=rint(((double)PG_UINT32_MAX+1)*percent /100);
160+
sampler->cutoff= (uint64)dcutoff;
159161
sampler->seed=seed;
160162
sampler->lt=InvalidOffsetNumber;
161163

‎src/backend/access/tablesample/system.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ system_beginsamplescan(SampleScanState *node,
148148
{
149149
SystemSamplerData*sampler= (SystemSamplerData*)node->tsm_state;
150150
doublepercent=DatumGetFloat4(params[0]);
151+
doubledcutoff;
151152

152153
if (percent<0||percent>100||isnan(percent))
153154
ereport(ERROR,
@@ -159,7 +160,8 @@ system_beginsamplescan(SampleScanState *node,
159160
* store that as a uint64, of course. Note that this gives strictly
160161
* correct behavior at the limits of zero or one probability.
161162
*/
162-
sampler->cutoff=rint(((double)PG_UINT32_MAX+1)*percent /100);
163+
dcutoff=rint(((double)PG_UINT32_MAX+1)*percent /100);
164+
sampler->cutoff= (uint64)dcutoff;
163165
sampler->seed=seed;
164166
sampler->nextblock=0;
165167
sampler->lt=InvalidOffsetNumber;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp