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

Commitdabccf4

Browse files
committed
Move RemoveInheritedConstraint() call slightly earlier
This change is harmless and does not affect the existing intendedoperation. It is necessary for a subsequent patch operation (NOTENFORCED foreign keys), where we may need to change the childconstraint to enforced. In this case, we would create the necessarytriggers and queue the constraint for validation, so it is importantto remove any unnecessary constraints before proceeding.This is a small change that could have been included in the previous"split tryAttachPartitionForeignKey" refactoring patch (commit1d26c2d), but was kept separate to highlight the changes.Author: Amul Sul <amul.sul@enterprisedb.com>Reviewed-by: Alexandra Wang <alexandra.wang.oss@gmail.com>Discussion:https://www.postgresql.org/message-id/flat/CAAJ_b962c5AcYW9KUt_R_ER5qs3fUGbe4az-SP-vuwPS-w-AGA%40mail.gmail.com
1 parent1d26c2d commitdabccf4

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11572,6 +11572,21 @@ AttachPartitionForeignKey(List **wqueue,
1157211572
partConstrFrelid = partConstr->confrelid;
1157311573
partConstrRelid = partConstr->conrelid;
1157411574

11575+
/*
11576+
* If the referenced table is partitioned, then the partition we're
11577+
* attaching now has extra pg_constraint rows and action triggers that are
11578+
* no longer needed. Remove those.
11579+
*/
11580+
if (get_rel_relkind(partConstrFrelid) == RELKIND_PARTITIONED_TABLE)
11581+
{
11582+
Relationpg_constraint = table_open(ConstraintRelationId, RowShareLock);
11583+
11584+
RemoveInheritedConstraint(pg_constraint, trigrel, partConstrOid,
11585+
partConstrRelid);
11586+
11587+
table_close(pg_constraint, RowShareLock);
11588+
}
11589+
1157511590
/*
1157611591
* Will we need to validate this constraint? A valid parent constraint
1157711592
* implies that all child constraints have been validated, so if this one
@@ -11608,21 +11623,6 @@ AttachPartitionForeignKey(List **wqueue,
1160811623
TriggerSetParentTrigger(trigrel, updateTriggerOid, parentUpdTrigger,
1160911624
RelationGetRelid(partition));
1161011625

11611-
/*
11612-
* If the referenced table is partitioned, then the partition we're
11613-
* attaching now has extra pg_constraint rows and action triggers that are
11614-
* no longer needed. Remove those.
11615-
*/
11616-
if (get_rel_relkind(partConstrFrelid) == RELKIND_PARTITIONED_TABLE)
11617-
{
11618-
Relationpg_constraint = table_open(ConstraintRelationId, RowShareLock);
11619-
11620-
RemoveInheritedConstraint(pg_constraint, trigrel, partConstrOid,
11621-
partConstrRelid);
11622-
11623-
table_close(pg_constraint, RowShareLock);
11624-
}
11625-
1162611626
/*
1162711627
* We updated this pg_constraint row above to set its parent; validating
1162811628
* it will cause its convalidated flag to change, so we need CCI here. In

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp