pgsql: Fix handling of generated columns in ALTER TABLE.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix handling of generated columns in ALTER TABLE.
Date: 2020-01-08 14:43:17
Message-ID: E1ipCYH-00012T-Vl@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix handling of generated columns in ALTER TABLE.

ALTER TABLE failed if a column referenced in a GENERATED expression
had been added or changed in type earlier in the ALTER command.
That's because the GENERATED expression needs to be evaluated
against the table's updated tuples, but it was being evaluated
against the original tuples. (Fortunately the executor has adequate
cross-checks to notice the mismatch, so we just got an obscure error
message and not anything more dangerous.)

Per report from Andreas Joseph Krogh. Back-patch to v12 where
GENERATED was added.

Discussion: https://postgr.es/m/VisenaEmail.200.231b0a41523275d0.16ea7f800c7@tc7-visena

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c24f3b70efc243bb44a6a4121032f19e2d6e813e

Modified Files
--------------
src/backend/commands/tablecmds.c | 33 ++++++++++-
src/test/regress/expected/generated.out | 97 ++++++++++++++++++++++++++-------
src/test/regress/sql/generated.sql | 31 +++++++++--
3 files changed, 132 insertions(+), 29 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2020-01-08 15:04:17 Re: src/test/recovery regression failure on bionic
Previous Message Christoph Berg 2020-01-08 14:38:25 src/test/recovery regression failure on bionic