From 77fe28f33e49d752be4e4a1bbc6c112f825e7882 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 3 May 2001 17:50:55 +0000 Subject: [PATCH] Describe handling of multiply-inherited fields correctly. --- doc/src/sgml/ref/create_table.sgml | 64 +++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index 8a7796c575..fb5e2b2a55 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -1,5 +1,5 @@ @@ -26,7 +26,7 @@ Postgres documentation CREATE [ TEMPORARY | TEMP ] TABLE table_name ( { column_name type [ column_constraint [ ... ] ] | table_constraint } [, ... ] - ) [ INHERITS ( inherited_table [, ... ] ) ] + ) [ INHERITS ( parent_table [, ... ] ) ] where column_constraint can be: [ CONSTRAINT constraint_name ] @@ -99,17 +99,11 @@ and table_constraint can be: - inherited_table + parent_table The optional INHERITS clause specifies a list of table names from which this table automatically inherits all fields. - If any inherited field name appears more than once, - Postgres - reports an error. - Postgres automatically allows the created - table to inherit functions on tables above it in the inheritance - hierarchy. @@ -259,19 +253,53 @@ ERROR: Relation 'table' already ex + A table can have no more than 1600 columns (in practice, the + effective limit is lower because of tuple-length constraints). + A table cannot have the same name as a system catalog table. + + + + + + INHERITS Clause + + + +INHERITS ( parent_table [, ... ] ) + + + + The optional INHERITS - clause specifies a collection of table names from which this table - automatically inherits all fields. If any inherited field name - appears more than once, Postgres reports an error. Postgres automatically - allows the created table to inherit functions on tables above it in - the inheritance hierarchy. Inheritance of functions is done according - to the conventions of the Common Lisp Object System (CLOS). + clause specifies a list of table names from which the new table + automatically inherits all fields. If the same field name appears in + more than one parent table, Postgres reports an error unless the field + definitions match in each of the parent tables. If there is no + definition conflict, then the duplicate fields are merged to form a single + field of the new table. If the new table's own field list contains a + field name that is also inherited, this declaration must likewise match + the inherited field(s), and the field definitions are merged into one. - A table can have no more than 1600 columns (in practice, the - effective limit is lower because of tuple-length constraints). - A table cannot have the same name as a system catalog table. + Inherited and new field declarations of the same name must specify exactly + the same data type to avoid an error. They need not specify identical + constraints --- all constraints provided from any declaration are merged + together and all are applied to the new table. If the new table explicitly + specifies a default value for the field, this default overrides any + defaults from inherited declarations of the field. Otherwise, any parents + that specify default values for the field must all specify the same + default, or an error will be reported. + + + + Postgres automatically allows the created table to inherit functions on + tables above it in the inheritance hierarchy; that is, if we create table + foo inheriting from bar, then + functions that accept the tuple type bar can also be + applied to instances of foo. (Currently, this works + reliably for functions on the first or only parent table, but not so well + for functions on additional parents.) -- 2.11.0