diff options
author | Tom Lane | 2016-04-03 19:16:07 +0000 |
---|---|---|
committer | Tom Lane | 2016-04-03 19:16:07 +0000 |
commit | 8f75fd1f402acbc30bc15dbf51eb6dec1bbec600 (patch) | |
tree | d7c56b357ba1a302fdf86321491db4685a154945 /contrib/bloom/blutils.c | |
parent | a9284849b48b04fa2836aaf704659974c13e610d (diff) |
Fix contrib/bloom to not fail under CLOBBER_CACHE_ALWAYS.
The code was supposing that rd_amcache wouldn't disappear from under it
during a scan; which is wrong. Copy the data out of the relcache rather
than trying to reference it there.
Diffstat (limited to 'contrib/bloom/blutils.c')
-rw-r--r-- | contrib/bloom/blutils.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/contrib/bloom/blutils.c b/contrib/bloom/blutils.c index 92ab85811b8..be056c33ba0 100644 --- a/contrib/bloom/blutils.c +++ b/contrib/bloom/blutils.c @@ -155,9 +155,9 @@ initBloomState(BloomState *state, Relation index) index->rd_amcache = (void *) opts; } - state->opts = (BloomOptions *) index->rd_amcache; + memcpy(&state->opts, index->rd_amcache, sizeof(state->opts)); state->sizeOfBloomTuple = BLOOMTUPLEHDRSZ + - sizeof(SignType) * state->opts->bloomLength; + sizeof(SignType) * state->opts.bloomLength; } /* @@ -228,10 +228,10 @@ signValue(BloomState *state, SignType *sign, Datum value, int attno) hashVal = DatumGetInt32(FunctionCall1(&state->hashFn[attno], value)); mySrand(hashVal ^ myRand()); - for (j = 0; j < state->opts->bitSize[attno]; j++) + for (j = 0; j < state->opts.bitSize[attno]; j++) { /* prevent mutiple evaluation */ - nBit = myRand() % (state->opts->bloomLength * BITSIGNTYPE); + nBit = myRand() % (state->opts.bloomLength * BITSIGNTYPE); SETBIT(sign, nBit); } } |