Allow ALTER COLUMN SET EXPRESSION on virtual columns with CHECK constraints
Peter Eisentraut <peter@eisentraut.org>
Author:
Peter Eisentraut <peter@eisentraut.org>
Date: 2026-02-24T09:32:05Z
Releases:
19 (unreleased)
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
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/ref/alter_table.sgml | modified | +3 −0 |
| src/backend/commands/tablecmds.c | modified | +6 −19 |
| src/test/regress/expected/generated_virtual.out | modified | +33 −6 |
| src/test/regress/sql/generated_virtual.sql | modified | +14 −2 |
Discussion
- support ALTER COLUMN SET EXPRESSION over virtual generated column with check constraint 13 messages · 2025-03-11 → 2026-02-24