1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-28 11:55:03 +03:00

ATTACH PARTITION: Don't match a PK with a UNIQUE constraint

When matching constraints in AttachPartitionEnsureIndexes() we weren't
testing the constraint type, which could make a UNIQUE key lacking a
not-null constraint incorrectly satisfy a primary key requirement.  Fix
this by testing that the constraint types match.  (Other possible
mismatches are verified by comparing index properties.)

Discussion: https://postgr.es/m/202402051447.wimb4xmtiiyb@alvherre.pgsql
This commit is contained in:
Alvaro Herrera
2024-04-15 15:07:47 +02:00
parent 9dfcac8e15
commit cee8db3f68
5 changed files with 52 additions and 0 deletions

View File

@@ -19550,6 +19550,11 @@ AttachPartitionEnsureIndexes(List **wqueue, Relation rel, Relation attachrel)
/* no dice */
if (!OidIsValid(cldConstrOid))
continue;
/* Ensure they're both the same type of constraint */
if (get_constraint_type(constraintOid) !=
get_constraint_type(cldConstrOid))
continue;
}
/* bingo. */