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

Commit71eba83

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 parentb620cf2 commit71eba83

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
@@ -15244,24 +15244,14 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
1524415244
idx=index_open(idxid,AccessExclusiveLock);
1524515245
IndexSetParentIndex(idx,InvalidOid);
1524615246
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;
1525615247

15248+
/* If there's a constraint associated with the index, detach it too */
1525715249
constrOid=get_relation_idx_constraint_oid(RelationGetRelid(partRel),
1525815250
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);
1526315253

15264-
ConstraintSetParentConstraint(constrOid,InvalidOid);
15254+
index_close(idx,NoLock);
1526515255
}
1526615256
heap_close(classRel,RowExclusiveLock);
1526715257

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp