Commit 8c1d09d5 authored by Bruce Momjian's avatar Bruce Momjian

Inheritance overhaul by Chris Bitmead <chris@bitmead.com>

parent fb070464
...@@ -90,16 +90,14 @@ s ...@@ -90,16 +90,14 @@ s
M-x set-variable tab-width M-x set-variable tab-width
or or
; Cmd to set tab stops &etc for working with PostgreSQL code ; Cmd to set tab stops &etc for working with PostgreSQL code
(defun pgsql-mode () (c-add-style "pgsql"
"Set PostgreSQL C indenting conventions in current buffer." '("bsd"
(interactive) (indent-tabs-mode . t)
(c-mode) ; necessary to make c-set (c-basic-offset . 4)
-offset local! (tab-width . 4)
(setq tab-width 4) ; already buffer-local (c-offsets-alist .
; (setq comment-column 48) ; already buffer-local ((case-label . +))))
(c-set-style "bsd") t) ; t = set this mode on
(c-set-offset 'case-label '+)
)
and add this to your autoload list (modify file path in macro): and add this to your autoload list (modify file path in macro):
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.12 2000/05/02 20:01:51 thomas Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.13 2000/06/09 01:43:55 momjian Exp $
--> -->
<chapter id="advanced"> <chapter id="advanced">
...@@ -35,7 +35,7 @@ CREATE TABLE cities ( ...@@ -35,7 +35,7 @@ CREATE TABLE cities (
CREATE TABLE capitals ( CREATE TABLE capitals (
state char(2) state char(2)
) INHERITS (cities); ) UNDER cities;
</programlisting> </programlisting>
In this case, an instance of capitals <firstterm>inherits</firstterm> all In this case, an instance of capitals <firstterm>inherits</firstterm> all
...@@ -60,56 +60,72 @@ CREATE TABLE capitals ( ...@@ -60,56 +60,72 @@ CREATE TABLE capitals (
</para> </para>
</note> </note>
For example, the following query finds <para>
all the cities that are situated at an attitude of 500ft or higher: 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:
<programlisting> <programlisting>
SELECT name, altitude SELECT c.name, c.altitude
FROM cities FROM cities c
WHERE altitude &gt; 500; WHERE c.altitude > 500;
</programlisting>
which returns:
<programlisting>
+----------+----------+ +----------+----------+
|name | altitude | |name | altitude |
+----------+----------+ +----------+----------+
|Las Vegas | 2174 | |Las Vegas | 2174 |
+----------+----------+ +----------+----------+
|Mariposa | 1953 | |Mariposa | 1953 |
+----------+----------+
|Madison | 845 |
+----------+----------+ +----------+----------+
</programlisting> </programlisting>
</para> </para>
<para> <para>
On the other hand, to find the names of all cities, On the other hand, the following query finds
including state capitals, that are located at an altitude all the cities, but not capital cities
over 500ft, the query is: that are situated at an attitude of 500ft or higher:
<programlisting> <programlisting>
SELECT c.name, c.altitude SELECT name, altitude
FROM cities* c FROM ONLY cities
WHERE c.altitude > 500; WHERE altitude &gt; 500;
</programlisting>
which returns:
<programlisting>
+----------+----------+ +----------+----------+
|name | altitude | |name | altitude |
+----------+----------+ +----------+----------+
|Las Vegas | 2174 | |Las Vegas | 2174 |
+----------+----------+ +----------+----------+
|Mariposa | 1953 | |Mariposa | 1953 |
+----------+----------+
|Madison | 845 |
+----------+----------+ +----------+----------+
</programlisting> </programlisting>
</para>
Here the "*" after cities indicates that the query should
be run over cities and all classes below cities in the Here the <quote>ONLY</quote> before cities indicates that the query should
be run over only cities and not classes below cities in the
inheritance hierarchy. Many of the commands that we inheritance hierarchy. Many of the commands that we
have already discussed (<command>SELECT</command>, have already discussed -- <command>SELECT</command>,
<command>UPDATE</command> and <command>DELETE</command>) <command>UPDATE</command> and <command>DELETE</command> --
support this inheritance notation using "*" as do other commands like support this <quote>ONLY</quote> notation.
<command>ALTER</command>. </para>
<para>
Deprecated: In previous versions of postgres, the default was not to
get access to child classes. By experience this was found to be error
prone. Under the old syntax, to get the sub-classes you append "*"
to the table name. For example
<programlisting>
SELECT * from cities*;
</programlisting>
This old behaviour is still available by using a SET command...
<programlisting>
SET EXAMINE_SUBCLASS TO on;
</programlisting>
</para> </para>
</sect1> </sect1>
......
.\" This is -*-nroff-*- .\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here.... .\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.5 2000/02/17 03:39:39 tgl Exp $ .\" $Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.6 2000/06/09 01:43:56 momjian Exp $
.TH "SYSTEM CATALOGS" INTRO 03/13/94 PostgreSQL PostgreSQL .TH "SYSTEM CATALOGS" INTRO 03/13/94 PostgreSQL PostgreSQL
.SH "Section 7 - System Catalogs" .SH "Section 7 - System Catalogs"
.de LS .de LS
...@@ -191,6 +191,8 @@ pg_class ...@@ -191,6 +191,8 @@ pg_class
2=main memory */ 2=main memory */
int2vector relkey /* - unused */ int2vector relkey /* - unused */
oidvector relkeyop /* - unused */ oidvector relkeyop /* - unused */
bool relhassubclass /* does the class have a subclass?
*/
aclitem relacl[1] /* access control lists */ aclitem relacl[1] /* access control lists */
.fi .fi
.nf M .nf M
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/inherit.sgml,v 1.7 2000/05/02 20:01:51 thomas Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/inherit.sgml,v 1.8 2000/06/09 01:43:56 momjian Exp $
--> -->
<chapter id="inherit"> <chapter id="inherit">
...@@ -17,9 +17,9 @@ CREATE TABLE cities ( ...@@ -17,9 +17,9 @@ CREATE TABLE cities (
altitude int -- (in ft) altitude int -- (in ft)
); );
CREATE TABLE capitals ( CREATE TABLE capitals UNDER cities (
state char(2) state char(2)
) INHERITS (cities); );
</programlisting> </programlisting>
In this case, an instance of capitals <firstterm>inherits</firstterm> all In this case, an instance of capitals <firstterm>inherits</firstterm> all
...@@ -41,50 +41,71 @@ CREATE TABLE capitals ( ...@@ -41,50 +41,71 @@ CREATE TABLE capitals (
</para> </para>
</note> </note>
For example, the following query finds
all the cities that are situated at an attitude of 500ft or higher:
<programlisting>
SELECT name, altitude
FROM cities
WHERE altitude &gt; 500;
name | altitude
-----------+----------
Las Vegas | 2174
Mariposa | 1953
(2 rows)
</programlisting>
</para>
<para> <para>
On the other hand, to find the names of all cities, For example, the following query finds the names of all cities,
including state capitals, that are located at an altitude including state capitals, that are located at an altitude
over 500ft, the query is: over 500ft, the query is:
<programlisting> <programlisting>
SELECT c.name, c.altitude SELECT c.name, c.altitude
FROM cities* c FROM cities c
WHERE c.altitude > 500; WHERE c.altitude > 500;
</programlisting> </programlisting>
which returns: which returns:
<programlisting> <programlisting>
name | altitude +----------+----------+
-----------+---------- |name | altitude |
Las Vegas | 2174 +----------+----------+
Mariposa | 1953 |Las Vegas | 2174 |
Madison | 845 +----------+----------+
</programlisting> |Mariposa | 1953 |
+----------+----------+
|Madison | 845 |
+----------+----------+
</programlisting>
</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:
<programlisting>
SELECT name, altitude
FROM ONLY cities
WHERE altitude &gt; 500;
+----------+----------+
|name | altitude |
+----------+----------+
|Las Vegas | 2174 |
+----------+----------+
|Mariposa | 1953 |
+----------+----------+
</programlisting>
</para>
Here the "*" after cities indicates that the query should Here the <quote>ONLY</quote> before cities indicates that the query should
be run over cities and all classes below cities in the be run over only cities and not classes below cities in the
inheritance hierarchy. Many of the commands that we inheritance hierarchy. Many of the commands that we
have already discussed -- <command>SELECT</command>, have already discussed -- <command>SELECT</command>,
<command>UPDATE</command> and <command>DELETE</command> -- <command>UPDATE</command> and <command>DELETE</command> --
support this "*" notation, as do others, like support this <quote>ONLY</quote> notation.
<command>ALTER TABLE</command>. </para>
<para>
Deprecated: In previous versions of postgres, the default was not to
get access to child classes. By experience this was found to be error
prone. Under the old syntax, to get the sub-classes you append "*"
to the table name. For example
<programlisting>
SELECT * from cities*;
</programlisting>
This old behaviour is still available by using a SET command...
<programlisting>
SET EXAMINE_SUBCLASS TO on;
</programlisting>
</para> </para>
</chapter> </chapter>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.12 2000/04/11 14:43:54 momjian Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.13 2000/06/09 01:43:57 momjian Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -23,10 +23,10 @@ Postgres documentation ...@@ -23,10 +23,10 @@ Postgres documentation
<date>1999-07-20</date> <date>1999-07-20</date>
</refsynopsisdivinfo> </refsynopsisdivinfo>
<synopsis> <synopsis>
ALTER TABLE <replaceable class="PARAMETER">table</replaceable> [ * ] ALTER TABLE [ ONLY ]<replaceable class="PARAMETER">table</replaceable> [ * ]
ADD [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> <replaceable ADD [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> <replaceable
class="PARAMETER">type</replaceable> class="PARAMETER">type</replaceable>
ALTER TABLE <replaceable class="PARAMETER">table</replaceable> [ * ] ALTER TABLE [ ONLY ]<replaceable class="PARAMETER">table</replaceable> [ * ]
ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> { SET DEFAULT <replaceable ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> { SET DEFAULT <replaceable
class="PARAMETER">value</replaceable> | DROP DEFAULT } class="PARAMETER">value</replaceable> | DROP DEFAULT }
ALTER TABLE <replaceable class="PARAMETER">table</replaceable> [ * ] ALTER TABLE <replaceable class="PARAMETER">table</replaceable> [ * ]
...@@ -175,24 +175,6 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable> ...@@ -175,24 +175,6 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
The keyword <literal>COLUMN</literal> is noise and can be omitted. The keyword <literal>COLUMN</literal> is noise and can be omitted.
</para> </para>
<para>
<quote>*</quote> following a name of a table indicates that the statement
should be run over that table and all tables below it in the
inheritance hierarchy;
by default, the attribute will not be added to or renamed in any of the subclasses.
This should always be done when adding or modifying an attribute in a
superclass. If it is not, queries on the inheritance hierarchy
such as
<programlisting>
SELECT <replaceable>NewColumn</replaceable> FROM <replaceable>SuperClass</replaceable>*
</programlisting>
will not work because the subclasses will be missing an attribute
found in the superclass.
</para>
<para> <para>
In the current implementation, default and constraint clauses for the In the current implementation, default and constraint clauses for the
new column will be ignored. You can use the <literal>SET DEFAULT</literal> new column will be ignored. You can use the <literal>SET DEFAULT</literal>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v 1.29 2000/05/02 20:02:03 thomas Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v 1.30 2000/06/09 01:43:57 momjian Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -31,7 +31,7 @@ CREATE [ TEMPORARY | TEMP ] TABLE <replaceable class="PARAMETER">table</replacea ...@@ -31,7 +31,7 @@ CREATE [ TEMPORARY | TEMP ] TABLE <replaceable class="PARAMETER">table</replacea
[, PRIMARY KEY ( <replaceable class="PARAMETER">column</replaceable> [, ...] ) ] [, PRIMARY KEY ( <replaceable class="PARAMETER">column</replaceable> [, ...] ) ]
[, CHECK ( <replaceable class="PARAMETER">condition</replaceable> ) ] [, CHECK ( <replaceable class="PARAMETER">condition</replaceable> ) ]
[, <replaceable>table_constraint_clause</replaceable> ] [, <replaceable>table_constraint_clause</replaceable> ]
) [ INHERITS ( <replaceable>inherited_table</replaceable> [, ...] ) ] ) [ UNDER <replaceable>inherited_table</replaceable> [, ...] ]
</synopsis> </synopsis>
<refsect2 id="R2-SQL-CREATETABLE-1"> <refsect2 id="R2-SQL-CREATETABLE-1">
...@@ -130,10 +130,10 @@ CREATE [ TEMPORARY | TEMP ] TABLE <replaceable class="PARAMETER">table</replacea ...@@ -130,10 +130,10 @@ CREATE [ TEMPORARY | TEMP ] TABLE <replaceable class="PARAMETER">table</replacea
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>INHERITS <replaceable class="PARAMETER">inherited_table</replaceable></term> <term>UNDER <replaceable class="PARAMETER">inherited_table</replaceable></term>
<listitem> <listitem>
<para> <para>
The optional INHERITS clause specifies a collection of table The optional UNDER clause specifies a collection of table
names from which this table automatically inherits all fields. names from which this table automatically inherits all fields.
If any inherited field name appears more than once, If any inherited field name appears more than once,
<productname>Postgres</productname> <productname>Postgres</productname>
...@@ -229,7 +229,7 @@ ERROR: DEFAULT: type mismatched ...@@ -229,7 +229,7 @@ ERROR: DEFAULT: type mismatched
</para> </para>
<para> <para>
The optional INHERITS The optional UNDER
clause specifies a collection of class names from which this class clause specifies a collection of class names from which this class
automatically inherits all fields. If any inherited field name automatically inherits all fields. If any inherited field name
appears more than once, Postgres reports an error. Postgres automatically appears more than once, Postgres reports an error. Postgres automatically
...@@ -1838,8 +1838,8 @@ CREATE TABLE distributors ( ...@@ -1838,8 +1838,8 @@ CREATE TABLE distributors (
Notes Notes
</title> </title>
<para> <para>
CREATE TABLE/INHERITS is a <productname>Postgres</productname> CREATE TABLE/UNDER is defined by SQL3. Multiple inheritance is a
language extension. <productname>Postgres</productname> language extension.
</para> </para>
</refsect2> </refsect2>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/delete.sgml,v 1.10 2000/03/26 18:32:27 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/delete.sgml,v 1.11 2000/06/09 01:44:00 momjian Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -24,7 +24,7 @@ Postgres documentation ...@@ -24,7 +24,7 @@ Postgres documentation
<date>1999-07-20</date> <date>1999-07-20</date>
</refsynopsisdivinfo> </refsynopsisdivinfo>
<synopsis> <synopsis>
DELETE FROM <replaceable class="PARAMETER">table</replaceable> [ WHERE <replaceable class="PARAMETER">condition</replaceable> ] DELETE FROM [ ONLY ] <replaceable class="PARAMETER">table</replaceable> [ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
</synopsis> </synopsis>
<refsect2 id="R2-SQL-DELETE-1"> <refsect2 id="R2-SQL-DELETE-1">
...@@ -118,6 +118,12 @@ DELETE <replaceable class="parameter">count</replaceable> ...@@ -118,6 +118,12 @@ DELETE <replaceable class="parameter">count</replaceable>
</tip> </tip>
</para> </para>
<para>
By default DELETE will delete tuples in the table specified
and all its sub-classes. If you wish to only update the
specific table mentioned, you should use the ONLY clause.
</para>
<para> <para>
You must have write access to the table in order to modify You must have write access to the table in order to modify
it, as well as read access to any table whose values are it, as well as read access to any table whose values are
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/select.sgml,v 1.28 2000/03/27 17:14:43 thomas Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/select.sgml,v 1.29 2000/06/09 01:44:00 momjian Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -25,7 +25,7 @@ Postgres documentation ...@@ -25,7 +25,7 @@ Postgres documentation
SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replaceable> [, ...] ) ] ] SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replaceable> [, ...] ) ] ]
<replaceable class="PARAMETER">expression</replaceable> [ AS <replaceable class="PARAMETER">name</replaceable> ] [, ...] <replaceable class="PARAMETER">expression</replaceable> [ AS <replaceable class="PARAMETER">name</replaceable> ] [, ...]
[ INTO [ TEMPORARY | TEMP ] [ TABLE ] <replaceable class="PARAMETER">new_table</replaceable> ] [ INTO [ TEMPORARY | TEMP ] [ TABLE ] <replaceable class="PARAMETER">new_table</replaceable> ]
[ FROM <replaceable class="PARAMETER">table</replaceable> [ <replaceable class="PARAMETER">alias</replaceable> ] [, ...] ] [ FROM [ ONLY ]<replaceable class="PARAMETER">table</replaceable> [ <replaceable class="PARAMETER">alias</replaceable> ] [, ...] ]
[ WHERE <replaceable class="PARAMETER">condition</replaceable> ] [ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
[ GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...] ] [ GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...] ]
[ HAVING <replaceable class="PARAMETER">condition</replaceable> [, ...] ] [ HAVING <replaceable class="PARAMETER">condition</replaceable> [, ...] ]
...@@ -203,6 +203,13 @@ SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replac ...@@ -203,6 +203,13 @@ SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replac
if WHERE is omitted, all rows are candidates. if WHERE is omitted, all rows are candidates.
(See <xref linkend="sql-where" endterm="sql-where-title">.) (See <xref linkend="sql-where" endterm="sql-where-title">.)
</para> </para>
<para>
<command>ONLY</command> will eliminate rows from subclasses of the table.
This was previously the default result, and getting subclasses was
obtained by appending <command>*</command> to the table name.
The old behaviour is available via the command
<command>SET EXAMINE_SUBCLASS TO 'on';</command>
</para>
<para> <para>
<command>DISTINCT</command> will eliminate duplicate rows from the <command>DISTINCT</command> will eliminate duplicate rows from the
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/set.sgml,v 1.43 2000/05/18 14:24:33 momjian Exp $ <<<<<<< set.sgml
$Header: /cvsroot/pgsql/doc/src/sgml/ref/set.sgml,v 1.44 2000/06/09 01:44:00 momjian Exp $
=======
$Header: /cvsroot/pgsql/doc/src/sgml/ref/set.sgml,v 1.44 2000/06/09 01:44:00 momjian Exp $
>>>>>>> 1.43
Postgres documentation Postgres documentation
--> -->
...@@ -553,6 +557,39 @@ SELECT setseed(<replaceable>value</replaceable>); ...@@ -553,6 +557,39 @@ SELECT setseed(<replaceable>value</replaceable>);
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>EXAMINE_SUBCLASS</term>
<listitem>
<para>
Changes the behaviour of SELECT so that it no longer automatically
examines sub-classes. (See SELECT). By default a SELECT on a table
will also return subclass tuples unless specifying ONLY tablename.
Setting this returns postgres to the traditional behaviour of
only returning subclasses when appending "*" to the tablename.
<variablelist>
<varlistentry>
<term>ON</term>
<listitem>
<para>
Returns SELECT to the behaviour of automatically returning
results from sub-classes.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>OFF</term>
<listitem>
<para>
Prevents SELECT from returning sub-classes unless the "*" follows the table name
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term>ENABLE_SEQSCAN</term> <term>ENABLE_SEQSCAN</term>
<listitem> <listitem>
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/update.sgml,v 1.9 2000/04/11 05:39:15 thomas Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/update.sgml,v 1.10 2000/06/09 01:44:00 momjian Exp $
Postgres documentation Postgres documentation
--> -->
...@@ -23,7 +23,7 @@ Postgres documentation ...@@ -23,7 +23,7 @@ Postgres documentation
<date>1999-07-20</date> <date>1999-07-20</date>
</refsynopsisdivinfo> </refsynopsisdivinfo>
<synopsis> <synopsis>
UPDATE <replaceable class="PARAMETER">table</replaceable> SET <replaceable class="PARAMETER">col</replaceable> = <replaceable class="PARAMETER">expression</replaceable> [, ...] UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replaceable class="PARAMETER">col</replaceable> = <replaceable class="PARAMETER">expression</replaceable> [, ...]
[ FROM <replaceable class="PARAMETER">fromlist</replaceable> ] [ FROM <replaceable class="PARAMETER">fromlist</replaceable> ]
[ WHERE <replaceable class="PARAMETER">condition</replaceable> ] [ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
</synopsis> </synopsis>
...@@ -140,6 +140,12 @@ UPDATE <replaceable class="parameter">#</replaceable> ...@@ -140,6 +140,12 @@ UPDATE <replaceable class="parameter">#</replaceable>
it, as well as read access to any table whose values are it, as well as read access to any table whose values are
mentioned in the WHERE condition. mentioned in the WHERE condition.
</para> </para>
<para>
By default UPDATE will update tuples in the table specified
and all its sub-classes. If you wish to only update the
specific table mentioned, you should use the ONLY clause.
</para>
</refsect1> </refsect1>
<refsect1 id="R1-SQL-UPDATE-2"> <refsect1 id="R1-SQL-UPDATE-2">
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.20 2000/05/02 20:01:53 thomas Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.21 2000/06/09 01:43:56 momjian Exp $
--> -->
<chapter id="syntax"> <chapter id="syntax">
...@@ -854,9 +854,10 @@ sqrt(emp.salary) ...@@ -854,9 +854,10 @@ sqrt(emp.salary)
defines one or more instance variables to range over the class defines one or more instance variables to range over the class
indicated in <replaceable>class_reference</replaceable>. indicated in <replaceable>class_reference</replaceable>.
One can also request One can also request
the instance variable to range over all classes that are beneath the the instance variable to range over only the specific class
indicated class in the inheritance hierarchy by postpending the and not those that are beneath the
designator asterisk ("*"). indicated class in the inheritance hierarchy by specifying ONLY before
before the classname.
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
......
...@@ -8,7 +8,11 @@ ...@@ -8,7 +8,11 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.58 2000/05/30 00:49:43 momjian Exp $ <<<<<<< creatinh.c
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.59 2000/06/09 01:44:03 momjian Exp $
=======
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.59 2000/06/09 01:44:03 momjian Exp $
>>>>>>> 1.58
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -34,6 +38,9 @@ static bool checkAttrExists(const char *attributeName, ...@@ -34,6 +38,9 @@ static bool checkAttrExists(const char *attributeName,
const char *attributeType, List *schema); const char *attributeType, List *schema);
static List *MergeAttributes(List *schema, List *supers, List **supconstr); static List *MergeAttributes(List *schema, List *supers, List **supconstr);
static void StoreCatalogInheritance(Oid relationId, List *supers); static void StoreCatalogInheritance(Oid relationId, List *supers);
static void
setRelhassubclassInRelation(Oid relationId, bool relhassubclass);
/* ---------------------------------------------------------------- /* ----------------------------------------------------------------
* DefineRelation * DefineRelation
...@@ -326,6 +333,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr) ...@@ -326,6 +333,7 @@ MergeAttributes(List *schema, List *supers, List **supconstr)
TupleConstr *constr; TupleConstr *constr;
relation = heap_openr(name, AccessShareLock); relation = heap_openr(name, AccessShareLock);
setRelhassubclassInRelation(relation->rd_id, true);
tupleDesc = RelationGetDescr(relation); tupleDesc = RelationGetDescr(relation);
constr = tupleDesc->constr; constr = tupleDesc->constr;
...@@ -660,3 +668,39 @@ checkAttrExists(const char *attributeName, const char *attributeType, List *sche ...@@ -660,3 +668,39 @@ checkAttrExists(const char *attributeName, const char *attributeType, List *sche
} }
return false; return false;
} }
static void
setRelhassubclassInRelation(Oid relationId, bool relhassubclass)
{
Relation relationRelation;
HeapTuple tuple;
Relation idescs[Num_pg_class_indices];
/*
* Lock a relation given its Oid. Go to the RelationRelation (i.e.
* pg_relation), find the appropriate tuple, and add the specified
* lock to it.
*/
relationRelation = heap_openr(RelationRelationName, RowExclusiveLock);
tuple = SearchSysCacheTuple(RELOID,
ObjectIdGetDatum(relationId),
0, 0, 0)
;
Assert(HeapTupleIsValid(tuple));
((Form_pg_class) GETSTRUCT(tuple))->relhassubclass = relhassubclass;
heap_update(relationRelation, &tuple->t_self, tuple, NULL);
/* keep the catalog indices up to date */
CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs);
CatalogIndexInsert(idescs, Num_pg_class_indices, relationRelation, tuple
);
CatalogCloseIndices(Num_pg_class_indices, idescs);
heap_close(relationRelation, RowExclusiveLock);
}
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.35 2000/05/31 00:28:15 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.36 2000/06/09 01:44:03 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -49,7 +49,12 @@ static bool parse_XactIsoLevel(char *); ...@@ -49,7 +49,12 @@ static bool parse_XactIsoLevel(char *);
static bool parse_random_seed(char *); static bool parse_random_seed(char *);
static bool show_random_seed(void); static bool show_random_seed(void);
static bool reset_random_seed(void); static bool reset_random_seed(void);
static bool parse_examine_subclass(char *);
static bool show_examine_subclass(void);
static bool reset_examine_subclass(void);
#define examine_subclass_default true
bool examine_subclass = examine_subclass_default;
/* /*
* get_token * get_token
...@@ -164,6 +169,44 @@ get_token(char **tok, char **val, char *str) ...@@ -164,6 +169,44 @@ get_token(char **tok, char **val, char *str)
return str; return str;
} }
/*
*
* EXAMINE_SUBCLASS
*
*/
#define EXAMINE_SUBCLASS "EXAMINE_SUBCLASS"
static bool
parse_examine_subclass(char *value)
{
if (strcasecmp(value, "on") == 0)
examine_subclass = true;
else if (strcasecmp(value, "off") == 0)
examine_subclass = false;
else if (strcasecmp(value, "default") == 0)
examine_subclass = examine_subclass_default;
else
elog(ERROR, "Bad value for %s (%s)", EXAMINE_SUBCLASS, value);
return TRUE;
}
static bool
show_examine_subclass()
{
if (examine_subclass)
elog(NOTICE, "%s is ON", EXAMINE_SUBCLASS);
else
elog(NOTICE, "%s is OFF", EXAMINE_SUBCLASS);
return TRUE;
}
static bool
reset_examine_subclass(void)
{
examine_subclass = examine_subclass_default;
return TRUE;
}
/* /*
* DATE_STYLE * DATE_STYLE
...@@ -545,6 +588,8 @@ SetPGVariable(const char *name, const char *value) ...@@ -545,6 +588,8 @@ SetPGVariable(const char *name, const char *value)
#endif #endif
else if (strcasecmp(name, "random_seed")==0) else if (strcasecmp(name, "random_seed")==0)
parse_random_seed(pstrdup(value)); parse_random_seed(pstrdup(value));
else if (strcasecmp(name, "examine_subclass")==0)
parse_examine_subclass(pstrdup(value));
else else
SetConfigOption(name, value, superuser() ? PGC_SUSET : PGC_USERSET); SetConfigOption(name, value, superuser() ? PGC_SUSET : PGC_USERSET);
} }
...@@ -567,6 +612,8 @@ GetPGVariable(const char *name) ...@@ -567,6 +612,8 @@ GetPGVariable(const char *name)
#endif #endif
else if (strcasecmp(name, "random_seed")==0) else if (strcasecmp(name, "random_seed")==0)
show_random_seed(); show_random_seed();
else if (strcasecmp(name, "examine_subclass")==0)
show_examine_subclass();
else else
{ {
const char * val = GetConfigOption(name, superuser()); const char * val = GetConfigOption(name, superuser());
...@@ -574,7 +621,6 @@ GetPGVariable(const char *name) ...@@ -574,7 +621,6 @@ GetPGVariable(const char *name)
} }
} }
void void
ResetPGVariable(const char *name) ResetPGVariable(const char *name)
{ {
...@@ -592,6 +638,8 @@ ResetPGVariable(const char *name) ...@@ -592,6 +638,8 @@ ResetPGVariable(const char *name)
#endif #endif
else if (strcasecmp(name, "random_seed")==0) else if (strcasecmp(name, "random_seed")==0)
reset_random_seed(); reset_random_seed();
else if (strcasecmp(name, "examine_subclass")==0)
reset_examine_subclass();
else else
SetConfigOption(name, NULL, superuser() ? PGC_SUSET : PGC_USERSET); SetConfigOption(name, NULL, superuser() ? PGC_SUSET : PGC_USERSET);
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.30 2000/04/12 17:15:09 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.31 2000/06/09 01:44:09 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -268,7 +268,12 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent) ...@@ -268,7 +268,12 @@ ExecInitAppend(Append *node, EState *estate, Plan *parent)
resultList = lcons(rri, resultList); resultList = lcons(rri, resultList);
} }
appendstate->as_result_relation_info_list = resultList; /*
The as_result_relation_info_list must be in the same
order as the rtentry list otherwise update or delete on
inheritance hierarchies won't work.
*/
appendstate->as_result_relation_info_list = lreverse(resultList);
} }
/* ---------------- /* ----------------
* call ExecInitNode on each of the plans in our list * call ExecInitNode on each of the plans in our list
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.31 2000/04/12 17:15:16 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.32 2000/06/09 01:44:12 momjian Exp $
* *
* NOTES * NOTES
* XXX a few of the following functions are duplicated to handle * XXX a few of the following functions are duplicated to handle
...@@ -522,6 +522,21 @@ set_differencei(List *l1, List *l2) ...@@ -522,6 +522,21 @@ set_differencei(List *l1, List *l2)
return result; return result;
} }
/*
* Reverse a list, non-destructively
*/
List *
lreverse(List *l)
{
List *result = NIL;
List *i;
foreach(i, l)
{
result = lcons(lfirst(i), result);
}
return result;
}
/* /*
* Return t if two integer lists have no members in common. * Return t if two integer lists have no members in common.
*/ */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.80 2000/05/30 00:49:47 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.81 2000/06/09 01:44:14 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -106,6 +106,9 @@ planner(Query *parse) ...@@ -106,6 +106,9 @@ planner(Query *parse)
Plan * Plan *
subquery_planner(Query *parse, double tuple_fraction) subquery_planner(Query *parse, double tuple_fraction)
{ {
List *l;
List *rangetable = parse->rtable;
RangeTblEntry *rangeTblEntry;
/* /*
* A HAVING clause without aggregates is equivalent to a WHERE clause * A HAVING clause without aggregates is equivalent to a WHERE clause
...@@ -138,6 +141,18 @@ subquery_planner(Query *parse, double tuple_fraction) ...@@ -138,6 +141,18 @@ subquery_planner(Query *parse, double tuple_fraction)
parse->qual = eval_const_expressions(parse->qual); parse->qual = eval_const_expressions(parse->qual);
parse->havingQual = eval_const_expressions(parse->havingQual); parse->havingQual = eval_const_expressions(parse->havingQual);
/*
* If the query is going to look for subclasses, but no subclasses
* actually exist, then we can optimise away the union that would
* otherwise happen and thus save some time.
*/
foreach(l, rangetable)
{
rangeTblEntry = (RangeTblEntry *)lfirst(l);
if (rangeTblEntry->inh && !has_subclass(rangeTblEntry->relid))
rangeTblEntry->inh = FALSE;
}
/* /*
* Canonicalize the qual, and convert it to implicit-AND format. * Canonicalize the qual, and convert it to implicit-AND format.
* *
......
...@@ -9,7 +9,11 @@ ...@@ -9,7 +9,11 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.53 2000/05/30 04:24:48 tgl Exp $ <<<<<<< plancat.c
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.54 2000/06/09 01:44:16 momjian Exp $
=======
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.54 2000/06/09 01:44:16 momjian Exp $
>>>>>>> 1.53
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -278,6 +282,25 @@ find_inheritance_children(Oid inhparent) ...@@ -278,6 +282,25 @@ find_inheritance_children(Oid inhparent)
return list; return list;
} }
/*
* has_subclass -
* In the current implementation, has_subclass returns whether a
* particular class *might* have a subclass. It will not return the
* correct result if a class had a subclass which was later dropped.
* This is because relhassubclass in pg_class is not updated,
* possibly because of efficiency and/or concurrency concerns.
* Currently has_subclass is only used as an efficiency hack, so this
* is ok.
*/
bool has_subclass(Oid relationId)
{
HeapTuple tuple =
SearchSysCacheTuple(RELOID,
ObjectIdGetDatum(relationId),
0, 0, 0);
return ((Form_pg_class) GETSTRUCT(tuple))->relhassubclass;
}
#ifdef NOT_USED #ifdef NOT_USED
/* /*
* VersionGetParents * VersionGetParents
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: analyze.c,v 1.145 2000/05/30 00:49:50 momjian Exp $ * $Id: analyze.c,v 1.146 2000/06/09 01:44:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -270,7 +270,7 @@ transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt) ...@@ -270,7 +270,7 @@ transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt)
/* set up a range table */ /* set up a range table */
makeRangeTable(pstate, NULL); makeRangeTable(pstate, NULL);
setTargetTable(pstate, stmt->relname); setTargetTable(pstate, stmt->relname, stmt->inh);
qry->distinctClause = NIL; qry->distinctClause = NIL;
...@@ -368,7 +368,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt) ...@@ -368,7 +368,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
* (We didn't want it there until now since it shouldn't be visible in * (We didn't want it there until now since it shouldn't be visible in
* the SELECT part.) * the SELECT part.)
*/ */
setTargetTable(pstate, stmt->relname); setTargetTable(pstate, stmt->relname, FALSE);
/* now the range table will not change */ /* now the range table will not change */
qry->rtable = pstate->p_rtable; qry->rtable = pstate->p_rtable;
...@@ -1489,7 +1489,7 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt) ...@@ -1489,7 +1489,7 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
* do this with REPLACE in POSTQUEL so we keep the feature. * do this with REPLACE in POSTQUEL so we keep the feature.
*/ */
makeRangeTable(pstate, stmt->fromClause); makeRangeTable(pstate, stmt->fromClause);
setTargetTable(pstate, stmt->relname); setTargetTable(pstate, stmt->relname, stmt->inh);
qry->targetList = transformTargetList(pstate, stmt->targetList); qry->targetList = transformTargetList(pstate, stmt->targetList);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.169 2000/05/31 00:28:24 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.170 2000/06/09 01:44:18 momjian Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include "storage/lmgr.h" #include "storage/lmgr.h"
#include "utils/acl.h" #include "utils/acl.h"
#include "utils/numeric.h" #include "utils/numeric.h"
#include "commands/variable.h"
#ifdef MULTIBYTE #ifdef MULTIBYTE
#include "miscadmin.h" #include "miscadmin.h"
...@@ -170,7 +171,7 @@ static void doNegateFloat(Value *v); ...@@ -170,7 +171,7 @@ static void doNegateFloat(Value *v);
%type <list> stmtblock, stmtmulti, %type <list> stmtblock, stmtmulti,
result, OptTempTableName, relation_name_list, OptTableElementList, result, OptTempTableName, relation_name_list, OptTableElementList,
OptInherit, definition, opt_distinct, OptUnder, OptInherit, definition, opt_distinct,
opt_with, func_args, func_args_list, func_as, opt_with, func_args, func_args_list, func_as,
oper_argtypes, RuleActionList, RuleActionMulti, oper_argtypes, RuleActionList, RuleActionMulti,
opt_column_list, columnList, opt_va_list, va_list, opt_column_list, columnList, opt_va_list, va_list,
...@@ -207,7 +208,7 @@ static void doNegateFloat(Value *v); ...@@ -207,7 +208,7 @@ static void doNegateFloat(Value *v);
%type <list> substr_list, substr_from, substr_for, trim_list %type <list> substr_list, substr_from, substr_for, trim_list
%type <list> opt_interval %type <list> opt_interval
%type <boolean> opt_inh_star, opt_binary, opt_using, opt_instead, %type <boolean> opt_inh_star, opt_binary, opt_using, opt_instead, opt_only
opt_with_copy, index_opt_unique, opt_verbose, opt_analyze opt_with_copy, index_opt_unique, opt_verbose, opt_analyze
%type <boolean> opt_cursor %type <boolean> opt_cursor
...@@ -324,6 +325,7 @@ static void doNegateFloat(Value *v); ...@@ -324,6 +325,7 @@ static void doNegateFloat(Value *v);
PENDANT, PENDANT,
RESTRICT, RESTRICT,
TRIGGER, TRIGGER,
UNDER,
OFF OFF
/* Keywords (in SQL92 non-reserved words) */ /* Keywords (in SQL92 non-reserved words) */
...@@ -882,7 +884,7 @@ AlterTableStmt: ...@@ -882,7 +884,7 @@ AlterTableStmt:
AlterTableStmt *n = makeNode(AlterTableStmt); AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'A'; n->subtype = 'A';
n->relname = $3; n->relname = $3;
n->inh = $4; n->inh = $4 || examine_subclass;
n->def = $7; n->def = $7;
$$ = (Node *)n; $$ = (Node *)n;
} }
...@@ -892,7 +894,7 @@ AlterTableStmt: ...@@ -892,7 +894,7 @@ AlterTableStmt:
AlterTableStmt *n = makeNode(AlterTableStmt); AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'T'; n->subtype = 'T';
n->relname = $3; n->relname = $3;
n->inh = $4; n->inh = $4 || examine_subclass;
n->name = $7; n->name = $7;
n->def = $8; n->def = $8;
$$ = (Node *)n; $$ = (Node *)n;
...@@ -903,7 +905,7 @@ AlterTableStmt: ...@@ -903,7 +905,7 @@ AlterTableStmt:
AlterTableStmt *n = makeNode(AlterTableStmt); AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'D'; n->subtype = 'D';
n->relname = $3; n->relname = $3;
n->inh = $4; n->inh = $4 || examine_subclass;
n->name = $7; n->name = $7;
n->behavior = $8; n->behavior = $8;
$$ = (Node *)n; $$ = (Node *)n;
...@@ -914,7 +916,7 @@ AlterTableStmt: ...@@ -914,7 +916,7 @@ AlterTableStmt:
AlterTableStmt *n = makeNode(AlterTableStmt); AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'C'; n->subtype = 'C';
n->relname = $3; n->relname = $3;
n->inh = $4; n->inh = $4 || examine_subclass;
n->def = $6; n->def = $6;
$$ = (Node *)n; $$ = (Node *)n;
} }
...@@ -924,7 +926,7 @@ AlterTableStmt: ...@@ -924,7 +926,7 @@ AlterTableStmt:
AlterTableStmt *n = makeNode(AlterTableStmt); AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'X'; n->subtype = 'X';
n->relname = $3; n->relname = $3;
n->inh = $4; n->inh = $4 || examine_subclass;
n->name = $7; n->name = $7;
n->behavior = $8; n->behavior = $8;
$$ = (Node *)n; $$ = (Node *)n;
...@@ -1036,14 +1038,22 @@ copy_null: WITH NULL_P AS Sconst { $$ = $4; } ...@@ -1036,14 +1038,22 @@ copy_null: WITH NULL_P AS Sconst { $$ = $4; }
* *
*****************************************************************************/ *****************************************************************************/
CreateStmt: CREATE OptTemp TABLE relation_name '(' OptTableElementList ')' CreateStmt: CREATE OptTemp TABLE relation_name OptUnder '(' OptTableElementList ')' OptInherit
OptInherit
{ {
CreateStmt *n = makeNode(CreateStmt); CreateStmt *n = makeNode(CreateStmt);
n->istemp = $2; n->istemp = $2;
n->relname = $4; n->relname = $4;
n->tableElts = $6; n->tableElts = $7;
n->inhRelnames = $8; n->inhRelnames = nconc($5, $9);
/* if ($5 != NIL)
{
n->inhRelnames = $5;
}
else
{ */
/* INHERITS is deprecated */
/* n->inhRelnames = $9;
} */
n->constraints = NIL; n->constraints = NIL;
$$ = (Node *)n; $$ = (Node *)n;
} }
...@@ -1400,6 +1410,15 @@ key_reference: NO ACTION { $$ = FKCONSTR_ON_KEY_NOACTION; } ...@@ -1400,6 +1410,15 @@ key_reference: NO ACTION { $$ = FKCONSTR_ON_KEY_NOACTION; }
| SET DEFAULT { $$ = FKCONSTR_ON_KEY_SETDEFAULT; } | SET DEFAULT { $$ = FKCONSTR_ON_KEY_SETDEFAULT; }
; ;
OptUnder: UNDER relation_name_list { $$ = $2; }
| /*EMPTY*/ { $$ = NIL; }
;
opt_only: ONLY { $$ = FALSE; }
| /*EMPTY*/ { $$ = TRUE; }
;
/* INHERITS is Deprecated */
OptInherit: INHERITS '(' relation_name_list ')' { $$ = $3; } OptInherit: INHERITS '(' relation_name_list ')' { $$ = $3; }
| /*EMPTY*/ { $$ = NIL; } | /*EMPTY*/ { $$ = NIL; }
; ;
...@@ -1409,11 +1428,13 @@ OptInherit: INHERITS '(' relation_name_list ')' { $$ = $3; } ...@@ -1409,11 +1428,13 @@ OptInherit: INHERITS '(' relation_name_list ')' { $$ = $3; }
* SELECT ... INTO. * SELECT ... INTO.
*/ */
CreateAsStmt: CREATE OptTemp TABLE relation_name OptCreateAs AS SelectStmt CreateAsStmt: CREATE OptTemp TABLE relation_name OptUnder OptCreateAs AS SelectStmt
{ {
SelectStmt *n = (SelectStmt *)$7; SelectStmt *n = (SelectStmt *)$8;
if ($5 != NIL) if ($5 != NIL)
mapTargetColumns($5, n->targetList); yyerror("CREATE TABLE/AS SELECT does not support UNDER");
if ($6 != NIL)
mapTargetColumns($6, n->targetList);
if (n->into != NULL) if (n->into != NULL)
elog(ERROR,"CREATE TABLE/AS SELECT may not specify INTO"); elog(ERROR,"CREATE TABLE/AS SELECT may not specify INTO");
n->istemp = $2; n->istemp = $2;
...@@ -2536,11 +2557,12 @@ opt_force: FORCE { $$ = TRUE; } ...@@ -2536,11 +2557,12 @@ opt_force: FORCE { $$ = TRUE; }
*****************************************************************************/ *****************************************************************************/
RenameStmt: ALTER TABLE relation_name opt_inh_star RenameStmt: ALTER TABLE relation_name opt_inh_star
/* "*" deprecated */
RENAME opt_column opt_name TO name RENAME opt_column opt_name TO name
{ {
RenameStmt *n = makeNode(RenameStmt); RenameStmt *n = makeNode(RenameStmt);
n->relname = $3; n->relname = $3;
n->inh = $4; n->inh = $4 || examine_subclass;
n->column = $7; n->column = $7;
n->newname = $9; n->newname = $9;
$$ = (Node *)n; $$ = (Node *)n;
...@@ -3094,12 +3116,12 @@ columnElem: ColId opt_indirection ...@@ -3094,12 +3116,12 @@ columnElem: ColId opt_indirection
* *
*****************************************************************************/ *****************************************************************************/
DeleteStmt: DELETE FROM relation_name DeleteStmt: DELETE FROM opt_only relation_name where_clause
where_clause
{ {
DeleteStmt *n = makeNode(DeleteStmt); DeleteStmt *n = makeNode(DeleteStmt);
n->relname = $3; n->inh = $3;
n->whereClause = $4; n->relname = $4;
n->whereClause = $5;
$$ = (Node *)n; $$ = (Node *)n;
} }
; ;
...@@ -3136,16 +3158,17 @@ opt_lmode: SHARE { $$ = TRUE; } ...@@ -3136,16 +3158,17 @@ opt_lmode: SHARE { $$ = TRUE; }
* *
*****************************************************************************/ *****************************************************************************/
UpdateStmt: UPDATE relation_name UpdateStmt: UPDATE opt_only relation_name
SET update_target_list SET update_target_list
from_clause from_clause
where_clause where_clause
{ {
UpdateStmt *n = makeNode(UpdateStmt); UpdateStmt *n = makeNode(UpdateStmt);
n->relname = $2; n->inh = $2;
n->targetList = $4; n->relname = $3;
n->fromClause = $5; n->targetList = $5;
n->whereClause = $6; n->fromClause = $6;
n->whereClause = $7;
$$ = (Node *)n; $$ = (Node *)n;
} }
; ;
...@@ -3780,10 +3803,10 @@ where_clause: WHERE a_expr { $$ = $2; } ...@@ -3780,10 +3803,10 @@ where_clause: WHERE a_expr { $$ = $2; }
relation_expr: relation_name relation_expr: relation_name
{ {
/* normal relations */ /* default inheritance */
$$ = makeNode(RelExpr); $$ = makeNode(RelExpr);
$$->relname = $1; $$->relname = $1;
$$->inh = FALSE; $$->inh = examine_subclass;
} }
| relation_name '*' %prec '=' | relation_name '*' %prec '='
{ {
...@@ -3792,6 +3815,14 @@ relation_expr: relation_name ...@@ -3792,6 +3815,14 @@ relation_expr: relation_name
$$->relname = $1; $$->relname = $1;
$$->inh = TRUE; $$->inh = TRUE;
} }
| ONLY relation_name %prec '='
{
/* no inheritance */
$$ = makeNode(RelExpr);
$$->relname = $2;
$$->inh = FALSE;
}
;
opt_array_bounds: '[' ']' opt_array_bounds opt_array_bounds: '[' ']' opt_array_bounds
{ $$ = lcons(makeInteger(-1), $3); } { $$ = lcons(makeInteger(-1), $3); }
...@@ -5396,7 +5427,6 @@ TokenId: ABSOLUTE { $$ = "absolute"; } ...@@ -5396,7 +5427,6 @@ TokenId: ABSOLUTE { $$ = "absolute"; }
| NOTIFY { $$ = "notify"; } | NOTIFY { $$ = "notify"; }
| OF { $$ = "of"; } | OF { $$ = "of"; }
| OIDS { $$ = "oids"; } | OIDS { $$ = "oids"; }
| ONLY { $$ = "only"; }
| OPERATOR { $$ = "operator"; } | OPERATOR { $$ = "operator"; }
| OPTION { $$ = "option"; } | OPTION { $$ = "option"; }
| PARTIAL { $$ = "partial"; } | PARTIAL { $$ = "partial"; }
...@@ -5433,6 +5463,7 @@ TokenId: ABSOLUTE { $$ = "absolute"; } ...@@ -5433,6 +5463,7 @@ TokenId: ABSOLUTE { $$ = "absolute"; }
| TRIGGER { $$ = "trigger"; } | TRIGGER { $$ = "trigger"; }
| TRUNCATE { $$ = "truncate"; } | TRUNCATE { $$ = "truncate"; }
| TRUSTED { $$ = "trusted"; } | TRUSTED { $$ = "trusted"; }
| UNDER { $$ = "under"; }
| UNLISTEN { $$ = "unlisten"; } | UNLISTEN { $$ = "unlisten"; }
| UNTIL { $$ = "until"; } | UNTIL { $$ = "until"; }
| UPDATE { $$ = "update"; } | UPDATE { $$ = "update"; }
...@@ -5534,6 +5565,7 @@ ColLabel: ColId { $$ = $1; } ...@@ -5534,6 +5565,7 @@ ColLabel: ColId { $$ = $1; }
| OFF { $$ = "off"; } | OFF { $$ = "off"; }
| OFFSET { $$ = "offset"; } | OFFSET { $$ = "offset"; }
| ON { $$ = "on"; } | ON { $$ = "on"; }
| ONLY { $$ = "only"; }
| OR { $$ = "or"; } | OR { $$ = "or"; }
| ORDER { $$ = "order"; } | ORDER { $$ = "order"; }
| OUTER_P { $$ = "outer"; } | OUTER_P { $$ = "outer"; }
......
...@@ -8,7 +8,11 @@ ...@@ -8,7 +8,11 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.73 2000/05/31 00:28:24 petere Exp $ <<<<<<< keywords.c
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.74 2000/06/09 01:44:18 momjian Exp $
=======
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.74 2000/06/09 01:44:18 momjian Exp $
>>>>>>> 1.73
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -247,6 +251,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -247,6 +251,7 @@ static ScanKeyword ScanKeywords[] = {
{"truncate", TRUNCATE}, {"truncate", TRUNCATE},
{"trusted", TRUSTED}, {"trusted", TRUSTED},
{"type", TYPE_P}, {"type", TYPE_P},
{"under", UNDER},
{"union", UNION}, {"union", UNION},
{"unique", UNIQUE}, {"unique", UNIQUE},
{"unlisten", UNLISTEN}, {"unlisten", UNLISTEN},
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.63 2000/06/08 22:37:18 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.64 2000/06/09 01:44:18 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -72,7 +72,7 @@ makeRangeTable(ParseState *pstate, List *frmList) ...@@ -72,7 +72,7 @@ makeRangeTable(ParseState *pstate, List *frmList)
* there is no other use of any of its attributes. Tricky, eh? * there is no other use of any of its attributes. Tricky, eh?
*/ */
void void
setTargetTable(ParseState *pstate, char *relname) setTargetTable(ParseState *pstate, char *relname, bool inh)
{ {
RangeTblEntry *rte; RangeTblEntry *rte;
...@@ -80,7 +80,7 @@ setTargetTable(ParseState *pstate, char *relname) ...@@ -80,7 +80,7 @@ setTargetTable(ParseState *pstate, char *relname)
if (refnameRangeTablePosn(pstate, relname, NULL) == 0) if (refnameRangeTablePosn(pstate, relname, NULL) == 0)
rte = addRangeTableEntry(pstate, relname, rte = addRangeTableEntry(pstate, relname,
makeAttr(relname, NULL), makeAttr(relname, NULL),
FALSE, FALSE, FALSE); inh, FALSE, FALSE);
else else
rte = refnameRangeTableEntry(pstate, relname); rte = refnameRangeTableEntry(pstate, relname);
......
...@@ -9,7 +9,7 @@ CREATE \[ TEMPORARY | TEMP \] TABLE table ( ...@@ -9,7 +9,7 @@ CREATE \[ TEMPORARY | TEMP \] TABLE table (
\[, PRIMARY KEY ( column \[, ...\] ) \] \[, PRIMARY KEY ( column \[, ...\] ) \]
\[, CHECK ( condition ) \] \[, CHECK ( condition ) \]
\[, table_constraint_clause \] \[, table_constraint_clause \]
) \[ INHERITS ( inherited_table \[, ...\] ) \] ) \[ UNDER inherited_table \[, ...\] \]
" {code} " " {code} "
TEMPORARY TEMPORARY
The table is created only for this session, and is automatically dropped on session exit. Existing permanent tables with the same name are not visible while the temporary table exists. The table is created only for this session, and is automatically dropped on session exit. Existing permanent tables with the same name are not visible while the temporary table exists.
......
...@@ -11,7 +11,7 @@ Let's create two classes. The capitals class contains state capitals which are a ...@@ -11,7 +11,7 @@ Let's create two classes. The capitals class contains state capitals which are a
CREATE TABLE capitals ( CREATE TABLE capitals (
state char2 state char2
) INHERITS (cities); ) UNDER cities;
" {code} " " {code} "
In this case, an instance of capitals inherits all attributes (name, population, and altitude) from its parent, cities. The type of the attribute name is text, a native Postgres type for variable length ASCII strings. The type of the attribute population is float, a native Postgres type for double precision floating point numbers. State capitals have an extra attribute, state, that shows their state. In Postgres, a class can inherit from zero or more other classes, and a query can reference either all instances of a class or all instances of a class plus all of its descendants. In this case, an instance of capitals inherits all attributes (name, population, and altitude) from its parent, cities. The type of the attribute name is text, a native Postgres type for variable length ASCII strings. The type of the attribute population is float, a native Postgres type for double precision floating point numbers. State capitals have an extra attribute, state, that shows their state. In Postgres, a class can inherit from zero or more other classes, and a query can reference either all instances of a class or all instances of a class plus all of its descendants.
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_attribute.h,v 1.56 2000/05/28 17:56:16 tgl Exp $ * $Id: pg_attribute.h,v 1.57 2000/06/09 01:44:22 momjian Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * the genbki.sh script reads this file and generates .bki
...@@ -429,7 +429,8 @@ DATA(insert OID = 0 ( 1249 cmax 29 0 4 -6 0 -1 -1 t p f i f f)); ...@@ -429,7 +429,8 @@ DATA(insert OID = 0 ( 1249 cmax 29 0 4 -6 0 -1 -1 t p f i f f));
{ 1259, {"relrefs"}, 21, 0, 2, 16, 0, -1, -1, '\001', 'p', '\0', 's', '\0', '\0' }, \ { 1259, {"relrefs"}, 21, 0, 2, 16, 0, -1, -1, '\001', 'p', '\0', 's', '\0', '\0' }, \
{ 1259, {"relhaspkey"}, 16, 0, 1, 17, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ { 1259, {"relhaspkey"}, 16, 0, 1, 17, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \
{ 1259, {"relhasrules"}, 16, 0, 1, 18, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \ { 1259, {"relhasrules"}, 16, 0, 1, 18, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \
{ 1259, {"relacl"}, 1034, 0, -1, 19, 0, -1, -1, '\0', 'p', '\0', 'i', '\0', '\0' } { 1259, {"relhassubclass"},16, 0, 1, 19, 0, -1, -1, '\001', 'p', '\0', 'c', '\0', '\0' }, \
{ 1259, {"relacl"}, 1034, 0, -1, 20, 0, -1, -1, '\0', 'p', '\0', 'i', '\0', '\0' }
DATA(insert OID = 0 ( 1259 relname 19 0 NAMEDATALEN 1 0 -1 -1 f p f i f f)); DATA(insert OID = 0 ( 1259 relname 19 0 NAMEDATALEN 1 0 -1 -1 f p f i f f));
DATA(insert OID = 0 ( 1259 reltype 26 0 4 2 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1259 reltype 26 0 4 2 0 -1 -1 t p f i f f));
...@@ -449,7 +450,8 @@ DATA(insert OID = 0 ( 1259 relfkeys 21 0 2 15 0 -1 -1 t p f s f f)); ...@@ -449,7 +450,8 @@ DATA(insert OID = 0 ( 1259 relfkeys 21 0 2 15 0 -1 -1 t p f s f f));
DATA(insert OID = 0 ( 1259 relrefs 21 0 2 16 0 -1 -1 t p f s f f)); DATA(insert OID = 0 ( 1259 relrefs 21 0 2 16 0 -1 -1 t p f s f f));
DATA(insert OID = 0 ( 1259 relhaspkey 16 0 1 17 0 -1 -1 t p f c f f)); DATA(insert OID = 0 ( 1259 relhaspkey 16 0 1 17 0 -1 -1 t p f c f f));
DATA(insert OID = 0 ( 1259 relhasrules 16 0 1 18 0 -1 -1 t p f c f f)); DATA(insert OID = 0 ( 1259 relhasrules 16 0 1 18 0 -1 -1 t p f c f f));
DATA(insert OID = 0 ( 1259 relacl 1034 0 -1 19 0 -1 -1 f p f i f f)); DATA(insert OID = 0 ( 1259 relhassubclass 16 0 1 19 0 -1 -1 t p f c f f));
DATA(insert OID = 0 ( 1259 relacl 1034 0 -1 20 0 -1 -1 f p f i f f));
DATA(insert OID = 0 ( 1259 ctid 27 0 6 -1 0 -1 -1 f p f i f f)); DATA(insert OID = 0 ( 1259 ctid 27 0 6 -1 0 -1 -1 f p f i f f));
DATA(insert OID = 0 ( 1259 oid 26 0 4 -2 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1259 oid 26 0 4 -2 0 -1 -1 t p f i f f));
DATA(insert OID = 0 ( 1259 xmin 28 0 4 -3 0 -1 -1 t p f i f f)); DATA(insert OID = 0 ( 1259 xmin 28 0 4 -3 0 -1 -1 t p f i f f));
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_class.h,v 1.34 2000/05/28 17:56:16 tgl Exp $ * $Id: pg_class.h,v 1.35 2000/06/09 01:44:23 momjian Exp $
* *
* NOTES * NOTES
* ``pg_relation'' is being replaced by ``pg_class''. currently * ``pg_relation'' is being replaced by ``pg_class''. currently
...@@ -78,11 +78,12 @@ CATALOG(pg_class) BOOTSTRAP ...@@ -78,11 +78,12 @@ CATALOG(pg_class) BOOTSTRAP
int2 relrefs; /* # of references to this relation */ int2 relrefs; /* # of references to this relation */
bool relhaspkey; /* has PRIMARY KEY */ bool relhaspkey; /* has PRIMARY KEY */
bool relhasrules; bool relhasrules;
bool relhassubclass;
aclitem relacl[1]; /* this is here for the catalog */ aclitem relacl[1]; /* this is here for the catalog */
} FormData_pg_class; } FormData_pg_class;
#define CLASS_TUPLE_SIZE \ #define CLASS_TUPLE_SIZE \
(offsetof(FormData_pg_class,relhasrules) + sizeof(bool)) (offsetof(FormData_pg_class,relhassubclass) + sizeof(bool))
/* ---------------- /* ----------------
* Form_pg_class corresponds to a pointer to a tuple with * Form_pg_class corresponds to a pointer to a tuple with
...@@ -102,8 +103,8 @@ typedef FormData_pg_class *Form_pg_class; ...@@ -102,8 +103,8 @@ typedef FormData_pg_class *Form_pg_class;
* relacl field. * relacl field.
* ---------------- * ----------------
*/ */
#define Natts_pg_class_fixed 18 #define Natts_pg_class_fixed 19
#define Natts_pg_class 19 #define Natts_pg_class 20
#define Anum_pg_class_relname 1 #define Anum_pg_class_relname 1
#define Anum_pg_class_reltype 2 #define Anum_pg_class_reltype 2
#define Anum_pg_class_relowner 3 #define Anum_pg_class_relowner 3
...@@ -122,38 +123,39 @@ typedef FormData_pg_class *Form_pg_class; ...@@ -122,38 +123,39 @@ typedef FormData_pg_class *Form_pg_class;
#define Anum_pg_class_relrefs 16 #define Anum_pg_class_relrefs 16
#define Anum_pg_class_relhaspkey 17 #define Anum_pg_class_relhaspkey 17
#define Anum_pg_class_relhasrules 18 #define Anum_pg_class_relhasrules 18
#define Anum_pg_class_relacl 19 #define Anum_pg_class_relhassubclass 19
#define Anum_pg_class_relacl 20
/* ---------------- /* ----------------
* initial contents of pg_class * initial contents of pg_class
* ---------------- * ----------------
*/ */
DATA(insert OID = 1247 ( pg_type 71 PGUID 0 0 0 0 f f r 16 0 0 0 0 0 f f _null_ )); DATA(insert OID = 1247 ( pg_type 71 PGUID 0 0 0 0 f f r 16 0 0 0 0 0 f f f _null_ ));
DESCR(""); DESCR("");
DATA(insert OID = 1249 ( pg_attribute 75 PGUID 0 0 0 0 f f r 15 0 0 0 0 0 f f _null_ )); DATA(insert OID = 1249 ( pg_attribute 75 PGUID 0 0 0 0 f f r 15 0 0 0 0 0 f f f _null_ ));
DESCR(""); DESCR("");
DATA(insert OID = 1255 ( pg_proc 81 PGUID 0 0 0 0 f f r 17 0 0 0 0 0 f f _null_ )); DATA(insert OID = 1255 ( pg_proc 81 PGUID 0 0 0 0 f f r 17 0 0 0 0 0 f f f _null_ ));
DESCR(""); DESCR("");
DATA(insert OID = 1259 ( pg_class 83 PGUID 0 0 0 0 f f r 19 0 0 0 0 0 f f _null_ )); DATA(insert OID = 1259 ( pg_class 83 PGUID 0 0 0 0 f f r 20 0 0 0 0 0 f f f _null_ ));
DESCR(""); DESCR("");
DATA(insert OID = 1260 ( pg_shadow 86 PGUID 0 0 0 0 f t r 8 0 0 0 0 0 f f _null_ )); DATA(insert OID = 1260 ( pg_shadow 86 PGUID 0 0 0 0 f t r 8 0 0 0 0 0 f f f _null_ ));
DESCR(""); DESCR("");
DATA(insert OID = 1261 ( pg_group 87 PGUID 0 0 0 0 f t r 3 0 0 0 0 0 f f _null_ )); DATA(insert OID = 1261 ( pg_group 87 PGUID 0 0 0 0 f t r 3 0 0 0 0 0 f f f _null_ ));
DESCR(""); DESCR("");
DATA(insert OID = 1262 ( pg_database 88 PGUID 0 0 0 0 f t r 4 0 0 0 0 0 f f _null_ )); DATA(insert OID = 1262 ( pg_database 88 PGUID 0 0 0 0 f t r 4 0 0 0 0 0 f f f _null_ ));
DESCR(""); DESCR("");
DATA(insert OID = 1264 ( pg_variable 90 PGUID 0 0 0 0 f t s 1 0 0 0 0 0 f f _null_ )); DATA(insert OID = 1264 ( pg_variable 90 PGUID 0 0 0 0 f t s 1 0 0 0 0 0 f f f _null_ ));
DESCR(""); DESCR("");
DATA(insert OID = 1269 ( pg_log 99 PGUID 0 0 0 0 f t s 1 0 0 0 0 0 f f _null_ )); DATA(insert OID = 1269 ( pg_log 99 PGUID 0 0 0 0 f t s 1 0 0 0 0 0 f f f _null_ ));
DESCR(""); DESCR("");
DATA(insert OID = 376 ( pg_xactlock 0 PGUID 0 0 0 0 f t s 1 0 0 0 0 0 f f _null_ )); DATA(insert OID = 376 ( pg_xactlock 0 PGUID 0 0 0 0 f t s 1 0 0 0 0 0 f f f _null_ ));
DESCR(""); DESCR("");
DATA(insert OID = 1215 ( pg_attrdef 109 PGUID 0 0 0 0 t t r 4 0 0 0 0 0 f f _null_ )); DATA(insert OID = 1215 ( pg_attrdef 109 PGUID 0 0 0 0 t t r 4 0 0 0 0 0 f f f _null_ ));
DESCR(""); DESCR("");
DATA(insert OID = 1216 ( pg_relcheck 110 PGUID 0 0 0 0 t t r 4 0 0 0 0 0 f f _null_ )); DATA(insert OID = 1216 ( pg_relcheck 110 PGUID 0 0 0 0 t t r 4 0 0 0 0 0 f f f _null_ ));
DESCR(""); DESCR("");
DATA(insert OID = 1219 ( pg_trigger 111 PGUID 0 0 0 0 t t r 13 0 0 0 0 0 f f _null_ )); DATA(insert OID = 1219 ( pg_trigger 111 PGUID 0 0 0 0 t t r 13 0 0 0 0 0 f f f _null_ ));
DESCR(""); DESCR("");
#define RelOid_pg_type 1247 #define RelOid_pg_type 1247
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Headers for handling of 'SET var TO', 'SHOW var' and 'RESET var' * Headers for handling of 'SET var TO', 'SHOW var' and 'RESET var'
* statements * statements
* *
* $Id: variable.h,v 1.10 2000/05/31 00:28:37 petere Exp $ * $Id: variable.h,v 1.11 2000/06/09 01:44:24 momjian Exp $
* *
*/ */
#ifndef VARIABLE_H #ifndef VARIABLE_H
...@@ -13,5 +13,6 @@ extern void GetPGVariable(const char *name); ...@@ -13,5 +13,6 @@ extern void GetPGVariable(const char *name);
extern void ResetPGVariable(const char *name); extern void ResetPGVariable(const char *name);
extern void set_default_datestyle(void); extern void set_default_datestyle(void);
extern bool examine_subclass;
#endif /* VARIABLE_H */ #endif /* VARIABLE_H */
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: parsenodes.h,v 1.105 2000/05/28 20:34:49 tgl Exp $ * $Id: parsenodes.h,v 1.106 2000/06/09 01:44:26 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -795,6 +795,7 @@ typedef struct DeleteStmt ...@@ -795,6 +795,7 @@ typedef struct DeleteStmt
NodeTag type; NodeTag type;
char *relname; /* relation to delete from */ char *relname; /* relation to delete from */
Node *whereClause; /* qualifications */ Node *whereClause; /* qualifications */
bool inh; /* delete from subclasses */
} DeleteStmt; } DeleteStmt;
/* ---------------------- /* ----------------------
...@@ -808,6 +809,7 @@ typedef struct UpdateStmt ...@@ -808,6 +809,7 @@ typedef struct UpdateStmt
List *targetList; /* the target list (of ResTarget) */ List *targetList; /* the target list (of ResTarget) */
Node *whereClause; /* qualifications */ Node *whereClause; /* qualifications */
List *fromClause; /* the from clause */ List *fromClause; /* the from clause */
bool inh; /* update subclasses */
} UpdateStmt; } UpdateStmt;
/* ---------------------- /* ----------------------
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: pg_list.h,v 1.17 2000/04/12 17:16:40 momjian Exp $ * $Id: pg_list.h,v 1.18 2000/06/09 01:44:26 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -118,6 +118,7 @@ extern void set_nth(List *l, int n, void *elem); ...@@ -118,6 +118,7 @@ extern void set_nth(List *l, int n, void *elem);
extern List *set_difference(List *list1, List *list2); extern List *set_difference(List *list1, List *list2);
extern List *set_differencei(List *list1, List *list2); extern List *set_differencei(List *list1, List *list2);
extern List *lreverse(List *l);
extern List *LispUnion(List *list1, List *list2); extern List *LispUnion(List *list1, List *list2);
extern List *LispUnioni(List *list1, List *list2); extern List *LispUnioni(List *list1, List *list2);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: parse_clause.h,v 1.17 2000/04/12 17:16:45 momjian Exp $ * $Id: parse_clause.h,v 1.18 2000/06/09 01:44:29 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "parser/parse_node.h" #include "parser/parse_node.h"
extern void makeRangeTable(ParseState *pstate, List *frmList); extern void makeRangeTable(ParseState *pstate, List *frmList);
extern void setTargetTable(ParseState *pstate, char *relname); extern void setTargetTable(ParseState *pstate, char *relname, bool inh);
extern Node *transformWhereClause(ParseState *pstate, Node *where); extern Node *transformWhereClause(ParseState *pstate, Node *where);
extern List *transformGroupClause(ParseState *pstate, List *grouplist, extern List *transformGroupClause(ParseState *pstate, List *grouplist,
List *targetlist); List *targetlist);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.26 2000/04/08 12:20:27 meskes Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.27 2000/06/09 01:44:31 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -246,6 +246,7 @@ static ScanKeyword ScanKeywords[] = { ...@@ -246,6 +246,7 @@ static ScanKeyword ScanKeywords[] = {
{"truncate", TRUNCATE}, {"truncate", TRUNCATE},
{"trusted", TRUSTED}, {"trusted", TRUSTED},
{"type", TYPE_P}, {"type", TYPE_P},
{"under", UNDER},
{"union", UNION}, {"union", UNION},
{"unique", UNIQUE}, {"unique", UNIQUE},
{"unlisten", UNLISTEN}, {"unlisten", UNLISTEN},
......
...@@ -236,7 +236,7 @@ make_name(void) ...@@ -236,7 +236,7 @@ make_name(void)
REINDEX, RENAME, RESET, RETURNS, ROW, RULE, REINDEX, RENAME, RESET, RETURNS, ROW, RULE,
SEQUENCE, SERIAL, SETOF, SHARE, SHOW, START, STATEMENT, STDIN, STDOUT, SYSID SEQUENCE, SERIAL, SETOF, SHARE, SHOW, START, STATEMENT, STDIN, STDOUT, SYSID
TEMP, TRUNCATE, TRUSTED, TEMP, TRUNCATE, TRUSTED,
UNLISTEN, UNTIL, VACUUM, VALID, VERBOSE, VERSION UNDER, UNLISTEN, UNTIL, VACUUM, VALID, VERBOSE, VERSION
/* Special keywords, not in the query language - see the "lex" file */ /* Special keywords, not in the query language - see the "lex" file */
%token <str> IDENT SCONST Op CSTRING CVARIABLE CPP_LINE %token <str> IDENT SCONST Op CSTRING CVARIABLE CPP_LINE
...@@ -276,7 +276,7 @@ make_name(void) ...@@ -276,7 +276,7 @@ make_name(void)
%type <str> Iconst Fconst Sconst TransactionStmt CreateStmt UserId %type <str> Iconst Fconst Sconst TransactionStmt CreateStmt UserId
%type <str> CreateAsElement OptCreateAs CreateAsList CreateAsStmt %type <str> CreateAsElement OptCreateAs CreateAsList CreateAsStmt
%type <str> OptInherit key_reference comment_text ConstraintDeferrabilitySpec %type <str> OptUnder key_reference comment_text ConstraintDeferrabilitySpec
%type <str> key_match ColLabel SpecialRuleRelation ColId columnDef %type <str> key_match ColLabel SpecialRuleRelation ColId columnDef
%type <str> ColConstraint ColConstraintElem NumericOnly FloatOnly %type <str> ColConstraint ColConstraintElem NumericOnly FloatOnly
%type <str> OptTableElementList OptTableElement TableConstraint %type <str> OptTableElementList OptTableElement TableConstraint
...@@ -995,7 +995,7 @@ copy_null: WITH NULL_P AS Sconst { $$ = cat2_str(make_str("with null as"), $4); ...@@ -995,7 +995,7 @@ copy_null: WITH NULL_P AS Sconst { $$ = cat2_str(make_str("with null as"), $4);
*****************************************************************************/ *****************************************************************************/
CreateStmt: CREATE OptTemp TABLE relation_name '(' OptTableElementList ')' CreateStmt: CREATE OptTemp TABLE relation_name '(' OptTableElementList ')'
OptInherit OptUnder
{ {
$$ = cat_str(8, make_str("create"), $2, make_str("table"), $4, make_str("("), $6, make_str(")"), $8); $$ = cat_str(8, make_str("create"), $2, make_str("table"), $4, make_str("("), $6, make_str(")"), $8);
} }
...@@ -1192,7 +1192,8 @@ key_reference: NO ACTION { $$ = make_str("no action"); } ...@@ -1192,7 +1192,8 @@ key_reference: NO ACTION { $$ = make_str("no action"); }
| SET NULL_P { $$ = make_str("set null"); } | SET NULL_P { $$ = make_str("set null"); }
; ;
OptInherit: INHERITS '(' relation_name_list ')' { $$ = cat_str(3, make_str("inherits ("), $3, make_str(")")); } OptUnder: UNDER relation_name_list { $$ = cat_str(2, make_str("under "), $2); }
| INHERITS '(' relation_name_list ')' { $$ = cat_str(3, make_str("inherits ("), $3, make_str(")")); }
| /*EMPTY*/ { $$ = EMPTY; } | /*EMPTY*/ { $$ = EMPTY; }
; ;
...@@ -2877,6 +2878,11 @@ relation_expr: relation_name ...@@ -2877,6 +2878,11 @@ relation_expr: relation_name
/* inheritance query */ /* inheritance query */
$$ = cat2_str($1, make_str("*")); $$ = cat2_str($1, make_str("*"));
} }
| ONLY relation_name %prec '='
{
/* inheritance query */
$$ = cat2_str(make_str("ONLY "), $2);
}
opt_array_bounds: '[' ']' opt_array_bounds opt_array_bounds: '[' ']' opt_array_bounds
{ {
...@@ -5081,6 +5087,7 @@ TokenId: ABSOLUTE { $$ = make_str("absolute"); } ...@@ -5081,6 +5087,7 @@ TokenId: ABSOLUTE { $$ = make_str("absolute"); }
| TRIGGER { $$ = make_str("trigger"); } | TRIGGER { $$ = make_str("trigger"); }
| TRUNCATE { $$ = make_str("truncate"); } | TRUNCATE { $$ = make_str("truncate"); }
| TRUSTED { $$ = make_str("trusted"); } | TRUSTED { $$ = make_str("trusted"); }
| UNDER { $$ = make_str("under"); }
| UNLISTEN { $$ = make_str("unlisten"); } | UNLISTEN { $$ = make_str("unlisten"); }
| UNTIL { $$ = make_str("until"); } | UNTIL { $$ = make_str("until"); }
| UPDATE { $$ = make_str("update"); } | UPDATE { $$ = make_str("update"); }
......
...@@ -70,6 +70,7 @@ parallel group3 ...@@ -70,6 +70,7 @@ parallel group3
test create_aggregate test create_aggregate
test create_operator test create_operator
test create_index test create_index
test inherit
endparallel endparallel
test create_view # Depends on the above test create_view # Depends on the above
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment