]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Allow ALTER COLUMN SET EXPRESSION on virtual columns with CHECK constraints
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 24 Feb 2026 09:30:50 +0000 (10:30 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 24 Feb 2026 09:32:05 +0000 (10:32 +0100)
commitf80bedd52b1501de51b7180cd817e3e1fc31429d
tree6c8ac271e486844c86cb8ddd5636fc20fa2295a8
parent462fe0ff6215ae222fc866af621e4b86462289b1
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.universality@gmail.com>
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Discussion: https://postgr.es/m/CACJufxH3VETr7orF5rW29GnDk3n1wWbOE3WdkHYd3iPGrQ9E_A@mail.gmail.com
doc/src/sgml/ref/alter_table.sgml
src/backend/commands/tablecmds.c
src/test/regress/expected/generated_virtual.out
src/test/regress/sql/generated_virtual.sql