Re: Fix tuple deformation with virtual generated NOT NULL columns
Chao Li <li.evan.chao@gmail.com>
From: Chao Li <li.evan.chao@gmail.com>
To: cca5507 <cca5507@qq.com>
Cc: Postgres hackers <pgsql-hackers@lists.postgresql.org>,
David Rowley <dgrowleyml@gmail.com>
Date: 2026-06-04T10:30:09Z
Lists: pgsql-hackers
Attachments
- v2-0001-Fix-tuple-deformation-with-virtual-generated-NOT-.patch (application/octet-stream) patch v2-0001
> On Jun 4, 2026, at 17:32, cca5507 <cca5507@qq.com> wrote: > >> While testing "Optimize tuple deformation”, I found a bug: >> ``` >> evantest=# create table t (a int not null, >> evantest(# g int generated always as (a+1) virtual not null, >> evantest(# b int not null); >> CREATE TABLE >> evantest=# insert into t (a, b) values (10, 20); >> INSERT 0 1 >> evantest=# select a, g, b from t; >> a | g | b >> ----+----+--- >> 10 | 11 | 0 >> (1 row) >> ``` > > Nice catch! I can reproduce this bug on master. Some comments about the fix: > > I find that a virtual generated column is stored as a null in heap tuple, so I think > we should stop setting 'attcacheoff' when we see a virtual generated column in > TupleDescFinalize(), or we will set wrong 'attcacheoff' value. But it seems that > we don't use these wrong value because we can only use 'attcacheoff' up until > the first NULL. > > -- > Regards, > ChangAo Chen Hi ChangAo, Thanks for your review. Please see v2 that addressed your comment. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/
Commits
-
Update JIT tuple deforming code for virtual generated columns
- e9692de1d6f6 18 (unreleased) landed
- dc5116780846 19 (unreleased) landed
-
Add tuple deformation test for virtual generated columns
- 1f7dfe8c8ef7 19 (unreleased) landed
-
Fix tuple deforming with virtual generated columns
- 89eafad297a9 19 (unreleased) landed