CloneFkReferenced-fix.patch
text/plain
Filename: CloneFkReferenced-fix.patch
Type: text/plain
Part: 1
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/backend/commands/tablecmds.c | 2 | 9 |
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 8e26053a5c..2ad30c8452 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8319,8 +8317,8 @@ CloneFkReferenced(Relation parentRel, Relation partitionRel,
{
Form_pg_constraint constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
- /* ignore this constraint if the parent is already on the list */
- if (list_member_oid(clone, constrForm->conparentid))
+ /* Only try to clone the top-level constraint; skip child ones. */
+ if (constrForm->conparentid != InvalidOid)
continue;
clone = lappend_oid(clone, constrForm->oid);
@@ -8348,13 +8346,6 @@ CloneFkReferenced(Relation parentRel, Relation partitionRel,
elog(ERROR, "cache lookup failed for constraint %u", constrOid);
constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
- /* skip children whose parents are going to be cloned, as above */
- if (list_member_oid(clone, constrForm->conparentid))
- {
- ReleaseSysCache(tuple);
- continue;
- }
-
/*
* Because we're only expanding the key space at the referenced side,
* we don't need to prevent any operation in the referencing table, so