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 <[email protected]>
Author: Fujii Masao <[email protected]>
Reviewed-by: Ayush Tiwari <[email protected]>
Reviewed-by: Ashutosh Sharma <[email protected]>
Discussion: https://postgr.es/m/[email protected]

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(+)

Reply via email to