Re: support ALTER COLUMN SET EXPRESSION over virtual generated column with check constraint - Mailing list pgsql-hackers

From Matheus Alcantara
Subject Re: support ALTER COLUMN SET EXPRESSION over virtual generated column with check constraint
Date
Msg-id c2d6c637-8952-423c-b84c-bd805e8e4143@gmail.com
Whole thread Raw
In response to support ALTER COLUMN SET EXPRESSION over virtual generated column with check constraint  (jian he <jian.universality@gmail.com>)
Responses Re: support ALTER COLUMN SET EXPRESSION over virtual generated column with check constraint
List pgsql-hackers
Hi,

On 06/07/25 23:24, jian he wrote:
> hi.
> rebased only.

+--test no table rewrite happen
+ALTER TABLE gtest20 ALTER COLUMN b SET EXPRESSION AS (a * 4), ADD 
COLUMN C int default 11;
+SELECT  pa.attnum,pa.attname,attmissingval
+FROM    pg_attribute pa
+JOIN    pg_attrdef patt ON pa.attrelid = patt.adrelid AND pa.attnum = 
patt.adnum
+WHERE   pa.attrelid = 'gtest20'::regclass

Not sure if I understand the goal of this query. Is to check if the 
table was not rewritten after an update on the virtual generated 
column? If that's the case, I've tested this query by updating the 
expression from a STORED generated column and it return the same 
results, before and after the alter table, so I'm not sure if it's the 
best way to test this, or I'm missing something?

Perhaps we could use pg_relation_filenode() and use \gset to store the 
value on a variable before the ALTER TABLE execution and check if the 
value is the same after the ALTER TABLE SET EXPRESSION is executed. 
Please see the attached diff for reference.


--
Matheus Alcantara
EDB: https://www.enterprisedb.com
Attachment

pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: how to gate experimental features (SQL/PGQ)
Next
From: Kirill Reshke
Date:
Subject: Re: PL/Python initialization cleanup