Subject: pgsql: Whole-row fixes for ALTER COLUMN SET EXPRESSION

From: Peter Eisentraut <[email-masked]>
Date: Wed, 08 Jul 2026 17:58:34 +0000

Whole-row fixes for ALTER COLUMN SET EXPRESSION

When changing the expression of a generated column via ALTER TABLE
ALTER COLUMN SET EXPRESSION, objects that depend on the column via
indirect whole-row references (such as CHECK constraints, indexes)
must be handled specially, because technically pg_depend does not
contain such dependencies, see
recordDependencyOnSingleRelExpr->find_expr_references_walker.

This is a fix for commit f80bedd52, "Allow ALTER COLUMN SET EXPRESSION
on virtual columns with CHECK constraints".

Author: jian he <[email-masked]>
Co-authored-by: Peter Eisentraut <[email-masked]>
Reported-by: Ayush Tiwari <[email-masked]>
Reviewed-by: Ayush Tiwari <[email-masked]>
Reviewed-by: solai v <[email-masked]>
Reviewed-by: Zsolt Parragi <[email-masked]>
Discussion: https://www.postgresql.org/message-id/flat/[email-masked]

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9530898940302d6f501fb54a3fbc61cbfb7768bf

Modified Files
--------------
src/backend/commands/tablecmds.c                | 176 ++++++++++++++++++++++++
src/test/regress/expected/generated_stored.out  |   9 ++
src/test/regress/expected/generated_virtual.out |   9 ++
src/test/regress/sql/generated_stored.sql       |  10 ++
src/test/regress/sql/generated_virtual.sql      |  10 ++
5 files changed, 214 insertions(+)