summaryrefslogtreecommitdiff
path: root/doc/src/sgml
diff options
context:
space:
mode:
authorTom Lane2001-01-05 06:34:23 +0000
committerTom Lane2001-01-05 06:34:23 +0000
commit2fb6cc904555024ef668f5ba096b5bf0ddd3ec26 (patch)
tree267b9c28722477567b05001e1e37cf03afc7dc09 /doc/src/sgml
parente62c38d0fccd16593ab2b126e97ea890ac646943 (diff)
Remove not-really-standard implementation of CREATE TABLE's UNDER clause,
and revert documentation to describe the existing INHERITS clause instead, per recent discussion in pghackers. Also fix implementation of SQL_inheritance SET variable: it is not cool to look at this var during the initial parsing phase, only during parse_analyze(). See recent bug report concerning misinterpretation of date constants just after a SET TIMEZONE command. gram.y really has to be an invariant transformation of the query string to a raw parsetree; anything that can vary with time must be done during parse analysis.
Diffstat (limited to 'doc/src/sgml')
-rw-r--r--doc/src/sgml/advanced.sgml29
-rw-r--r--doc/src/sgml/inherit.sgml55
-rw-r--r--doc/src/sgml/ref/alter_table.sgml6
-rw-r--r--doc/src/sgml/ref/create_table.sgml29
4 files changed, 70 insertions, 49 deletions
diff --git a/doc/src/sgml/advanced.sgml b/doc/src/sgml/advanced.sgml
index 0e1cf4df4d7..dcfe90eec3b 100644
--- a/doc/src/sgml/advanced.sgml
+++ b/doc/src/sgml/advanced.sgml
@@ -1,5 +1,5 @@
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.19 2000/12/30 19:11:45 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.20 2001/01/05 06:34:15 tgl Exp $
-->
<chapter id="advanced">
@@ -33,9 +33,9 @@ CREATE TABLE cities (
altitude int -- (in ft)
);
-CREATE TABLE capitals UNDER cities (
+CREATE TABLE capitals (
state char(2)
-);
+) INHERITS (cities);
</programlisting>
In this case, an instance of capitals <firstterm>inherits</firstterm> all
@@ -64,12 +64,12 @@ CREATE TABLE capitals UNDER cities (
<para>
For example, the following query finds the names of all cities,
including state capitals, that are located at an altitude
- over 500ft, the query is:
+ over 500ft:
<programlisting>
-SELECT c.name, c.altitude
- FROM cities c
- WHERE c.altitude > 500;
+SELECT name, altitude
+ FROM cities
+ WHERE altitude &gt; 500;
</programlisting>
which returns:
@@ -89,8 +89,8 @@ SELECT c.name, c.altitude
<para>
On the other hand, the following query finds
- all the cities, but not capital cities
- that are situated at an attitude of 500ft or higher:
+ all the cities that are not state capitals and
+ are situated at an altitude of 500ft or higher:
<programlisting>
SELECT name, altitude
@@ -109,7 +109,7 @@ SELECT name, altitude
<para>
Here the <quote>ONLY</quote> before cities indicates that the query should
- be run over only cities and not classes below cities in the
+ be run over only the cities table, and not classes below cities in the
inheritance hierarchy. Many of the commands that we
have already discussed -- <command>SELECT</command>,
<command>UPDATE</command> and <command>DELETE</command> --
@@ -121,13 +121,18 @@ SELECT name, altitude
<para>
In previous versions of <productname>Postgres</productname>, the
default was not to get access to child tables. This was found to
- be error prone and is also in violation of SQL. Under the old
+ be error prone and is also in violation of SQL99. Under the old
syntax, to get the sub-classes you append "*" to the table name.
For example
<programlisting>
SELECT * from cities*;
</programlisting>
- To get the old behavior, the set configuration option
+ You can still explicitly specify scanning child tables by appending
+ "*", as well as explicitly specify not scanning child tables by
+ writing <quote>ONLY</quote>. But beginning in version 7.1, the default
+ behavior for an undecorated table name is to scan its child tables
+ too, whereas before the default was not to do so. To get the old
+ default behavior, set the configuration option
<literal>SQL_Inheritance</literal> to off, e.g.,
<programlisting>
SET SQL_Inheritance TO OFF;
diff --git a/doc/src/sgml/inherit.sgml b/doc/src/sgml/inherit.sgml
index bb0a4d9c7a6..37cd94c5862 100644
--- a/doc/src/sgml/inherit.sgml
+++ b/doc/src/sgml/inherit.sgml
@@ -1,5 +1,5 @@
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/Attic/inherit.sgml,v 1.11 2000/07/02 22:00:23 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/Attic/inherit.sgml,v 1.12 2001/01/05 06:34:15 tgl Exp $
-->
<chapter id="inherit">
@@ -17,9 +17,9 @@ CREATE TABLE cities (
altitude int -- (in ft)
);
-CREATE TABLE capitals UNDER cities (
+CREATE TABLE capitals (
state char(2)
-);
+) INHERITS (cities);
</programlisting>
In this case, an instance of capitals <firstterm>inherits</firstterm> all
@@ -43,15 +43,15 @@ CREATE TABLE capitals UNDER cities (
</para>
<para>
- For example, the following query finds the names of all cities,
- including state capitals, that are located at an altitude
- over 500ft, the query is:
+ For example, the following query finds the names of all cities,
+ including state capitals, that are located at an altitude
+ over 500ft:
- <programlisting>
- SELECT c.name, c.altitude
- FROM cities c
- WHERE c.altitude > 500;
-</programlisting>
+ <programlisting>
+SELECT name, altitude
+ FROM cities
+ WHERE altitude &gt; 500;
+ </programlisting>
which returns:
@@ -69,12 +69,12 @@ CREATE TABLE capitals UNDER cities (
</para>
<para>
- On the other hand, the following query finds
- all the cities, but not capital cities
- that are situated at an attitude of 500ft or higher:
+ On the other hand, the following query finds
+ all the cities that are not state capitals and
+ are situated at an altitude of 500ft or higher:
<programlisting>
- SELECT name, altitude
+SELECT name, altitude
FROM ONLY cities
WHERE altitude &gt; 500;
@@ -106,7 +106,7 @@ CREATE TABLE capitals UNDER cities (
<programlisting>
SELECT c.tableoid, c.name, c.altitude
FROM cities c
- WHERE c.altitude > 500;
+ WHERE c.altitude &gt; 500;
</programlisting>
which returns:
@@ -128,7 +128,7 @@ CREATE TABLE capitals UNDER cities (
<programlisting>
SELECT p.relname, c.name, c.altitude
FROM cities c, pg_class p
- WHERE c.altitude > 500 and c.tableoid = p.oid;
+ WHERE c.altitude &gt; 500 and c.tableoid = p.oid;
</programlisting>
which returns:
@@ -150,20 +150,25 @@ CREATE TABLE capitals UNDER cities (
<note>
<title>Deprecated</title>
<para>
- In previous versions of <productname>Postgres</productname>, the
- default was not to get access to child tables. This was found to
- be error prone and is also in violation of SQL. Under the old
- syntax, to get the sub-classes you append "*" to the table name.
- For example
+ In previous versions of <productname>Postgres</productname>, the
+ default was not to get access to child tables. This was found to
+ be error prone and is also in violation of SQL99. Under the old
+ syntax, to get the sub-classes you append "*" to the table name.
+ For example
<programlisting>
SELECT * from cities*;
</programlisting>
- To get the old behavior, the set configuration option
- <literal>SQL_Inheritance</literal> to off, e.g.,
+ You can still explicitly specify scanning child tables by appending
+ "*", as well as explicitly specify not scanning child tables by
+ writing <quote>ONLY</quote>. But beginning in version 7.1, the default
+ behavior for an undecorated table name is to scan its child tables
+ too, whereas before the default was not to do so. To get the old
+ default behavior, set the configuration option
+ <literal>SQL_Inheritance</literal> to off, e.g.,
<programlisting>
SET SQL_Inheritance TO OFF;
</programlisting>
- or add a line in your <filename>postgresql.conf</filename> file.
+ or add a line in your <filename>postgresql.conf</filename> file.
</para>
</note>
</chapter>
diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml
index 110b5204cfb..24513344d74 100644
--- a/doc/src/sgml/ref/alter_table.sgml
+++ b/doc/src/sgml/ref/alter_table.sgml
@@ -1,5 +1,5 @@
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.17 2000/12/25 23:15:26 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.18 2001/01/05 06:34:16 tgl Exp $
Postgres documentation
-->
@@ -23,10 +23,10 @@ Postgres documentation
<date>1999-07-20</date>
</refsynopsisdivinfo>
<synopsis>
-ALTER TABLE [ ONLY ]<replaceable class="PARAMETER">table</replaceable> [ * ]
+ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ * ]
ADD [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> <replaceable
class="PARAMETER">type</replaceable>
-ALTER TABLE [ ONLY ]<replaceable class="PARAMETER">table</replaceable> [ * ]
+ALTER TABLE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ * ]
ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> { SET DEFAULT <replaceable
class="PARAMETER">value</replaceable> | DROP DEFAULT }
ALTER TABLE <replaceable class="PARAMETER">table</replaceable> [ * ]
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index f4ac83f1b0d..fc0d98be250 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -1,5 +1,5 @@
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v 1.38 2000/12/30 19:00:11 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v 1.39 2001/01/05 06:34:16 tgl Exp $
Postgres documentation
-->
@@ -20,12 +20,10 @@ Postgres documentation
</refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
- <date>2000-03-25</date>
+ <date>2001-01-04</date>
</refsynopsisdivinfo>
<synopsis>
-CREATE [ TEMPORARY | TEMP ] TABLE <replaceable class="PARAMETER">table</replaceable>
- [ UNDER <replaceable>inherited_table</replaceable> [, ...] ]
- (
+CREATE [ TEMPORARY | TEMP ] TABLE <replaceable class="PARAMETER">table</replaceable> (
<replaceable class="PARAMETER">column</replaceable> <replaceable class="PARAMETER">type</replaceable>
[ NULL | NOT NULL ] [ UNIQUE ] [ DEFAULT <replaceable class="PARAMETER">value</replaceable> ]
[<replaceable>column_constraint_clause</replaceable> | PRIMARY KEY } [ ... ] ]
@@ -33,7 +31,7 @@ CREATE [ TEMPORARY | TEMP ] TABLE <replaceable class="PARAMETER">table</replacea
[, PRIMARY KEY ( <replaceable class="PARAMETER">column</replaceable> [, ...] ) ]
[, CHECK ( <replaceable class="PARAMETER">condition</replaceable> ) ]
[, <replaceable>table_constraint_clause</replaceable> ]
- )
+ ) [ INHERITS ( <replaceable>inherited_table</replaceable> [, ...] ) ]
</synopsis>
<refsect2 id="R2-SQL-CREATETABLE-1">
@@ -132,10 +130,10 @@ CREATE [ TEMPORARY | TEMP ] TABLE <replaceable class="PARAMETER">table</replacea
</varlistentry>
<varlistentry>
- <term>UNDER <replaceable class="PARAMETER">inherited_table</replaceable></term>
+ <term>INHERITS <replaceable class="PARAMETER">inherited_table</replaceable></term>
<listitem>
<para>
- The optional UNDER clause specifies a collection of 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,
<productname>Postgres</productname>
@@ -231,7 +229,7 @@ ERROR: DEFAULT: type mismatched
</para>
<para>
- The optional UNDER
+ 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
@@ -2154,6 +2152,19 @@ ALTER DOMAIN cities
</synopsis>
</para>
</refsect3>
+
+ <refsect3 id="R3-SQL-INHERITANCE-1">
+ <title>
+ Inheritance
+ </title>
+ <para>
+ Multiple inheritance via the INHERITS clause is a
+ <productname>Postgres</productname> language extension.
+ SQL99 (but not SQL92) defines single inheritance using a different
+ syntax and different semantics. SQL99-style inheritance is not yet
+ supported by <productname>Postgres</productname>.
+ </para>
+ </refsect3>
</refsect2>
</refsect1>
</refentry>