diff options
author | Tomas Vondra <tomas.vondra@postgresql.org> | 2023-07-02 10:18:56 +0200 |
---|---|---|
committer | Tomas Vondra <tomas.vondra@postgresql.org> | 2023-07-02 10:21:17 +0200 |
commit | 28d03feac386c2c68ffaa47f30e6578591ef5c1b (patch) | |
tree | d7b369d344865cd2085b00e4b3d1db3a51ba6a4a /src/backend/access/brin/brin_bloom.c | |
parent | 4f49b3f8497d5c8c3cc06eb32942c13b8ee7209e (diff) |
Minor cleanups in the BRIN code
BRIN bloom and minmax-multi opclasses were somewhat inconsistent when
dealing with bool variables, assigning to them Datum values etc. While
not a bug, it makes the code harder to understand, so fix that.
While at it, update an incorrect comment copied to bloom opclass from
minmax, talking about strategies not supported by bloom.
Reviewed-by: Heikki Linnakangas
Discussion: https://postgr.es/m/0e1f3350-c9cf-ab62-43a5-5dae314de89c%40enterprisedb.com
Diffstat (limited to 'src/backend/access/brin/brin_bloom.c')
-rw-r--r-- | src/backend/access/brin/brin_bloom.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c index e4953a9d37b..568faf1cd58 100644 --- a/src/backend/access/brin/brin_bloom.c +++ b/src/backend/access/brin/brin_bloom.c @@ -574,7 +574,7 @@ brin_bloom_consistent(PG_FUNCTION_ARGS) Oid colloid = PG_GET_COLLATION(); AttrNumber attno; Datum value; - Datum matches; + bool matches; FmgrInfo *finfo; uint32 hashValue; BloomFilter *filter; @@ -584,6 +584,10 @@ brin_bloom_consistent(PG_FUNCTION_ARGS) Assert(filter); + /* + * Assume all scan keys match. We'll be searching for a scan key eliminating + * the page range (we can stop on the first such key). + */ matches = true; for (keyno = 0; keyno < nkeys; keyno++) @@ -601,9 +605,8 @@ brin_bloom_consistent(PG_FUNCTION_ARGS) case BloomEqualStrategyNumber: /* - * In the equality case (WHERE col = someval), we want to - * return the current page range if the minimum value in the - * range <= scan key, and the maximum value >= scan key. + * We want to return the current page range if the bloom filter + * seems to contain the value. */ finfo = bloom_get_procinfo(bdesc, attno, PROCNUM_HASH); @@ -614,7 +617,7 @@ brin_bloom_consistent(PG_FUNCTION_ARGS) default: /* shouldn't happen */ elog(ERROR, "invalid strategy number %d", key->sk_strategy); - matches = 0; + matches = false; break; } @@ -622,7 +625,7 @@ brin_bloom_consistent(PG_FUNCTION_ARGS) break; } - PG_RETURN_DATUM(matches); + PG_RETURN_BOOL(matches); } /* |