@@ -15106,24 +15106,14 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
1510615106 idx = index_open (idxid , AccessExclusiveLock );
1510715107 IndexSetParentIndex (idx , InvalidOid );
1510815108 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 ;
1511815109
15110+ /* If there's a constraint associated with the index, detach it too */
1511915111 constrOid = get_relation_idx_constraint_oid (RelationGetRelid (partRel ),
1512015112 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 );
1512515115
15126- ConstraintSetParentConstraint ( constrOid , InvalidOid );
15116+ index_close ( idx , NoLock );
1512715117 }
1512815118 table_close (classRel , RowExclusiveLock );
1512915119
0 commit comments