| From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Allow ALTER COLUMN SET EXPRESSION on virtual columns with CHECK |
| Date: | 2026-02-24 09:42:06 |
| Message-ID: | E1vuove-000wwm-32@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers pgsql-hackers |
Allow ALTER COLUMN SET EXPRESSION on virtual columns with CHECK constraints
Previously, changing the generation expression of a virtual column was
prohibited if the column was referenced by a CHECK constraint. This
lifts that restriction.
RememberAllDependentForRebuilding within ATExecSetExpression will
rebuild all the dependent constraints, later ATPostAlterTypeCleanup
queues the required AlterTableStmt operations for ALTER TABLE Phase 3
execution.
Overall, ALTER COLUMN SET EXPRESSION on virtual columns may require
scanning the table to re-verify any associated CHECK constraints, but
it does not require a table rewrite in ALTER TABLE Phase 3.
Author: jian he <jian(dot)universality(at)gmail(dot)com>
Reviewed-by: Matheus Alcantara <matheusssilv97(at)gmail(dot)com>
Discussion: https://postgr.es/m/CACJufxH3VETr7orF5rW29GnDk3n1wWbOE3WdkHYd3iPGrQ9E_A@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/f80bedd52b1501de51b7180cd817e3e1fc31429d
Modified Files
--------------
doc/src/sgml/ref/alter_table.sgml | 3 ++
src/backend/commands/tablecmds.c | 25 ++++------------
src/test/regress/expected/generated_virtual.out | 39 +++++++++++++++++++++----
src/test/regress/sql/generated_virtual.sql | 16 ++++++++--
4 files changed, 56 insertions(+), 27 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2026-02-24 10:04:32 | pgsql: Make ALTER DOMAIN VALIDATE CONSTRAINT no-op when constraint is a |
| Previous Message | Michael Paquier | 2026-02-24 04:27:41 | pgsql: Fix variety of typos and grammar mistakes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2026-02-24 09:44:21 | Re: support ALTER COLUMN SET EXPRESSION over virtual generated column with check constraint |
| Previous Message | Dean Rasheed | 2026-02-24 09:09:54 | Re: MERGE behavior with REPEATABLE READ isolation level |