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:
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user