Re: Fix tuple deformation with virtual generated NOT NULL columns - Mailing list pgsql-hackers

From David Rowley
Subject Re: Fix tuple deformation with virtual generated NOT NULL columns
Date
Msg-id CAApHDvpE1Jx=NrwUCihrfP+Dmkfn6kUkpCZYC10Yo+wkMu3ssQ@mail.gmail.com
Whole thread
In response to Re: Fix tuple deformation with virtual generated NOT NULL columns  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Thu, 18 Jun 2026 at 10:45, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> set jit = 1;
> set jit_above_cost = 0;
> set jit_optimize_above_cost = 1000;
> CREATE TABLE gtest21c (a int NOT NULL, b int GENERATED ALWAYS AS (a * 2) VIRTUAL NOT NULL, c int NOT NULL);
> INSERT INTO gtest21c (a, c) VALUES (10, 42);
> table gtest21c;
>
> I conclude that something in the JIT code for tuple formation
> is unaware of virtual generated columns.

Just starting to look now, but I suspect that this code in
llvmjit_deform.c needs to be updated now that we have virtual
generated columns.

/*
* If the column is declared NOT NULL then it must be present in every
* tuple, unless there's a "missing" entry that could provide a
* non-NULL value for it. That in turn guarantees that the NULL bitmap
* - if there are any NULLable columns - is at least long enough to
* cover columns up to attnum.
*
* Be paranoid and also check !attisdropped, even though the
* combination of attisdropped && attnotnull combination shouldn't
* exist.
*/
if (att->attnullability == ATTNULLABLE_VALID &&
!att->atthasmissing &&
!att->attisdropped)
guaranteed_column_number = attnum;

David



pgsql-hackers by date:

Previous
From: Peter Smith
Date:
Subject: Re: DOCS - Clarify behaviour when EXCEPT tables are moved/renamed
Next
From: Jeff Davis
Date:
Subject: Re: Bug in ALTER SUBSCRIPTION ... SERVER / ... CONNECTION with broken old server