pgsql: Introduce bms_offset_members() function

From: David Rowley <drowley(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Introduce bms_offset_members() function
Date: 2026-07-08 13:12:57
Message-ID: E1whS5A-0009LU-2Y@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Introduce bms_offset_members() function

Effectively, a function to bitshift members by the specified number of
bits. We have various fragments of code doing this manually with a
bms_next_member() -> bms_add_member() loop. We can do this more
efficiently in terms of CPU and memory allocation by making a new
Bitmapset and bitshifting in the words of the old set to populate it.

Author: David Rowley <dgrowleyml(at)gmail(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Greg Burd <greg(at)burd(dot)me>
Discussion: https://postgr.es/m/CAApHDvq=eEdw2Qp+aSzSOtTSe+h0fnVQ55CcTNqBkLDYiRZmxw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/bb7ded1eebed708865d9bb0a3513c7ed3afe7065

Modified Files
--------------
src/backend/nodes/bitmapset.c | 135 +++++++++++++++++++++
src/backend/optimizer/plan/setrefs.c | 10 +-
src/backend/optimizer/prep/prepjointree.c | 30 ++---
src/backend/rewrite/rewriteManip.c | 25 +---
src/backend/statistics/extended_stats.c | 12 +-
src/include/nodes/bitmapset.h | 1 +
.../test_bitmapset/expected/test_bitmapset.out | 81 +++++++++++++
.../modules/test_bitmapset/sql/test_bitmapset.sql | 23 ++++
.../modules/test_bitmapset/test_bitmapset--1.0.sql | 8 ++
src/test/modules/test_bitmapset/test_bitmapset.c | 101 ++++++++++++++-
10 files changed, 374 insertions(+), 52 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-07-08 15:45:28 pgsql: Remove sketchy TerminateThread() call on Ctrl-C on Windows
Previous Message Fujii Masao 2026-07-08 09:17:39 pgsql: doc: Clarify pg_get_sequence_data() NULL-return cases