diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-09-15 17:24:54 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-09-15 17:24:54 -0400 |
commit | 5225c66336a1e4b46925e9f169086fc70f49736f (patch) | |
tree | 2d59b13a6ac635fb06b386455f12a48a7f98a80f | |
parent | 5c6df67e0c961f68e73e7c1e6312211ed59da00a (diff) | |
download | postgresql-5225c66336a1e4b46925e9f169086fc70f49736f.tar.gz postgresql-5225c66336a1e4b46925e9f169086fc70f49736f.zip |
Clarify policy on marking inherited constraints as valid.
Amit Langote and Robert Haas
-rw-r--r-- | doc/src/sgml/ref/alter_table.sgml | 14 | ||||
-rw-r--r-- | src/backend/commands/tablecmds.c | 3 |
2 files changed, 11 insertions, 6 deletions
diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index 6f51cbc8962..e48ccf21e4f 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -1028,11 +1028,15 @@ ALTER TABLE ALL IN TABLESPACE <replaceable class="PARAMETER">name</replaceable> <para> If a table has any descendant tables, it is not permitted to add, - rename, or change the type of a column, or rename an inherited constraint - in the parent table without doing - the same to the descendants. That is, <command>ALTER TABLE ONLY</command> - will be rejected. This ensures that the descendants always have - columns matching the parent. + rename, or change the type of a column in the parent table without doing + same to the descendants. This ensures that the descendants always have + columns matching the parent. Similarly, a constraint cannot be renamed + in the parent without also renaming it in all descendents, so that + constraints also match between the parent and its descendents. + Also, because selecting from the parent also selects from its descendents, + a constraint on the parent cannot be marked valid unless it is also marked + valid for those descendents. In all of these cases, <command>ALTER TABLE + ONLY</command> will be rejected. </para> <para> diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 86e98148c16..d31276284ce 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -6908,7 +6908,8 @@ ATExecValidateConstraint(Relation rel, char *constrName, bool recurse, /* * If we are told not to recurse, there had better not be any - * child tables; else the addition would put them out of step. + * child tables, because we can't mark the constraint on the + * parent valid unless it is valid for all child tables. */ if (!recurse) ereport(ERROR, |