Re: BUG #17009: create temporary table with like option using same name as persistent table does not create indexes

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: misha_nagel(at)mail(dot)ru, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17009: create temporary table with like option using same name as persistent table does not create indexes
Date: 2021-05-14 09:46:32
Message-ID: CAApHDvpxmRbTBYfJvZCcSEP5eO4CHZiZ9KdY6zyBxhx8hOx=cQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, 14 May 2021 at 21:08, PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
> 12.5 output:
> ce2pg2=> create table t_tmp (a int);
> CREATE TABLE
> ce2pg2=> create index on t_tmp (a);
> CREATE INDEX
> ce2pg2=> create temporary table t_tmp (like t_tmp including all);
> CREATE TABLE
> ce2pg2=> select *
> ce2pg2-> from pg_catalog.pg_indexes
> ce2pg2-> where tablename like 't_tmp%';
> schemaname | tablename | indexname | tablespace |
> indexdef
> ------------+-----------+-------------+------------+---------------------------------------------------------
> test2 | t_tmp | t_tmp_a_idx | | CREATE INDEX
> t_tmp_a_idx ON public.t_tmp USING btree (a)

If you upgrade to 12.6 or 12.7, does it work?

https://www.postgresql.org/docs/12/release-12-6.html mentions:

> Prevent misprocessing of ambiguous CREATE TABLE LIKE clauses (Tom Lane)
> A LIKE clause is re-examined after initial creation of the new table, to handle importation of indexes and such. It was possible for this re-examination to find a different table of the same name, causing unexpected behavior; one example is where the new table is a temporary table of the same name as the LIKE target."

This sounds like it might fix the issue.

David

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Eric Thinnes 2021-05-14 10:54:08 Segmentation fault when calling BlessTupleDesc in a C function in parallel on PostgreSQL-(12.6, 12.7, 13.2, 13.3)
Previous Message PG Bug reporting form 2021-05-14 07:30:08 BUG #17009: create temporary table with like option using same name as persistent table does not create indexes