Fix for pageinspect bug in PG 17

From: Tomas Vondra <tomas(at)vondra(dot)me>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Fix for pageinspect bug in PG 17
Date: 2024-11-11 18:32:10
Message-ID: 3385a58f-5484-49d0-b790-9a198a0bf236@vondra.me
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Here's a fix for pageinspect bug in PG17, reported in [1]. The bug turns
out to be introduced by my commit

commit dae761a87edae444d11a411f711f1d679bed5941
Author: Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>
Date: Fri Dec 8 17:07:30 2023 +0100

Add empty BRIN ranges during CREATE INDEX

...

This adds an out argument to brin_page_items, but I failed to consider
the user may still run with an older version of the extension - either
after pg_upgrade (as in the report), or when the CREATE EXTENSION
command specifies VERSION.

The new "empty" field is added in the middle of the output tuple, which
shifts the values, causing segfault when accessing a text field at the
end of the array.

Of course, we add arguments to existing functions pretty often, and we
know how to do that in backwards-compatible way - pg_stat_statements is
a good example of how to do that nicely. Unfortunately, it's too late to
do that for brin_page_items :-( There may already be upgraded systems or
with installed pageinspect, etc.

The only fix I can think of is explicitly looking at TupleDesc->natts,
as in the attached fix.

regards

--
Tomas Vondra

Attachment Content-Type Size
pageinspect-fix.patch text/x-patch 1.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2024-11-11 18:33:37 Re: index prefetching
Previous Message David E. Wheeler 2024-11-11 18:15:53 Re: RFC: Additional Directory for Extensions