@@ -15106,24 +15106,14 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
15106
15106
idx = index_open (idxid , AccessExclusiveLock );
15107
15107
IndexSetParentIndex (idx , InvalidOid );
15108
15108
update_relispartition (classRel , idxid , false);
15109
- index_close (idx , NoLock );
15110
-
15111
- /*
15112
- * Detach any constraints associated with the index too. Only UNIQUE
15113
- * and PRIMARY KEY index constraints can be inherited, so no need
15114
- * to check for others.
15115
- */
15116
- if (!idx -> rd_index -> indisprimary && !idx -> rd_index -> indisunique )
15117
- continue ;
15118
15109
15110
+ /* If there's a constraint associated with the index, detach it too */
15119
15111
constrOid = get_relation_idx_constraint_oid (RelationGetRelid (partRel ),
15120
15112
idxid );
15121
- if (!OidIsValid (constrOid ))
15122
- elog (ERROR , "missing pg_constraint entry of index \"%s\" of partition \"%s\"" ,
15123
- RelationGetRelationName (idx ),
15124
- RelationGetRelationName (partRel ));
15113
+ if (OidIsValid (constrOid ))
15114
+ ConstraintSetParentConstraint (constrOid , InvalidOid );
15125
15115
15126
- ConstraintSetParentConstraint ( constrOid , InvalidOid );
15116
+ index_close ( idx , NoLock );
15127
15117
}
15128
15118
table_close (classRel , RowExclusiveLock );
15129
15119
0 commit comments