@@ -15244,24 +15244,14 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
15244
15244
idx = index_open (idxid , AccessExclusiveLock );
15245
15245
IndexSetParentIndex (idx , InvalidOid );
15246
15246
update_relispartition (classRel , idxid , false);
15247
- index_close (idx , NoLock );
15248
-
15249
- /*
15250
- * Detach any constraints associated with the index too. Only UNIQUE
15251
- * and PRIMARY KEY index constraints can be inherited, so no need
15252
- * to check for others.
15253
- */
15254
- if (!idx -> rd_index -> indisprimary && !idx -> rd_index -> indisunique )
15255
- continue ;
15256
15247
15248
+ /* If there's a constraint associated with the index, detach it too */
15257
15249
constrOid = get_relation_idx_constraint_oid (RelationGetRelid (partRel ),
15258
15250
idxid );
15259
- if (!OidIsValid (constrOid ))
15260
- elog (ERROR , "missing pg_constraint entry of index \"%s\" of partition \"%s\"" ,
15261
- RelationGetRelationName (idx ),
15262
- RelationGetRelationName (partRel ));
15251
+ if (OidIsValid (constrOid ))
15252
+ ConstraintSetParentConstraint (constrOid , InvalidOid );
15263
15253
15264
- ConstraintSetParentConstraint ( constrOid , InvalidOid );
15254
+ index_close ( idx , NoLock );
15265
15255
}
15266
15256
heap_close (classRel , RowExclusiveLock );
15267
15257
0 commit comments