set relispartition when attaching child index

Поиск
Список
Период
Сортировка
Искать
От
Amit Langote
Тема
set relispartition when attaching child index
Дата
Msg-id
CA+HiwqHMsRtRYRWYTWavKJ8x14AFsv7bmAV46mYwnfD3vy8goQ@mail.gmail.com
Список
Дерево обсуждения
set relispartition when attaching child index Amit Langote <amitlangote09@gmail.com>
Re: set relispartition when attaching child index Alvaro Herrera <alvherre@2ndquadrant.com>
Re: set relispartition when attaching child index Alvaro Herrera <alvherre@2ndquadrant.com>
Re: set relispartition when attaching child index Amit Langote <amitlangote09@gmail.com>
Re: set relispartition when attaching child index Amit Langote <amitlangote09@gmail.com>
Re: set relispartition when attaching child index Amit Langote <amitlangote09@gmail.com>
Re: set relispartition when attaching child index Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Re: set relispartition when attaching child index Alvaro Herrera <alvherre@2ndquadrant.com>
Re: set relispartition when attaching child index Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Hi,

It seems that DefineIndex() is forgetting to update_relispartition()
on a partition's index when it's attached to an index being added to
the parent.  That results in unexpected behavior when adding a foreign
key referencing the parent.

create table foo (a int) partition by list (a);
create table foo1 partition of foo for values in (1);
alter table foo1 add primary key (a);
alter table foo add primary key (a);
select relname, relispartition from pg_class where relname = 'foo1_pkey';
  relname  | relispartition
-----------+----------------
 foo1_pkey | f
(1 row)

create table bar (a int references foo);
ERROR:  index for 24683 not found in partition foo1

Attached patch fixes that, but I haven't added any new tests.

PS: Came to know that that's the case when reading this blog on the
new foreign key feature:
https://www.depesz.com/2019/04/24/waiting-for-postgresql-12-support-foreign-keys-that-reference-partitioned-tables/

Thanks,
Amit
В списке pgsql-hackers по дате отправления
От: Tom Lane
Дата:
От: Alvaro Herrera
Дата:
FAQ