From cd902b331dc4b0c170e800441a98f9213d98b46b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 9 May 2008 23:32:05 +0000 Subject: 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 --- doc/src/sgml/ref/create_table.sgml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'doc/src/sgml/ref/create_table.sgml') diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index 68e8f045e6a..ef28a8d2152 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -1,5 +1,5 @@ @@ -210,16 +210,25 @@ and table_constraint is: the new table. If the column name list of the new table contains a column name that is also inherited, the data type must likewise match the inherited column(s), and the column - definitions are merged into one. However, inherited and new - column declarations of the same name need not specify identical - constraints: all constraints provided from any declaration are - merged together and all are applied to the new table. If the + definitions are merged into one. If the new table explicitly specifies a default value for the column, this default overrides any defaults from inherited declarations of the column. Otherwise, any parents that specify default values for the column must all specify the same default, or an error will be reported. + + + CHECK constraints are merged in essentially the same way as + columns: if multiple parent tables and/or the new table definition + contain identically-named CHECK constraints, these + constraints must all have the same check expression, or an error will be + reported. Constraints having the same name and expression will + be merged into one copy. Notice that an unnamed CHECK + constraint in the new table will never be merged, since a unique name + will always be chosen for it. + +