Re: Bug: GiST index-only scans can use tuple descriptor with incorrect alignment when deforming

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Bug: GiST index-only scans can use tuple descriptor with incorrect alignment when deforming
Date: 2026-07-14 22:39:48
Message-ID: CAH2-Wzk2qxm8cQtmhwXdCLMpGFJBqbiqbzFT7MweOT3-UYurKA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 13, 2026 at 6:20 PM Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
> Attached bugfix teaches nodeIndexonlyscan.c to deform using the
> authoritative xs_hitupdesc descriptor used by the index AM, rather
> than assuming that the descriptor used by the scan's virtual slot is
> 100% compatible with xs_hitupdesc.

Attached V2 polishes the test case, and improves the comments and
commit message (no substantive change).

The conditions under which this bug could lead to wrong answers were
fairly subtle, so it's worth clarifying those aspects in the committed
test case.

> The patch includes a test case demonstrating a query where this leads
> to incorrect behavior when scanning a multicolumn GiST index. Without
> the fix the executor gets confused about where the second index column
> begins, leading to a spurious error (e.g., "ERROR: type with OID nnnnn
> does not exist"). I haven't investigated whether the consequences
> could be worse than just an error.

I can now confirm that this bug might cause a SIGSEGV.

--
Peter Geoghegan

Attachment Content-Type Size
v2-0001-Fix-index-only-scan-misreading-GiST-fetch-tuples.patch application/octet-stream 12.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2026-07-14 22:47:30 Hash index AM fake LSN oversight
Previous Message Alexander Korotkov 2026-07-14 22:31:46 Re: SQL/JSON json_table plan clause