Re: TupleDescAttr bounds checks

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-03-20T16:22:25Z
Lists: pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> Scrutiny of a recent test_plan_advice failure in the buildfarm
> revealed a bug that had nothing to do with test_plan_advice or
> pg_plan_advice; rather, it was a bug introduced by the virtual
> generated columns feature, and specifically of that feature indexing
> off of the beginning of a TupleDesc when whole-row attributes are
> present. The first patch attached to this email fixes this issue, and
> should be committed and back-patched to v18. I plan to do that soon
> unless there are objections.

I had just come to the same conclusion about why grison is failing.
+1 to all three of these patches.  (I did not look to see if 0002
fixes every case that the Assert could trigger on, but as long as
you're only putting it in HEAD I'm not too concerned that we might
have missed some.)

			regards, tom lane



Commits

  1. Avoid unsafe access to negative index in a TupleDesc.

  2. Disallow system columns in COPY FROM WHERE conditions.

  3. Add a test for creating an index on a whole-row expression.

  4. Bounds-check access to TupleDescAttr with an Assert.

  5. Prevent spurious "indexes on virtual generated columns are not supported".