mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
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.
This commit is contained in:
@ -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 > 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;
|
||||
|
Reference in New Issue
Block a user