Re: Fix tuple deformation with virtual generated NOT NULL columns

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix tuple deformation with virtual generated NOT NULL columns
Date: 2026-06-07 01:43:34
Message-ID: 981D66D0-1185-4319-9C32-9317966C8A02@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Jun 6, 2026, at 12:50, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
>
> On Thu, 4 Jun 2026 at 17:57, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>> While testing "Optimize tuple deformation”, I found a bug:
>
>> I think the problem is in finding the first non-guaranteed attribute where virtual generated attributes are not considered:
>
> Thanks for the report and fix. I pushed a slightly adjusted version.

Thanks for pushing.

> Form_pg_attribute.attgenerated is '\0' for non-generated columns, so
> there's no point in checking cattr->attgenerated as well as that.
>

I was trying to avoid unconditionally fetching TupleDescAttr(tupdesc, i), since cattr->attgenerated is already available and most columns won't be virtual generated columns. But I was probably overthinking the performance angle here. TupleDescFinalize() runs only when finalizing a tuple descriptor, not during per-tuple deformation. I agree your adjusted version is cleaner.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-06-07 02:09:44 Re: Fix domain fast defaults on empty tables
Previous Message Peter Geoghegan 2026-06-07 00:52:27 Re: index prefetching