pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix CREATE TABLE LIKE INCLUDING GENERATED column order issue
Date: Thu, 09 Apr 2020 14:42:09 +0000
Message-ID: <E1jMYNd-00087R-5g@gemulon.postgresql.org> (raw)

Fix CREATE TABLE LIKE INCLUDING GENERATED column order issue

CREATE TABLE LIKE INCLUDING GENERATED would fail if a generated column
referred to a column with a higher attribute number.  This is because
the column mapping mechanism created the mapping incrementally as
columns are added.  This was sufficient for previous uses of that
mechanism (omitting dropped columns), and it also happened to work if
generated columns only referred to columns with lower attribute
numbers, but here it failed.

This fix is to build the attribute mapping in a separate loop before
processing the columns in detail.

Bug: #16342
Reported-by: Ethan Waldo <ewaldo@healthetechs.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>

Branch
------
master

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

Modified Files
--------------
src/backend/parser/parse_utilcmd.c              | 25 ++++++++++++++++++---
src/test/regress/expected/create_table_like.out | 29 +++++++++++++------------
src/test/regress/sql/create_table_like.sql      | 19 ++++++++--------
3 files changed, 47 insertions(+), 26 deletions(-)



view thread (2+ messages)  latest in thread

Message-ID: <E1jMYNd-00087R-5g@gemulon.postgresql.org>
Permalink:  ../E1jMYNd-00087R-5g@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1jMYNd-00087R-5g@gemulon.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: peter@eisentraut.org
  Subject: Re: pgsql: Fix CREATE TABLE LIKE INCLUDING GENERATED column order issue
  In-Reply-To: <E1jMYNd-00087R-5g@gemulon.postgresql.org>
  References: <E1jMYNd-00087R-5g@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox