pgsql: pg_buffercache: restore rowtype verification in pg_buffercache_p

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: pg_buffercache: restore rowtype verification in pg_buffercache_p
Date: 2026-06-10 03:33:35
Message-ID: E1wX9h9-001oq7-13@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

pg_buffercache: restore rowtype verification in pg_buffercache_pages()

Commit 257c8231bf9 changed pg_buffercache_pages() to materialize its output
directly into a tuplestore. As a result, the function ended up trusting
a caller-supplied RECORD descriptors. That could lead to crashes
if the supplied row definition did not match the actual returned values,
for example by passing bool Datums to tuplestore_putvalues() with
an incompatible descriptor.

Fix this by constructing the correct tuple descriptor for
pg_buffercache_pages() and assigning it to
rsinfo->setDesc after InitMaterializedSRF(). This restores the executor's
tupledesc_match() verification, so incompatible caller-supplied
row definitions are rejected with an error, as before commit 257c8231bf9.

Bug: #19508
Reported-by: Nikita Kalinin <n(dot)kalinin(at)postgrespro(dot)ru>
Author: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Reviewed-by: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Reviewed-by: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
Discussion: https://postgr.es/m/19508-e5f188183279219b@postgresql.org

Branch
------
master

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

Modified Files
--------------
contrib/pg_buffercache/expected/pg_buffercache.out | 8 ++++
contrib/pg_buffercache/pg_buffercache_pages.c | 51 ++++++++++++++++++++++
contrib/pg_buffercache/sql/pg_buffercache.sql | 6 +++
3 files changed, 65 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2026-06-10 04:53:39 pgsql: Fix MarkBufferDirtyHint() to not call GetBufferDescriptor() for
Previous Message Michael Paquier 2026-06-10 01:56:39 pgsql: psql: Add some missing schema qualifications in describe.c