0002-Don-t-recurse-in-ATExecDropConstraint-for-non-CHECK-.patch

text/plain

Filename: 0002-Don-t-recurse-in-ATExecDropConstraint-for-non-CHECK-.patch
Type: text/plain
Part: 1
Message: Re: problems with foreign keys on partitioned tables

Patch

Format: format-patch
Series: patch 0002
Subject: Don't recurse in ATExecDropConstraint for non-CHECK constraints
File+
src/backend/commands/tablecmds.c 12 0
From c2c9bd4c4976902525ebfcb0e32eb8249df549c9 Mon Sep 17 00:00:00 2001
From: amit <amitlangote09@gmail.com>
Date: Thu, 24 Jan 2019 20:42:11 +0900
Subject: [PATCH 2/2] Don't recurse in ATExecDropConstraint for non-CHECK
 constraints

---
 src/backend/commands/tablecmds.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index fea4d99735..82e2cf1473 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -9134,6 +9134,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
 	HeapTuple	tuple;
 	bool		found = false;
 	bool		is_no_inherit_constraint = false;
+	char		contype;
 
 	/* At top level, permission check was done in ATPrepCmd, else do it */
 	if (recursing)
@@ -9203,6 +9204,7 @@ ATExecDropConstraint(Relation rel, const char *constrName,
 		performDeletion(&conobj, behavior, 0);
 
 		found = true;
+		contype = con->contype;
 	}
 
 	systable_endscan(scan);
@@ -9227,6 +9229,16 @@ ATExecDropConstraint(Relation rel, const char *constrName,
 	}
 
 	/*
+	 * Non-CHECK inherited constraints are dropped via dependency mechanism,
+	 * so we're done here for such constraints.
+	 */
+	if (contype != CONSTRAINT_CHECK)
+	{
+		table_close(conrel, RowExclusiveLock);
+		return;
+	}
+
+	/*
 	 * Propagate to children as appropriate.  Unlike most other ALTER
 	 * routines, we have to do this one level of recursion at a time; we can't
 	 * use find_all_inheritors to do it in one pass.
-- 
2.11.0