set relispartition when attaching child index
Amit Langote <amitlangote09@gmail.com>
From: Amit Langote <amitlangote09@gmail.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Date: 2019-04-24T15:31:03Z
Lists: pgsql-hackers
Attachments
- DefineIndex-update_relispartition.patch (application/octet-stream) patch
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
Commits
-
Fix partitioned index attachment
- b1f570b57ccc 11.3 landed
- 05b38c7e63d1 12.0 landed