pgsql: Fix handling of GENERATED columns in CREATE TABLE LIKE INCLUDING

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 CREATE TABLE LIKE INCLUDING
Date: 2019-09-25 21:30:58
Message-ID: E1iDEsE-0000py-GB@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix handling of GENERATED columns in CREATE TABLE LIKE INCLUDING DEFAULTS.

LIKE INCLUDING DEFAULTS tried to copy the attrdef expression without
copying the state of the attgenerated column. This is in fact wrong,
because GENERATED and DEFAULT expressions are not the same kind of animal;
one can contain Vars and the other not. We *must* copy attgenerated
when we're copying the attrdef expression. Rearrange the if-tests
so that the expression is copied only when the correct one of
INCLUDING DEFAULTS and INCLUDING GENERATED has been specified.

Per private report from Manuel Rigger.

Tom Lane and Peter Eisentraut

Branch
------
master

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

Modified Files
--------------
src/backend/parser/parse_utilcmd.c | 12 ++--
src/test/regress/expected/create_table_like.out | 74 +++++++++++++++++++++++++
src/test/regress/sql/create_table_like.sql | 20 +++++++
3 files changed, 100 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alexander Korotkov 2019-09-25 22:30:30 Re: pgsql: Implement jsonpath .datetime() method
Previous Message Alexander Korotkov 2019-09-25 21:05:58 Re: pgsql: Implement jsonpath .datetime() method