From: | Amit Langote <amitlangote09(at)gmail(dot)com> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Cc: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
Subject: | set relispartition when attaching child index |
Date: | 2019-04-24 15:31:03 |
Message-ID: | CA+HiwqHMsRtRYRWYTWavKJ8x14AFsv7bmAV46mYwnfD3vy8goQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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
Attachment | Content-Type | Size |
---|---|---|
DefineIndex-update_relispartition.patch | application/octet-stream | 2.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2019-04-24 15:33:41 | Re: set relispartition when attaching child index |
Previous Message | Tom Lane | 2019-04-24 15:30:06 | Re: Help to review the with X cursor option. |