Describe handling of multiply-inherited fields correctly.
authorTom Lane
Thu, 3 May 2001 17:50:55 +0000 (17:50 +0000)
committerTom Lane
Thu, 3 May 2001 17:50:55 +0000 (17:50 +0000)
doc/src/sgml/ref/create_table.sgml

index 8a7796c575181980079cd7552927d46c71026158..fb5e2b2a5504f5e295fada9f6d941f7903543970 100644 (file)
@@ -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.
        
       
      
@@ -258,20 +252,54 @@ ERROR:  Relation 'table' already ex
    existing datatype.
   
 
+  
+   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.)