agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pg_buffercache: restore rowtype verification in pg_buffercache_p
Date: Wed, 10 Jun 2026 03:33:35 +0000
Message-ID: <E1wX9h9-001oq7-13@gemulon.postgresql.org> (raw)

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.kalinin@postgrespro.ru>
Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Ashutosh Sharma <ashu.coek88@gmail.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(+)



Message-ID: <E1wX9h9-001oq7-13@gemulon.postgresql.org>
Permalink:  ../E1wX9h9-001oq7-13@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wX9h9-001oq7-13@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: fujii@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: pg_buffercache: restore rowtype verification in pg_buffercache_p
  In-Reply-To: <E1wX9h9-001oq7-13@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox