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

Commita928484

Browse files
committed
Clean up some stuff in new contrib/bloom module.
Coverity complained about implicit sign-extension in theBloomPageGetFreeSpace macro, probably because sizeOfBloomTuple isn't wideenough for size calculations. No overflow is really possible as long asmaxoff and sizeOfBloomTuple are small enough to represent a realisticsituation, but it seems like a good idea to declare sizeOfBloomTuple asSize not int32.Add missing check on BloomPageAddItem() result, again from Coverity.Avoid core dump due to not allocating so->sign array whenscan->numberOfKeys is zero. Also thanks to Coverity.Use FLEXIBLE_ARRAY_MEMBER rather than declaring an array as size 1when it isn't necessarily.Very minor beautification of related code.Unfortunately, none of the Coverity-detected mistakes look like theycould account for the remaining buildfarm unhappiness with thismodule. It's barely possible that the FLEXIBLE_ARRAY_MEMBER mistakedoes account for that, if it's enabling bogus compiler optimizations;but I'm not terribly optimistic. We probably still have bugs tofind here.
1 parent3e4b7d8 commita928484

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

‎contrib/bloom/blinsert.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ bloomBuildCallback(Relation index, HeapTuple htup, Datum *values,
9696

9797
initCachedPage(buildstate);
9898

99-
if (BloomPageAddItem(&buildstate->blstate,buildstate->data,itup)== false)
99+
if (!BloomPageAddItem(&buildstate->blstate,buildstate->data,itup))
100100
{
101101
/* We shouldn't be here since we're inserting to the empty page */
102-
elog(ERROR,"can not add new tuple");
102+
elog(ERROR,"could not add newbloomtuple to empty page");
103103
}
104104
}
105105

@@ -298,7 +298,12 @@ blinsert(Relation index, Datum *values, bool *isnull,
298298
metaData=BloomPageGetMeta(metaPage);
299299
page=GenericXLogRegister(state,buffer, true);
300300
BloomInitPage(page,0);
301-
BloomPageAddItem(&blstate,page,itup);
301+
302+
if (!BloomPageAddItem(&blstate,page,itup))
303+
{
304+
/* We shouldn't be here since we're inserting to the empty page */
305+
elog(ERROR,"could not add new bloom tuple to empty page");
306+
}
302307

303308
metaData->nStart=0;
304309
metaData->nEnd=1;

‎contrib/bloom/bloom.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ typedef struct BloomState
118118
* sizeOfBloomTuple is index's specific, and it depends on reloptions, so
119119
* precompute it
120120
*/
121-
int32sizeOfBloomTuple;
121+
SizesizeOfBloomTuple;
122122
}BloomState;
123123

124124
#defineBloomPageGetFreeSpace(state,page) \
@@ -134,7 +134,7 @@ typedef uint16 SignType;
134134
typedefstructBloomTuple
135135
{
136136
ItemPointerDataheapPtr;
137-
SignTypesign[1];
137+
SignTypesign[FLEXIBLE_ARRAY_MEMBER];
138138
}BloomTuple;
139139

140140
#defineBLOOMTUPLEHDRSZ offsetof(BloomTuple, sign)

‎contrib/bloom/blscan.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ blgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
9494
BufferAccessStrategybas;
9595
BloomScanOpaqueso= (BloomScanOpaque)scan->opaque;
9696

97-
if (so->sign==NULL&&scan->numberOfKeys>0)
97+
if (so->sign==NULL)
9898
{
9999
/* New search: have to calculate search signature */
100100
ScanKeyskey=scan->keyData;
@@ -151,10 +151,13 @@ blgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
151151
boolres= true;
152152

153153
/* Check index signature with scan signature */
154-
for (i=0;res&&i<so->state.opts->bloomLength;i++)
154+
for (i=0;i<so->state.opts->bloomLength;i++)
155155
{
156156
if ((itup->sign[i]&so->sign[i])!=so->sign[i])
157+
{
157158
res= false;
159+
break;
160+
}
158161
}
159162

160163
/* Add matching tuples to bitmap */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp