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: marc@guidance.nl
Subject: BUG #16758: create temporary table with the same name loses defaults, indexes
Date: Tue, 01 Dec 2020 14:09:49 +0000
Message-ID: <16758-840e84a6cfab276d@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      16758
Logged by:          Marc Boeren
Email address:      marc@guidance.nl
PostgreSQL version: 12.5
Operating system:   macOS / docker-debian / CentOR
Description:        

In 12.5 (and later), in a clean, empty database (in this case the default
12.5 docker image), when I execute the following lines:

    create table xx (name text NOT NULL default '', PRIMARY KEY(name));

    create temporary table xx
        (like xx including DEFAULTS including CONSTRAINTS including
INDEXES);

    select c.relname, n.nspname
    from pg_namespace n
      join pg_class   c on n.oid=c.relnamespace
    where (c.relname LIKE 'x%') order by n.nspname, c.relname;

I get this:

    relname   nspname
    "xx"      "pg_temp_8"
    "xx"      "public"
    "xx_pkey" "public"

I expected the primary key to be copied too. Comparing the results from 12.4
(and earlier versions):

    relname   nspname
    "xx"      "pg_temp_8"
    "xx_pkey" "pg_temp_8"
    "xx"      "public"
    "xx_pkey" "public"

I couldn't find anything in the changelog for 12.5 that indicates it is
intentional. I checked against 13.1 too, same problem.
The actual table is a bit larger (about 100 fields, no relations) and loses
the primary key and all indexes and defaults since 12.5. The SQL above is
the shortest form that demonstrates the issue.

Thanks, Marc



view thread (5+ messages)  latest in thread

Message-ID: <16758-840e84a6cfab276d@postgresql.org>
Permalink:  ../16758-840e84a6cfab276d@postgresql.org/
Also on:    postgresql.org/message-id/16758-840e84a6cfab276d@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, marc@guidance.nl
  Subject: Re: BUG #16758: create temporary table with the same name loses defaults, indexes
  In-Reply-To: <16758-840e84a6cfab276d@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