aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Vondra <tomas.vondra@postgresql.org>2024-04-14 17:58:59 +0200
committerTomas Vondra <tomas.vondra@postgresql.org>2024-04-14 18:17:09 +0200
commitccd8f0fa1e541e6b59ac2727509cafa6367e5886 (patch)
tree42ec58d442fccc87967b7939eff26c3188be9c0e
parent4e62ba21a921b77df2da4bf1f4c1545da5da44e7 (diff)
downloadpostgresql-ccd8f0fa1e541e6b59ac2727509cafa6367e5886.tar.gz
postgresql-ccd8f0fa1e541e6b59ac2727509cafa6367e5886.zip
Update nbits_set in brin_bloom_union
Properly update the number of bits set in the bitmap after merging the filters in brin_bloom_union. This is mostly harmless, as the counter is used only in the output function, which means pageinspect may show incorrect information about the BRIN summary. The counter does not affect correctness. Discovered while adding a regression test comparing indexes built with and without parallelism. The parallel index builds exercise the union procedure when merging results from workers, which is otherwise very hard to do in a test. Which is why this went unnoticed until now. Backpatch through 14, where the BRIN bloom opclasses were introduced. Backpatch-through: 14 Discussion: https://postgr.es/m/1df00a66-db5a-4e66-809a-99b386a06d86%40enterprisedb.com
-rw-r--r--src/backend/access/brin/brin_bloom.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index 1ed0d8a3b80..80ce0becdd6 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -660,6 +660,9 @@ brin_bloom_union(PG_FUNCTION_ARGS)
for (i = 0; i < nbytes; i++)
filter_a->data[i] |= filter_b->data[i];
+ /* update the number of bits set in the filter */
+ filter_a->nbits_set = pg_popcount((const char *) filter_a->data, nbytes);
+
PG_RETURN_VOID();
}