Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit19184fc

Browse files
committed
Simplify coding to detach constraints when detaching partition
The original coding was too baroque and led to an use-after-releasemistake, noticed by buildfarm member prion.Discussion:https://postgr.es/m/21693.1548305934@sss.pgh.pa.us
1 parentfd1afdb commit19184fc

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp