On Fri, 14 May 2021 at 21:08, PG Bug reporting form
<noreply@postgresql.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
waspossible for this re-examination to find a different table of the same name, causing unexpected behavior; one
exampleis 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