Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 77fe28f

Browse files
committed
Describe handling of multiply-inherited fields correctly.
1 parent f2122d0 commit 77fe28f

File tree

1 file changed

+46
-18
lines changed

1 file changed

+46
-18
lines changed

doc/src/sgml/ref/create_table.sgml

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v 1.41 2001/02/04 12:18:08 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v 1.42 2001/05/03 17:50:55 tgl Exp $
33
Postgres documentation
44
-->
55

@@ -26,7 +26,7 @@ Postgres documentation
2626
CREATE [ TEMPORARY | TEMP ] TABLE <replaceable class="PARAMETER">table_name</replaceable> (
2727
{ <replaceable class="PARAMETER">column_name</replaceable> <replaceable class="PARAMETER">type</replaceable> [ <replaceable class="PARAMETER">column_constraint</replaceable> [ ... ] ]
2828
| <replaceable>table_constraint</replaceable> } [, ... ]
29-
) [ INHERITS ( <replaceable>inherited_table</replaceable> [, ... ] ) ]
29+
) [ INHERITS ( <replaceable>parent_table</replaceable> [, ... ] ) ]
3030

3131
where <replaceable class="PARAMETER">column_constraint</replaceable> can be:
3232
[ CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ]
@@ -99,17 +99,11 @@ and <replaceable class="PARAMETER">table_constraint</replaceable> can be:
9999
</varlistentry>
100100

101101
<varlistentry>
102-
<term><replaceable class="PARAMETER">inherited_table</replaceable></term>
102+
<term><replaceable class="PARAMETER">parent_table</replaceable></term>
103103
<listitem>
104104
<para>
105105
The optional INHERITS clause specifies a list of table
106106
names from which this table automatically inherits all fields.
107-
If any inherited field name appears more than once,
108-
<productname>Postgres</productname>
109-
reports an error.
110-
<productname>Postgres</productname> automatically allows the created
111-
table to inherit functions on tables above it in the inheritance
112-
hierarchy.
113107
</para>
114108
</listitem>
115109
</varlistentry>
@@ -258,20 +252,54 @@ ERROR: Relation '<replaceable class="parameter">table</replaceable>' already ex
258252
existing datatype.
259253
</para>
260254

255+
<para>
256+
A table can have no more than 1600 columns (in practice, the
257+
effective limit is lower because of tuple-length constraints).
258+
A table cannot have the same name as a system catalog table.
259+
</para>
260+
</refsect1>
261+
262+
<refsect1 id="R1-SQL-INHERITSCLAUSE-1">
263+
<title id="R1-SQL-INHERITSCLAUSE-1-TITLE">
264+
INHERITS Clause
265+
</title>
266+
<para>
267+
<synopsis>
268+
INHERITS ( <replaceable class="PARAMETER">parent_table</replaceable> [, ... ] )
269+
</synopsis>
270+
</para>
271+
261272
<para>
262273
The optional INHERITS
263-
clause specifies a collection of table names from which this table
264-
automatically inherits all fields. If any inherited field name
265-
appears more than once, Postgres reports an error. Postgres automatically
266-
allows the created table to inherit functions on tables above it in
267-
the inheritance hierarchy. Inheritance of functions is done according
268-
to the conventions of the Common Lisp Object System (CLOS).
274+
clause specifies a list of table names from which the new table
275+
automatically inherits all fields. If the same field name appears in
276+
more than one parent table, Postgres reports an error unless the field
277+
definitions match in each of the parent tables. If there is no
278+
definition conflict, then the duplicate fields are merged to form a single
279+
field of the new table. If the new table's own field list contains a
280+
field name that is also inherited, this declaration must likewise match
281+
the inherited field(s), and the field definitions are merged into one.
269282
</para>
270283

271284
<para>
272-
A table can have no more than 1600 columns (in practice, the
273-
effective limit is lower because of tuple-length constraints).
274-
A table cannot have the same name as a system catalog table.
285+
Inherited and new field declarations of the same name must specify exactly
286+
the same data type to avoid an error. They need not specify identical
287+
constraints --- all constraints provided from any declaration are merged
288+
together and all are applied to the new table. If the new table explicitly
289+
specifies a default value for the field, this default overrides any
290+
defaults from inherited declarations of the field. Otherwise, any parents
291+
that specify default values for the field must all specify the same
292+
default, or an error will be reported.
293+
</para>
294+
295+
<para>
296+
Postgres automatically allows the created table to inherit functions on
297+
tables above it in the inheritance hierarchy; that is, if we create table
298+
<literal>foo</literal> inheriting from <literal>bar</literal>, then
299+
functions that accept the tuple type <literal>bar</literal> can also be
300+
applied to instances of <literal>foo</literal>. (Currently, this works
301+
reliably for functions on the first or only parent table, but not so well
302+
for functions on additional parents.)
275303
</para>
276304
</refsect1>
277305

0 commit comments

Comments
 (0)