aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/tablecmds.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 1ada38908c1..18ff8956577 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -11573,6 +11573,21 @@ AttachPartitionForeignKey(List **wqueue,
partConstrRelid = partConstr->conrelid;
/*
+ * If the referenced table is partitioned, then the partition we're
+ * attaching now has extra pg_constraint rows and action triggers that are
+ * no longer needed. Remove those.
+ */
+ if (get_rel_relkind(partConstrFrelid) == RELKIND_PARTITIONED_TABLE)
+ {
+ Relation pg_constraint = table_open(ConstraintRelationId, RowShareLock);
+
+ RemoveInheritedConstraint(pg_constraint, trigrel, partConstrOid,
+ partConstrRelid);
+
+ table_close(pg_constraint, RowShareLock);
+ }
+
+ /*
* Will we need to validate this constraint? A valid parent constraint
* implies that all child constraints have been validated, so if this one
* isn't, we must trigger phase 3 validation.
@@ -11609,21 +11624,6 @@ AttachPartitionForeignKey(List **wqueue,
RelationGetRelid(partition));
/*
- * If the referenced table is partitioned, then the partition we're
- * attaching now has extra pg_constraint rows and action triggers that are
- * no longer needed. Remove those.
- */
- if (get_rel_relkind(partConstrFrelid) == RELKIND_PARTITIONED_TABLE)
- {
- Relation pg_constraint = table_open(ConstraintRelationId, RowShareLock);
-
- RemoveInheritedConstraint(pg_constraint, trigrel, partConstrOid,
- partConstrRelid);
-
- table_close(pg_constraint, RowShareLock);
- }
-
- /*
* We updated this pg_constraint row above to set its parent; validating
* it will cause its convalidated flag to change, so we need CCI here. In
* addition, we need it unconditionally for the rare case where the parent