pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: ewaldo@healthetechs.com
Subject: BUG #16342: CREATE TABLE LIKE INCLUDING GENERATED column order issue
Date: Fri, 03 Apr 2020 23:50:51 +0000
Message-ID: <16342-50008a509308f4ca@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      16342
Logged by:          Ethan Waldo
Email address:      ewaldo@healthetechs.com
PostgreSQL version: 12.2
Operating system:   Debian Buster
Description:        

CREATE TABLE succeeds when using generated columns and it doesn't matter
what order they are in.  When CREATE TABLE LIKE INCLUDING GENERATED is used,
it only works if the source column was created first in the original
table.

postgres=# CREATE TABLE test (
  funds float GENERATED ALWAYS AS (cast(funds_t AS double precision))
STORED,
  funds_t text,
  id bigserial not null
);
CREATE TABLE

postgres=# CREATE TABLE IF NOT EXISTS test_temp (LIKE test INCLUDING
GENERATED);
ERROR:  XX000: unexpected varattno 3 in expression to be mapped
LOCATION:  map_variable_attnos_mutator, rewriteManip.c:1255

postgres=# DROP TABLE test;
DROP TABLE

# Works with funds and funds_t order flipped
postgres=# CREATE TABLE test (
  funds_t text,
  funds float GENERATED ALWAYS AS (cast(funds_t AS double precision))
STORED,
  id bigserial not null
);
CREATE TABLE

postgres=# CREATE TABLE IF NOT EXISTS test_temp (LIKE test INCLUDING
GENERATED);
CREATE TABLE
postgres=#



view thread (5+ messages)  latest in thread

Message-ID: <16342-50008a509308f4ca@postgresql.org>
Permalink:  ../16342-50008a509308f4ca@postgresql.org/
Also on:    postgresql.org/message-id/16342-50008a509308f4ca@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 using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, ewaldo@healthetechs.com
  Subject: Re: BUG #16342: CREATE TABLE LIKE INCLUDING GENERATED column order issue
  In-Reply-To: <16342-50008a509308f4ca@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