> create schema w1; set search_path = w1; > create table p (id int not null, a int not null) partition by list (id); > create table p1 partition of p for values in (1); > create table p2 partition of p for values in (2); > create index p_idx on only p (a); -- invalid parent: nothing attached > create index tmp on p2 (a); > alter index p_idx attach partition tmp; -- p2 attached, p1 still not > alter index tmp rename to p1_a_idx; -- p2's index holds p1's default name > alter table p alter column a type bigint; -- ERROR: relation > "p1_a_idx" already exists; should work
Nice find! This is not v18 specific and has existed since we started preserving index names. The main issue here is the name clash during partition index rebuild. Checking pg_class alone is not sufficient, because that only sees names that currently exist in the catalogs. In this case we also have names from the old descendant index hierarchy that have already been captured and are effectively reserved by the current command, even though they are not visible in pg_class yet. So, v19 follows the existing pg_constraint pattern and tracks the names reserved during the command. When we need to auto-generate a replacement child index name, we check both the catalog and the reserved names list. I added a test case for this also. > Also, with the additional split 0003 now deletes a test case added by > 0001, is that intentional? That was my splitting of patches mistake. Fixed. -- Sami Imseih Amazon Web Services (AWS)
v19-0001-Preserve-index-DEPENDS-ON-EXTENSION-across-ALTER.patch
Description: Binary data
v19-0002-Preserve-index-per-column-statistics-targets-acr.patch
Description: Binary data
v19-0003-Preserve-descendant-partition-index-properties-a.patch
Description: Binary data
