pgsql: Expand virtual generated columns for ALTER COLUMN TYPE

From: Richard Guo <rguo(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Expand virtual generated columns for ALTER COLUMN TYPE
Date: 2025-06-26 03:18:32
Message-ID: E1uUd8C-003NCp-0Q@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Expand virtual generated columns for ALTER COLUMN TYPE

For the subcommand ALTER COLUMN TYPE of the ALTER TABLE command, the
USING expression may reference virtual generated columns. These
columns must be expanded before the expression is fed through
expression_planner and the expression-execution machinery. Failing to
do so can result in incorrect rewrite decisions, and can also lead to
"ERROR: unexpected virtual generated column reference".

Reported-by: Alexander Lakhin <exclusion(at)gmail(dot)com>
Reviewed-by: jian he <jian(dot)universality(at)gmail(dot)com>
Discussion: https://postgr.es/m/b5f96b24-ccac-47fd-9e20-14681b894f36@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5069fef1cfae271ca62e254b16dc831145bc5a4f

Modified Files
--------------
src/backend/commands/tablecmds.c | 3 +++
src/test/regress/expected/generated_virtual.out | 36 ++++++++++++++-----------
src/test/regress/sql/generated_virtual.sql | 10 ++++---
3 files changed, 30 insertions(+), 19 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-06-26 05:28:22 Re: pgsql: Introduce pg_shmem_allocations_numa view
Previous Message vignesh C 2025-06-25 16:52:02 Re: pgsql: Improve runtime and output of tests for replication slots checkp