Stored generated columns are NULL in transition tables of partitioned tables

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Stored generated columns are NULL in transition tables of partitioned tables
Date: 2026-11-10 03:23:22
Message-ID: CAGRkXqQMYy=Go5e42-C+b+9ppvXOxS1OyEdVEMTkcG7Z=mvKbQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

If a partition needs tuple conversion, the NEW TABLE of an AFTER trigger
on the parent shows NULL for stored generated columns.

create table t (a int, junk int, b int,
g int generated always as (b * 2) stored)
partition by range (a);
alter table t drop column junk;
create table t1 partition of t for values from (0) to (100);
create trigger tr after insert on t referencing new table as n
for each statement execute function show_n();
copy t (a, b) from stdin;
1 10
\.

0001 fixes it and 0002 adds a test. This affects 14 to 19.

003 is for master only. It passes the original tuple again in ExecInsert(),
which
398eb35f001 stopped doing.

Thanks,
Shihao

Attachment Content-Type Size
v1-0002-Test-stored-generated-columns-in-transition-tables-o.patch application/octet-stream 2.9 KB
v1-0001-Fix-stored-generated-columns-in-transition-tables-of.patch application/octet-stream 3.0 KB
v1-0003-Pass-the-original-tuple-to-AFTER-ROW-triggers-in-Exe.patch application/octet-stream 1.2 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message shihao zhong 2026-11-10 03:34:36 Re: [PATCH] Periodically refresh database frozen IDs during autovacuum
Previous Message Kirill Reshke 2026-11-10 03:01:07 Re: Reduce build times of pg_trgm GIN indexes