Re: BUG #16276: Server crash on an invalid attempt to attach a partition to an index

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2020-02-27T02:31:20Z
Lists: pgsql-bugs
On Wed, Feb 26, 2020 at 05:06:24PM +0900, Michael Paquier wrote:
> Attempting to attach a table to a partitioned index?  Nice thought.
> Without the assertion, RangeVarCallbackForAttachIndex complains that
> the relation is not an index, which is right, so I would be tempted to
> just remove the culprit assertion.  Any thoughts?

FWIW, one can note that ALTER TABLE ATTACH PARTITION with indexes
correctly registers partition indexes without partition bounds in
pg_class, even if the grammar cannot accept ALTER TABLE without any
bounds defined:
create table idxpart(a int) partition by list (a);
create table idxpart1 partition of idxpart for values in (1);
create index idxpart_idx on only idxpart(a);
create index idxpart1_idx on only idxpart1(a);
alter table idxpart_idx attach partition idxpart1_idx for values in (0);

So I would rather not issue an error in that case on compatibility
ground.
--
Michael

Commits

  1. Fix assertion failure with ALTER TABLE ATTACH PARTITION and indexes