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

Поиск
Список
Период
Сортировка
От PG Bug reporting form
Тема BUG #17009: create temporary table with like option using same name as persistent table does not create indexes
Дата
Msg-id 17009-b364ef2e97142a54@postgresql.org
обсуждение исходный текст
Ответы Re: BUG #17009: create temporary table with like option using same name as persistent table does not create indexes  (David Rowley <dgrowleyml@gmail.com>)
Список pgsql-bugs
The following bug has been logged on the website:

Bug reference:      17009
Logged by:          Mikhail Nagel
Email address:      misha_nagel@mail.ru
PostgreSQL version: 12.5
Operating system:   Debian x64
Description:

test:
create table t_tmp (a int);
create index on t_tmp (a);
create temporary table t_tmp (like t_tmp including all);
select * 
from pg_catalog.pg_indexes 
where tablename  like 't_tmp%';
drop table t_tmp;
drop table t_tmp;

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)
(1 строка)

index on temporary table "t_tmp" not created

12.3 and 13.3 output:
postgres=# create table t_tmp (a int);
CREATE TABLE
postgres=# create index on t_tmp (a);
CREATE INDEX
postgres=# create temporary table t_tmp (like t_tmp including all);
CREATE TABLE
postgres=# select *
postgres-# from pg_catalog.pg_indexes
postgres-# where tablename  like 't_tmp%';
 schemaname | tablename |  indexname   | tablespace |
   indexdef
------------+-----------+--------------+------------+---------------------------------------------------------------
 public     | t_tmp     | t_tmp_a_idx  |            | CREATE INDEX
t_tmp_a_idx ON public.t_tmp USING btree (a)
 pg_temp_4  | t_tmp     | t_tmp_a_idx  |            | CREATE INDEX
t_tmp_a_idx ON pg_temp_4.t_tmp USING btree (a)
(2 строки)

as expected index on temporary table "t_tmp" was created (second row)

workaround 
1. use different table name
create temporary table t_other_name (like t_tmp including all);
2. use schema in like option
create temporary table t_tmp (like public.t_tmp including all);


В списке pgsql-bugs по дате отправления:

Предыдущее
От: Alex F
Дата:
Сообщение: Re: BUG #16833: postgresql 13.1 process crash every hour
Следующее
От: David Rowley
Дата:
Сообщение: Re: BUG #17009: create temporary table with like option using same name as persistent table does not create indexes