public inbox for [email protected]
help / color / mirror / Atom feedFrom: Peter Eisentraut <[email protected]>
To: [email protected]
Subject: pgsql: Fix ALTER TABLE ADD VIRTUAL GENERATED COLUMN when table rewrite
Date: Tue, 04 Mar 2025 08:27:45 +0000
Message-ID: <[email protected]> (raw)
Fix ALTER TABLE ADD VIRTUAL GENERATED COLUMN when table rewrite
demo:
CREATE TABLE gtest20a (a int PRIMARY KEY, b int GENERATED ALWAYS AS (a * 2) VIRTUAL);
ALTER TABLE gtest20a ADD COLUMN c float8 DEFAULT RANDOM() CHECK (b < 60);
ERROR: no generation expression found for column number 2 of table "pg_temp_17306"
In ATRewriteTable, the variable OIDNewHeap (if valid) corresponding
pg_attrdef default expression entry was not populated. So OIDNewHeap
cannot be used to call expand_generated_columns_in_expr or
build_generation_expression. Therefore in ATRewriteTable, we can only
use the existing relation to expand the generated expression.
Author: jian he <[email protected]>
Reviewed-by: Srinath Reddy <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/CACJufxEJ%3DFoajabWXjszo_yrQeKSxdZ87KJqBW373rSbajKGAA%40m...
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/f011acdd61fc296ec8822ca4edc18e32b6bd2b56
Modified Files
--------------
src/backend/commands/tablecmds.c | 2 +-
src/test/regress/expected/generated_stored.out | 4 ++++
src/test/regress/expected/generated_virtual.out | 4 ++++
src/test/regress/sql/generated_stored.sql | 3 +++
src/test/regress/sql/generated_virtual.sql | 3 +++
5 files changed, 15 insertions(+), 1 deletion(-)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: pgsql: Fix ALTER TABLE ADD VIRTUAL GENERATED COLUMN when table rewrite
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox