Re: TupleDescAttr bounds checks

Robert Haas <robertmhaas@gmail.com>

From: Robert Haas <robertmhaas@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-03-20T17:02:35Z
Lists: pgsql-hackers
On Fri, Mar 20, 2026 at 12:46 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> I did see that, but it read to me that you were just guessing at that
> time.  This morning I put Asserts into indexcmds.c that verified that
> it was trying to access the tupledesc for attno zero, and that proves
> there is a bug there.  It also seems like a plausible explanation for
> why only one machine has exhibited the failure.  (Your 0002 is a
> better version of said Asserts.)

Ah, OK. Yeah, I wasn't completely sure at the time whether there was
some kind of TupleDesc out there that would allow zero or negative
indexes safely. It seems like there is not.

-- 
Robert Haas
EDB: http://www.enterprisedb.com



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".