aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2012-07-20 12:33:34 -0400
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2012-07-20 14:07:09 -0400
commitd721f208afeac72a943dc88d072ff3df05f53fef (patch)
tree7e6ef8afd6668d6c3407093c691b9df0c0763306 /src/backend/commands/tablecmds.c
parentd7991a13d86e2b94b0ca3d087fdad8a840ebf025 (diff)
downloadpostgresql-d721f208afeac72a943dc88d072ff3df05f53fef.tar.gz
postgresql-d721f208afeac72a943dc88d072ff3df05f53fef.zip
connoinherit may be true only for CHECK constraints
The code was setting it true for other constraints, which is bogus. Doing so caused bogus catalog entries for such constraints, and in particular caused an error to be raised when trying to drop a constraint of types other than CHECK from a table that has children, such as reported in bug #6712. In 9.2, additionally ignore connoinherit=true for other constraint types, to avoid having to force initdb; existing databases might already contain bogus catalog entries. Includes a catversion bump (in HEAD only). Bug report from Miroslav Ć ulc Analysis from Amit Kapila and Noah Misch; Amit also contributed the patch.
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 70e408cb6ea..6ff08a29cc1 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -6039,7 +6039,7 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel,
NULL,
true, /* islocal */
0, /* inhcount */
- false); /* isnoinherit */
+ true); /* isnoinherit */
/*
* Create the triggers that will enforce the constraint.
@@ -6948,6 +6948,16 @@ ATExecDropConstraint(Relation rel, const char *constrName,
is_no_inherit_constraint = con->connoinherit;
/*
+ * XXX as a special hack, we turn on no-inherit here unconditionally
+ * except for CHECK constraints. This is because 9.2 until beta2
+ * contained a bug that marked it false for all constraints, even
+ * though it was only supported false for CHECK constraints.
+ * See bug #6712.
+ */
+ if (con->contype != CONSTRAINT_CHECK)
+ is_no_inherit_constraint = true;
+
+ /*
* Perform the actual constraint deletion
*/
conobj.classId = ConstraintRelationId;