mirror of
https://github.com/postgres/postgres.git
synced 2025-12-21 05:21:08 +03:00
Change the rules for inherited CHECK constraints to be essentially the same
as those for inherited columns; that is, it's no longer allowed for a child table to not have a check constraint matching one that exists on a parent. This satisfies the principle of least surprise (rows selected from the parent will always appear to meet its check constraints) and eliminates some longstanding bogosity in pg_dump, which formerly had to guess about whether check constraints were really inherited or not. The implementation involves adding conislocal and coninhcount columns to pg_constraint (paralleling attislocal and attinhcount in pg_attribute) and refactoring various ALTER TABLE actions to be more like those for columns. Alex Hunsaker, Nikhil Sontakke, Tom Lane
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.81 2008/01/13 17:58:54 tgl Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.82 2008/05/09 23:32:03 tgl Exp $ -->
|
||||
|
||||
<chapter id="ddl">
|
||||
<title>Data Definition</title>
|
||||
@@ -2107,7 +2107,8 @@ VALUES ('New York', NULL, NULL, 'NY');
|
||||
|
||||
<para>
|
||||
A parent table cannot be dropped while any of its children remain. Neither
|
||||
can columns of child tables be dropped or altered if they are inherited
|
||||
can columns or check constraints of child tables be dropped or altered
|
||||
if they are inherited
|
||||
from any parent tables. If you wish to remove a table and all of its
|
||||
descendants, one easy way is to drop the parent table with the
|
||||
<literal>CASCADE</literal> option.
|
||||
@@ -2117,7 +2118,7 @@ VALUES ('New York', NULL, NULL, 'NY');
|
||||
<xref linkend="sql-altertable" endterm="sql-altertable-title"> will
|
||||
propagate any changes in column data definitions and check
|
||||
constraints down the inheritance hierarchy. Again, dropping
|
||||
columns or constraints on parent tables is only possible when using
|
||||
columns that are depended on by other tables is only possible when using
|
||||
the <literal>CASCADE</literal> option. <command>ALTER
|
||||
TABLE</command> follows the same rules for duplicate column merging
|
||||
and rejection that apply during <command>CREATE TABLE</command>.
|
||||
|
||||
Reference in New Issue
Block a user