diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 739a92bdcc1..f8a40140123 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -2645,9 +2645,16 @@ CompareIndexInfo(const IndexInfo *info1, const IndexInfo *info2, return false; } - /* No support currently for comparing exclusion indexes. */ - if (info1->ii_ExclusionOps != NULL || info2->ii_ExclusionOps != NULL) + if (((info1->ii_ExclusionOps == NULL) != (info2->ii_ExclusionOps == NULL))) return false; + if (info1->ii_ExclusionOps != NULL) + { + for (i = 0; i < info1->ii_NumIndexAttrs; i++) + { + if (info1->ii_ExclusionOps[i] != info2->ii_ExclusionOps[i]) + return false; + } + } return true; } diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out index 9ade7b835e6..395c55b0b35 100644 --- a/src/test/regress/expected/create_index.out +++ b/src/test/regress/expected/create_index.out @@ -3482,6 +3482,13 @@ SELECT * FROM bitmap_split_or WHERE a = 1 AND (b = 1 OR b = 2) AND c = 2; DROP TABLE bitmap_split_or; -- +-- Test restoring partitioned tables with exclude constraints. +-- Do not drop these tables; they are used in pg_upgrade tests. +-- +CREATE TABLE regress_table_excl (id int, data int) PARTITION BY LIST (id); +ALTER TABLE regress_table_excl ADD EXCLUDE USING btree(id WITH =, data WITH =); +CREATE TABLE regress_table_excl_1 PARTITION OF regress_table_excl FOR VALUES IN (1); +-- -- REINDEX SCHEMA -- REINDEX SCHEMA schema_to_reindex; -- failure, schema does not exist diff --git a/src/test/regress/sql/create_index.sql b/src/test/regress/sql/create_index.sql index e21ff426519..25ba64cc3f5 100644 --- a/src/test/regress/sql/create_index.sql +++ b/src/test/regress/sql/create_index.sql @@ -1451,6 +1451,14 @@ EXPLAIN (COSTS OFF) SELECT * FROM bitmap_split_or WHERE a = 1 AND (b = 1 OR b = 2) AND c = 2; DROP TABLE bitmap_split_or; +-- +-- Test restoring partitioned tables with exclude constraints. +-- Do not drop these tables; they are used in pg_upgrade tests. +-- +CREATE TABLE regress_table_excl (id int, data int) PARTITION BY LIST (id); +ALTER TABLE regress_table_excl ADD EXCLUDE USING btree(id WITH =, data WITH =); +CREATE TABLE regress_table_excl_1 PARTITION OF regress_table_excl FOR VALUES IN (1); + -- -- REINDEX SCHEMA --