Re: support ALTER COLUMN SET EXPRESSION over virtual generated column with check constraint
Matheus Alcantara <matheusssilv97@gmail.com>
From: Matheus Alcantara <matheusssilv97@gmail.com>
To: jian he <jian.universality@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-01-14T21:01:58Z
Lists: pgsql-hackers
Attachments
- test-no-table-rewrite.diff.nocfbot (text/plain)
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
Commits
-
Allow ALTER COLUMN SET EXPRESSION on virtual columns with CHECK constraints
- f80bedd52b15 19 (unreleased) landed