mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
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.
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user