summaryrefslogtreecommitdiff
path: root/contrib/bloom/blinsert.c
diff options
context:
space:
mode:
authorTom Lane2016-04-03 18:17:20 +0000
committerTom Lane2016-04-03 18:17:23 +0000
commita9284849b48b04fa2836aaf704659974c13e610d (patch)
tree8e3f1667e6b73a8fe636ed74ae847c23565216b7 /contrib/bloom/blinsert.c
parent3e4b7d87988f0835f137f15f5c1a40598dd21f3d (diff)
Clean up some stuff in new contrib/bloom module.
Coverity complained about implicit sign-extension in the BloomPageGetFreeSpace macro, probably because sizeOfBloomTuple isn't wide enough for size calculations. No overflow is really possible as long as maxoff and sizeOfBloomTuple are small enough to represent a realistic situation, but it seems like a good idea to declare sizeOfBloomTuple as Size not int32. Add missing check on BloomPageAddItem() result, again from Coverity. Avoid core dump due to not allocating so->sign array when scan->numberOfKeys is zero. Also thanks to Coverity. Use FLEXIBLE_ARRAY_MEMBER rather than declaring an array as size 1 when it isn't necessarily. Very minor beautification of related code. Unfortunately, none of the Coverity-detected mistakes look like they could account for the remaining buildfarm unhappiness with this module. It's barely possible that the FLEXIBLE_ARRAY_MEMBER mistake does account for that, if it's enabling bogus compiler optimizations; but I'm not terribly optimistic. We probably still have bugs to find here.
Diffstat (limited to 'contrib/bloom/blinsert.c')
-rw-r--r--contrib/bloom/blinsert.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/contrib/bloom/blinsert.c b/contrib/bloom/blinsert.c
index 9e6678087ca..6eecb12187d 100644
--- a/contrib/bloom/blinsert.c
+++ b/contrib/bloom/blinsert.c
@@ -96,10 +96,10 @@ bloomBuildCallback(Relation index, HeapTuple htup, Datum *values,
initCachedPage(buildstate);
- if (BloomPageAddItem(&buildstate->blstate, buildstate->data, itup) == false)
+ if (!BloomPageAddItem(&buildstate->blstate, buildstate->data, itup))
{
/* We shouldn't be here since we're inserting to the empty page */
- elog(ERROR, "can not add new tuple");
+ elog(ERROR, "could not add new bloom tuple to empty page");
}
}
@@ -298,7 +298,12 @@ blinsert(Relation index, Datum *values, bool *isnull,
metaData = BloomPageGetMeta(metaPage);
page = GenericXLogRegister(state, buffer, true);
BloomInitPage(page, 0);
- BloomPageAddItem(&blstate, page, itup);
+
+ if (!BloomPageAddItem(&blstate, page, itup))
+ {
+ /* We shouldn't be here since we're inserting to the empty page */
+ elog(ERROR, "could not add new bloom tuple to empty page");
+ }
metaData->nStart = 0;
metaData->nEnd = 1;