pgsql: Switch Get[Local]BufferDescriptor() to use a signed value in inp

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Switch Get[Local]BufferDescriptor() to use a signed value in inp
Date: 2026-07-03 03:07:53
Message-ID: E1wfUFt-0018Be-21@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Switch Get[Local]BufferDescriptor() to use a signed value in input

GetBufferDescriptor() and GetLocalBufferDescriptor() took a uint32
buffer index, but every real caller derives the index from a Buffer:
- Unsigned value for shared buffers.
- Signed value for local buffers.

Both routines now take in input a signed number, GetBufferDescriptor()
gaining an assertion checking that the input value is in the range
allowed by the GUC shared_buffers. This work is a follow-up of
e18b0cb7344c, where we found that passing down a value for a local
buffer was undetected and finished outside the range of NBuffers.

While monitoring all the existing callers of *BufferDescriptor(), the
only consumer that passes does an unsigned value is ClockSweepTick(),
whose result is always a module of NBuffers.

Suggested-by: Andres Freund <andres(at)anarazel(dot)de>
Author: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Reviewed-by: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Reviewed-by: Michael Paquier <michael(at)paquier(dot)xyz>
Discussion: https://postgr.es/m/CAExHW5uzRMYVZsXXS3HXXT0fG_sNrpUhUqwP4NorhaCqH9JDhA@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
src/include/storage/buf_internals.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2026-07-03 03:29:45 pgsql: Fix typo in pg_stat_us_to_ms()
Previous Message Fujii Masao 2026-07-03 02:25:06 pgsql: Remove replication slot advice from MultiXact wraparound hints