diff --git a/contrib/bloom/blscan.c b/contrib/bloom/blscan.c index fc82f54373..aebf32a8d2 100644 --- a/contrib/bloom/blscan.c +++ b/contrib/bloom/blscan.c @@ -29,9 +29,16 @@ IndexScanDesc blbeginscan(Relation r, int nkeys, int norderbys) { IndexScanDesc scan; + BloomScanOpaque so; scan = RelationGetIndexScan(r, nkeys, norderbys); + so = (BloomScanOpaque) palloc(sizeof(BloomScanOpaqueData)); + initBloomState(&so->state, scan->indexRelation); + so->sign = NULL; + + scan->opaque = so; + return scan; } @@ -42,23 +49,10 @@ void blrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys) { - BloomScanOpaque so; + BloomScanOpaque so = (BloomScanOpaque) scan->opaque; - so = (BloomScanOpaque) scan->opaque; - - if (so == NULL) - { - /* if called from blbeginscan */ - so = (BloomScanOpaque) palloc(sizeof(BloomScanOpaqueData)); - initBloomState(&so->state, scan->indexRelation); - scan->opaque = so; - - } - else - { - if (so->sign) - pfree(so->sign); - } + if (so->sign) + pfree(so->sign); so->sign = NULL; if (scankey && scan->numberOfKeys > 0)