Обсуждение: pgsql: Fix handling of GENERATED columns in CREATE TABLE LIKE INCLUDING

Поиск
Список
Период
Сортировка

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

От
Tom Lane
Дата:
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(-)