From: Tom Lane <tgl@sss.pgh.pa.us>
To: marc@guidance.nl
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16758: create temporary table with the same name loses defaults, indexes
Date: Tue, 01 Dec 2020 10:58:56 -0500
Message-ID: <1396479.1606838336@sss.pgh.pa.us> (raw)
In-Reply-To: <16758-840e84a6cfab276d@postgresql.org>
References: <16758-840e84a6cfab276d@postgresql.org>
PG Bug reporting form <noreply@postgresql.org> writes:
> 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);
Hm, interesting. Without having dug into the code, I bet what is
happening is that after creating pg_temp.xx, the LIKE code is looking
to see "what indexes exist on table xx?", to which the answer is "none"
because it finds pg_temp.xx. We need to nail down the schema in which
xx is sought for that step. As a workaround, you could nail down the
schema manually:
create temporary table xx (like public.xx including DEFAULTS including
CONSTRAINTS including INDEXES);
The ordering of these operations got rearranged recently to fix some
other bugs, so it doesn't surprise me if it used to work differently.
regards, tom lane
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: tgl@sss.pgh.pa.us, marc@guidance.nl, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16758: create temporary table with the same name loses defaults, indexes
In-Reply-To: <1396479.1606838336@sss.pgh.pa.us>
* 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