aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-10-13 17:05:15 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2016-10-13 17:05:15 -0400
commitf2024d59ae7f20b8d51eaf29e543c50ec88488f0 (patch)
tree60d104a1ef5f23a3c34fca32d9e3262b0f295826 /src/backend
parent6d3cbbf5954250638ea5837bf514a6d392f2329e (diff)
downloadpostgresql-f2024d59ae7f20b8d51eaf29e543c50ec88488f0.tar.gz
postgresql-f2024d59ae7f20b8d51eaf29e543c50ec88488f0.zip
Fix another bug in merging of inherited CHECK constraints.
It's not good for an inherited child constraint to be marked connoinherit; that would result in the constraint not propagating to grandchild tables, if any are created later. The code mostly prevented this from happening but there was one case that was missed. This is somewhat related to commit e55a946a8, which also tightened checks on constraint merging. Hence, back-patch to 9.2 like that one. This isn't so much because there's a concrete feature-related reason to stop there, as to avoid having more distinct behaviors than we have to in this area. Amit Langote Discussion: <b28ee774-7009-313d-dd55-5bdd81242c41@lab.ntt.co.jp>
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/catalog/heap.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 44f7f269ef2..3a8cf53646a 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -2432,6 +2432,17 @@ MergeWithExistingConstraint(Relation rel, char *ccname, Node *expr,
ccname, RelationGetRelationName(rel))));
/*
+ * Must not change an existing inherited constraint to "no
+ * inherit" status. That's because inherited constraints should
+ * be able to propagate to lower-level children.
+ */
+ if (con->coninhcount > 0 && is_no_inherit)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("constraint \"%s\" conflicts with inherited constraint on relation \"%s\"",
+ ccname, RelationGetRelationName(rel))));
+
+ /*
* If the child constraint is "not valid" then cannot merge with a
* valid parent constraint
*/