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:
parent
e62c38d0fc
commit
2fb6cc9045
@ -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;
|
||||
|
@ -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 > 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 > 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 > 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 > 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>
|
||||
|
@ -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> [ * ]
|
||||
|
@ -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>
|
||||
|
@ -15,7 +15,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.135 2000/12/14 22:30:42 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.136 2001/01/05 06:34:17 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1675,7 +1675,7 @@ _copyRangeVar(RangeVar *from)
|
||||
|
||||
if (from->relname)
|
||||
newnode->relname = pstrdup(from->relname);
|
||||
newnode->inh = from->inh;
|
||||
newnode->inhOpt = from->inhOpt;
|
||||
Node_Copy(from, newnode, name);
|
||||
|
||||
return newnode;
|
||||
@ -1829,7 +1829,7 @@ _copyDeleteStmt(DeleteStmt *from)
|
||||
if (from->relname)
|
||||
newnode->relname = pstrdup(from->relname);
|
||||
Node_Copy(from, newnode, whereClause);
|
||||
newnode->inh = from->inh;
|
||||
newnode->inhOpt = from->inhOpt;
|
||||
|
||||
return newnode;
|
||||
}
|
||||
@ -1844,7 +1844,7 @@ _copyUpdateStmt(UpdateStmt *from)
|
||||
Node_Copy(from, newnode, targetList);
|
||||
Node_Copy(from, newnode, whereClause);
|
||||
Node_Copy(from, newnode, fromClause);
|
||||
newnode->inh = from->inh;
|
||||
newnode->inhOpt = from->inhOpt;
|
||||
|
||||
return newnode;
|
||||
}
|
||||
@ -1900,7 +1900,7 @@ _copyAlterTableStmt(AlterTableStmt *from)
|
||||
newnode->subtype = from->subtype;
|
||||
if (from->relname)
|
||||
newnode->relname = pstrdup(from->relname);
|
||||
newnode->inh = from->inh;
|
||||
newnode->inhOpt = from->inhOpt;
|
||||
if (from->name)
|
||||
newnode->name = pstrdup(from->name);
|
||||
Node_Copy(from, newnode, def);
|
||||
@ -2137,7 +2137,7 @@ _copyRenameStmt(RenameStmt *from)
|
||||
RenameStmt *newnode = makeNode(RenameStmt);
|
||||
|
||||
newnode->relname = pstrdup(from->relname);
|
||||
newnode->inh = from->inh;
|
||||
newnode->inhOpt = from->inhOpt;
|
||||
if (from->column)
|
||||
newnode->column = pstrdup(from->column);
|
||||
if (from->newname)
|
||||
|
@ -20,7 +20,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.85 2000/12/14 22:30:42 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.86 2001/01/05 06:34:17 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -651,7 +651,7 @@ _equalDeleteStmt(DeleteStmt *a, DeleteStmt *b)
|
||||
return false;
|
||||
if (!equal(a->whereClause, b->whereClause))
|
||||
return false;
|
||||
if (a->inh != b->inh)
|
||||
if (a->inhOpt != b->inhOpt)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -668,7 +668,7 @@ _equalUpdateStmt(UpdateStmt *a, UpdateStmt *b)
|
||||
return false;
|
||||
if (!equal(a->fromClause, b->fromClause))
|
||||
return false;
|
||||
if (a->inh != b->inh)
|
||||
if (a->inhOpt != b->inhOpt)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -741,7 +741,7 @@ _equalAlterTableStmt(AlterTableStmt *a, AlterTableStmt *b)
|
||||
return false;
|
||||
if (!equalstr(a->relname, b->relname))
|
||||
return false;
|
||||
if (a->inh != b->inh)
|
||||
if (a->inhOpt != b->inhOpt)
|
||||
return false;
|
||||
if (!equalstr(a->name, b->name))
|
||||
return false;
|
||||
@ -998,7 +998,7 @@ _equalRenameStmt(RenameStmt *a, RenameStmt *b)
|
||||
{
|
||||
if (!equalstr(a->relname, b->relname))
|
||||
return false;
|
||||
if (a->inh != b->inh)
|
||||
if (a->inhOpt != b->inhOpt)
|
||||
return false;
|
||||
if (!equalstr(a->column, b->column))
|
||||
return false;
|
||||
@ -1501,7 +1501,7 @@ _equalRangeVar(RangeVar *a, RangeVar *b)
|
||||
{
|
||||
if (!equalstr(a->relname, b->relname))
|
||||
return false;
|
||||
if (a->inh != b->inh)
|
||||
if (a->inhOpt != b->inhOpt)
|
||||
return false;
|
||||
if (!equal(a->name, b->name))
|
||||
return false;
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: analyze.c,v 1.173 2000/12/18 01:37:56 tgl Exp $
|
||||
* $Id: analyze.c,v 1.174 2001/01/05 06:34:18 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -260,7 +260,8 @@ transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt)
|
||||
/* set up a range table */
|
||||
lockTargetTable(pstate, stmt->relname);
|
||||
makeRangeTable(pstate, NIL);
|
||||
setTargetTable(pstate, stmt->relname, stmt->inh, true);
|
||||
setTargetTable(pstate, stmt->relname,
|
||||
interpretInhOption(stmt->inhOpt), true);
|
||||
|
||||
qry->distinctClause = NIL;
|
||||
|
||||
@ -2213,7 +2214,8 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
|
||||
*/
|
||||
lockTargetTable(pstate, stmt->relname);
|
||||
makeRangeTable(pstate, stmt->fromClause);
|
||||
setTargetTable(pstate, stmt->relname, stmt->inh, true);
|
||||
setTargetTable(pstate, stmt->relname,
|
||||
interpretInhOption(stmt->inhOpt), true);
|
||||
|
||||
qry->targetList = transformTargetList(pstate, stmt->targetList);
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.212 2000/12/22 07:07:58 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.213 2001/01/05 06:34:18 tgl Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@ -24,36 +24,43 @@
|
||||
* SQL92-specific syntax is separated from plain SQL/Postgres syntax
|
||||
* to help isolate the non-extensible portions of the parser.
|
||||
*
|
||||
* if you use list, make sure the datum is a node so that the printing
|
||||
* routines work
|
||||
* In general, nothing in this file should initiate database accesses
|
||||
* nor depend on changeable state (such as SET variables). If you do
|
||||
* database accesses, your code will fail when we have aborted the
|
||||
* current transaction and are just parsing commands to find the next
|
||||
* ROLLBACK or COMMIT. If you make use of SET variables, then you
|
||||
* will do the wrong thing in multi-query strings like this:
|
||||
* SET SQL_inheritance TO off; SELECT * FROM foo;
|
||||
* because the entire string is parsed by gram.y before the SET gets
|
||||
* executed. Anything that depends on the database or changeable state
|
||||
* should be handled inside parse_analyze() so that it happens at the
|
||||
* right time not the wrong time. The handling of SQL_inheritance is
|
||||
* a good example.
|
||||
*
|
||||
* WARNING
|
||||
* sometimes we assign constants to makeStrings. Make sure we don't free
|
||||
* WARNINGS
|
||||
* If you use a list, make sure the datum is a node so that the printing
|
||||
* routines work.
|
||||
*
|
||||
* Sometimes we assign constants to makeStrings. Make sure we don't free
|
||||
* those.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include <ctype.h>
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "access/htup.h"
|
||||
#include "access/xact.h"
|
||||
#include "catalog/catname.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "nodes/params.h"
|
||||
#include "nodes/parsenodes.h"
|
||||
#include "nodes/print.h"
|
||||
#include "parser/analyze.h"
|
||||
#include "parser/gramparse.h"
|
||||
#include "parser/parse_type.h"
|
||||
#include "storage/bufpage.h"
|
||||
#include "storage/lmgr.h"
|
||||
#include "utils/acl.h"
|
||||
#include "utils/numeric.h"
|
||||
#include "utils/guc.h"
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
#include "miscadmin.h"
|
||||
#include "mb/pg_wchar.h"
|
||||
#else
|
||||
#define GetStandardEncoding() 0 /* SQL_ASCII */
|
||||
@ -99,6 +106,7 @@ static void doNegateFloat(Value *v);
|
||||
char *str;
|
||||
bool boolean;
|
||||
JoinType jtype;
|
||||
InhOption inhOpt;
|
||||
List *list;
|
||||
Node *node;
|
||||
Value *value;
|
||||
@ -175,7 +183,7 @@ static void doNegateFloat(Value *v);
|
||||
|
||||
%type <list> stmtblock, stmtmulti,
|
||||
into_clause, OptTempTableName, relation_name_list,
|
||||
OptTableElementList, OptUnder, OptInherit, definition, opt_distinct,
|
||||
OptTableElementList, OptInherit, definition, opt_distinct,
|
||||
opt_with, func_args, func_args_list, func_as,
|
||||
oper_argtypes, RuleActionList, RuleActionMulti,
|
||||
opt_column_list, columnList, opt_va_list, va_list,
|
||||
@ -202,9 +210,10 @@ static void doNegateFloat(Value *v);
|
||||
%type <list> opt_interval
|
||||
%type <node> substr_from, substr_for
|
||||
|
||||
%type <boolean> opt_inh_star, opt_binary, opt_using, opt_instead, opt_only
|
||||
opt_with_copy, index_opt_unique, opt_verbose, opt_analyze
|
||||
%type <boolean> opt_cursor
|
||||
%type <boolean> opt_binary, opt_using, opt_instead, opt_cursor
|
||||
%type <boolean> opt_with_copy, index_opt_unique, opt_verbose, opt_analyze
|
||||
|
||||
%type <inhOpt> opt_inh_star, opt_only
|
||||
|
||||
%type <ival> copy_dirn, direction, reindex_type, drop_type,
|
||||
opt_column, event, comment_type, comment_cl,
|
||||
@ -319,7 +328,6 @@ static void doNegateFloat(Value *v);
|
||||
PATH_P, PENDANT,
|
||||
RESTRICT,
|
||||
TRIGGER,
|
||||
UNDER,
|
||||
WITHOUT
|
||||
|
||||
/* Keywords (in SQL92 non-reserved words) */
|
||||
@ -937,7 +945,7 @@ AlterTableStmt:
|
||||
AlterTableStmt *n = makeNode(AlterTableStmt);
|
||||
n->subtype = 'A';
|
||||
n->relname = $3;
|
||||
n->inh = $4 || SQL_inheritance;
|
||||
n->inhOpt = $4;
|
||||
n->def = $7;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
@ -947,7 +955,7 @@ AlterTableStmt:
|
||||
AlterTableStmt *n = makeNode(AlterTableStmt);
|
||||
n->subtype = 'T';
|
||||
n->relname = $3;
|
||||
n->inh = $4 || SQL_inheritance;
|
||||
n->inhOpt = $4;
|
||||
n->name = $7;
|
||||
n->def = $8;
|
||||
$$ = (Node *)n;
|
||||
@ -958,7 +966,7 @@ AlterTableStmt:
|
||||
AlterTableStmt *n = makeNode(AlterTableStmt);
|
||||
n->subtype = 'D';
|
||||
n->relname = $3;
|
||||
n->inh = $4 || SQL_inheritance;
|
||||
n->inhOpt = $4;
|
||||
n->name = $7;
|
||||
n->behavior = $8;
|
||||
$$ = (Node *)n;
|
||||
@ -969,7 +977,7 @@ AlterTableStmt:
|
||||
AlterTableStmt *n = makeNode(AlterTableStmt);
|
||||
n->subtype = 'C';
|
||||
n->relname = $3;
|
||||
n->inh = $4 || SQL_inheritance;
|
||||
n->inhOpt = $4;
|
||||
n->def = $6;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
@ -979,7 +987,7 @@ AlterTableStmt:
|
||||
AlterTableStmt *n = makeNode(AlterTableStmt);
|
||||
n->subtype = 'X';
|
||||
n->relname = $3;
|
||||
n->inh = $4 || SQL_inheritance;
|
||||
n->inhOpt = $4;
|
||||
n->name = $7;
|
||||
n->behavior = $8;
|
||||
$$ = (Node *)n;
|
||||
@ -1108,22 +1116,13 @@ copy_null: WITH NULL_P AS Sconst { $$ = $4; }
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
CreateStmt: CREATE OptTemp TABLE relation_name OptUnder '(' OptTableElementList ')' OptInherit
|
||||
CreateStmt: CREATE OptTemp TABLE relation_name '(' OptTableElementList ')' OptInherit
|
||||
{
|
||||
CreateStmt *n = makeNode(CreateStmt);
|
||||
n->istemp = $2;
|
||||
n->relname = $4;
|
||||
n->tableElts = $7;
|
||||
n->inhRelnames = nconc($5, $9);
|
||||
/* if ($5 != NIL)
|
||||
{
|
||||
n->inhRelnames = $5;
|
||||
}
|
||||
else
|
||||
{ */
|
||||
/* INHERITS is deprecated */
|
||||
/* n->inhRelnames = $9;
|
||||
} */
|
||||
n->tableElts = $6;
|
||||
n->inhRelnames = $8;
|
||||
n->constraints = NIL;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
@ -1480,16 +1479,11 @@ key_reference: NO ACTION { $$ = FKCONSTR_ON_KEY_NOACTION; }
|
||||
| SET DEFAULT { $$ = FKCONSTR_ON_KEY_SETDEFAULT; }
|
||||
;
|
||||
|
||||
OptUnder: UNDER relation_name_list { $$ = $2; }
|
||||
| /*EMPTY*/ { $$ = NIL; }
|
||||
opt_only: ONLY { $$ = INH_NO; }
|
||||
| /*EMPTY*/ { $$ = INH_DEFAULT; }
|
||||
;
|
||||
|
||||
opt_only: ONLY { $$ = FALSE; }
|
||||
| /*EMPTY*/ { $$ = TRUE; }
|
||||
;
|
||||
|
||||
/* INHERITS is Deprecated */
|
||||
OptInherit: INHERITS '(' relation_name_list ')' { $$ = $3; }
|
||||
OptInherit: INHERITS '(' relation_name_list ')' { $$ = $3; }
|
||||
| /*EMPTY*/ { $$ = NIL; }
|
||||
;
|
||||
|
||||
@ -1498,7 +1492,7 @@ OptInherit: INHERITS '(' relation_name_list ')' { $$ = $3; }
|
||||
* SELECT ... INTO.
|
||||
*/
|
||||
|
||||
CreateAsStmt: CREATE OptTemp TABLE relation_name OptUnder OptCreateAs AS SelectStmt
|
||||
CreateAsStmt: CREATE OptTemp TABLE relation_name OptCreateAs AS SelectStmt
|
||||
{
|
||||
/*
|
||||
* When the SelectStmt is a set-operation tree, we must
|
||||
@ -1507,16 +1501,14 @@ CreateAsStmt: CREATE OptTemp TABLE relation_name OptUnder OptCreateAs AS Select
|
||||
* to find it. Similarly, the output column names must
|
||||
* be attached to that Select's target list.
|
||||
*/
|
||||
SelectStmt *n = findLeftmostSelect((SelectStmt *) $8);
|
||||
SelectStmt *n = findLeftmostSelect((SelectStmt *) $7);
|
||||
if (n->into != NULL)
|
||||
elog(ERROR,"CREATE TABLE/AS SELECT may not specify INTO");
|
||||
n->istemp = $2;
|
||||
n->into = $4;
|
||||
if ($5 != NIL)
|
||||
elog(ERROR,"CREATE TABLE/AS SELECT does not support UNDER");
|
||||
if ($6 != NIL)
|
||||
mapTargetColumns($6, n->targetList);
|
||||
$$ = $8;
|
||||
if ($5 != NIL)
|
||||
mapTargetColumns($5, n->targetList);
|
||||
$$ = $7;
|
||||
}
|
||||
;
|
||||
|
||||
@ -2608,12 +2600,11 @@ opt_force: FORCE { $$ = TRUE; }
|
||||
*****************************************************************************/
|
||||
|
||||
RenameStmt: ALTER TABLE relation_name opt_inh_star
|
||||
/* "*" deprecated */
|
||||
RENAME opt_column opt_name TO name
|
||||
{
|
||||
RenameStmt *n = makeNode(RenameStmt);
|
||||
n->relname = $3;
|
||||
n->inh = $4 || SQL_inheritance;
|
||||
n->inhOpt = $4;
|
||||
n->column = $7;
|
||||
n->newname = $9;
|
||||
$$ = (Node *)n;
|
||||
@ -3182,7 +3173,7 @@ columnElem: ColId opt_indirection
|
||||
DeleteStmt: DELETE FROM opt_only relation_name where_clause
|
||||
{
|
||||
DeleteStmt *n = makeNode(DeleteStmt);
|
||||
n->inh = $3;
|
||||
n->inhOpt = $3;
|
||||
n->relname = $4;
|
||||
n->whereClause = $5;
|
||||
$$ = (Node *)n;
|
||||
@ -3227,7 +3218,7 @@ UpdateStmt: UPDATE opt_only relation_name
|
||||
where_clause
|
||||
{
|
||||
UpdateStmt *n = makeNode(UpdateStmt);
|
||||
n->inh = $2;
|
||||
n->inhOpt = $2;
|
||||
n->relname = $3;
|
||||
n->targetList = $5;
|
||||
n->fromClause = $6;
|
||||
@ -3552,8 +3543,8 @@ select_offset_value: Iconst
|
||||
* ...however, recursive addattr and rename supported. make special
|
||||
* cases for these.
|
||||
*/
|
||||
opt_inh_star: '*' { $$ = TRUE; }
|
||||
| /*EMPTY*/ { $$ = FALSE; }
|
||||
opt_inh_star: '*' { $$ = INH_YES; }
|
||||
| /*EMPTY*/ { $$ = INH_DEFAULT; }
|
||||
;
|
||||
|
||||
relation_name_list: name_list;
|
||||
@ -3791,10 +3782,10 @@ join_qual: USING '(' name_list ')' { $$ = (Node *) $3; }
|
||||
|
||||
relation_expr: relation_name
|
||||
{
|
||||
/* default inheritance */
|
||||
/* default inheritance */
|
||||
$$ = makeNode(RangeVar);
|
||||
$$->relname = $1;
|
||||
$$->inh = SQL_inheritance;
|
||||
$$->inhOpt = INH_DEFAULT;
|
||||
$$->name = NULL;
|
||||
}
|
||||
| relation_name '*' %prec '='
|
||||
@ -3802,7 +3793,7 @@ relation_expr: relation_name
|
||||
/* inheritance query */
|
||||
$$ = makeNode(RangeVar);
|
||||
$$->relname = $1;
|
||||
$$->inh = TRUE;
|
||||
$$->inhOpt = INH_YES;
|
||||
$$->name = NULL;
|
||||
}
|
||||
| ONLY relation_name %prec '='
|
||||
@ -3810,7 +3801,7 @@ relation_expr: relation_name
|
||||
/* no inheritance */
|
||||
$$ = makeNode(RangeVar);
|
||||
$$->relname = $2;
|
||||
$$->inh = FALSE;
|
||||
$$->inhOpt = INH_NO;
|
||||
$$->name = NULL;
|
||||
}
|
||||
;
|
||||
@ -5529,7 +5520,6 @@ TokenId: ABSOLUTE { $$ = "absolute"; }
|
||||
| TRIGGER { $$ = "trigger"; }
|
||||
| TRUNCATE { $$ = "truncate"; }
|
||||
| TRUSTED { $$ = "trusted"; }
|
||||
| UNDER { $$ = "under"; }
|
||||
| UNLISTEN { $$ = "unlisten"; }
|
||||
| UNTIL { $$ = "until"; }
|
||||
| UPDATE { $$ = "update"; }
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.86 2000/12/15 23:36:19 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.87 2001/01/05 06:34:19 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -262,7 +262,6 @@ static ScanKeyword ScanKeywords[] = {
|
||||
{"truncate", TRUNCATE},
|
||||
{"trusted", TRUSTED},
|
||||
{"type", TYPE_P},
|
||||
{"under", UNDER},
|
||||
{"union", UNION},
|
||||
{"unique", UNIQUE},
|
||||
{"unlisten", UNLISTEN},
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.73 2000/11/16 22:30:27 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.74 2001/01/05 06:34:18 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -29,6 +29,8 @@
|
||||
#include "parser/parse_relation.h"
|
||||
#include "parser/parse_target.h"
|
||||
#include "parser/parse_type.h"
|
||||
#include "utils/guc.h"
|
||||
|
||||
|
||||
#define ORDER_CLAUSE 0
|
||||
#define GROUP_CLAUSE 1
|
||||
@ -171,6 +173,29 @@ setTargetTable(ParseState *pstate, char *relname, bool inh, bool inJoinSet)
|
||||
pstate->p_target_rangetblentry = rte;
|
||||
}
|
||||
|
||||
/*
|
||||
* Simplify InhOption (yes/no/default) into boolean yes/no.
|
||||
*
|
||||
* The reason we do things this way is that we don't want to examine the
|
||||
* SQL_inheritance option flag until parse_analyze is run. Otherwise,
|
||||
* we'd do the wrong thing with query strings that intermix SET commands
|
||||
* with queries.
|
||||
*/
|
||||
bool
|
||||
interpretInhOption(InhOption inhOpt)
|
||||
{
|
||||
switch (inhOpt)
|
||||
{
|
||||
case INH_NO:
|
||||
return false;
|
||||
case INH_YES:
|
||||
return true;
|
||||
case INH_DEFAULT:
|
||||
return SQL_inheritance;
|
||||
}
|
||||
elog(ERROR, "Bogus InhOption value");
|
||||
return false; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract all not-in-common columns from column lists of a source table
|
||||
@ -355,7 +380,8 @@ transformTableEntry(ParseState *pstate, RangeVar *r)
|
||||
* automatically generate the range variable if not specified. However
|
||||
* there are times we need to know whether the entries are legitimate.
|
||||
*/
|
||||
rte = addRangeTableEntry(pstate, relname, r->name, r->inh, true);
|
||||
rte = addRangeTableEntry(pstate, relname, r->name,
|
||||
interpretInhOption(r->inhOpt), true);
|
||||
|
||||
/*
|
||||
* We create a RangeTblRef, but we do not add it to the joinlist here.
|
||||
|
@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.104 2000/12/08 06:17:58 inoue Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.105 2001/01/05 06:34:20 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -37,6 +37,7 @@
|
||||
#include "commands/view.h"
|
||||
#include "miscadmin.h"
|
||||
#include "parser/parse.h"
|
||||
#include "parser/parse_clause.h"
|
||||
#include "parser/parse_expr.h"
|
||||
#include "rewrite/rewriteDefine.h"
|
||||
#include "rewrite/rewriteRemove.h"
|
||||
@ -400,7 +401,7 @@ ProcessUtility(Node *parsetree,
|
||||
renameatt(relname, /* relname */
|
||||
stmt->column, /* old att name */
|
||||
stmt->newname, /* new att name */
|
||||
stmt->inh); /* recursive? */
|
||||
interpretInhOption(stmt->inhOpt)); /* recursive? */
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -420,25 +421,40 @@ ProcessUtility(Node *parsetree,
|
||||
switch (stmt->subtype)
|
||||
{
|
||||
case 'A': /* ADD COLUMN */
|
||||
AlterTableAddColumn(stmt->relname, stmt->inh, (ColumnDef *) stmt->def);
|
||||
AlterTableAddColumn(stmt->relname,
|
||||
interpretInhOption(stmt->inhOpt),
|
||||
(ColumnDef *) stmt->def);
|
||||
break;
|
||||
case 'T': /* ALTER COLUMN */
|
||||
AlterTableAlterColumn(stmt->relname, stmt->inh, stmt->name, stmt->def);
|
||||
AlterTableAlterColumn(stmt->relname,
|
||||
interpretInhOption(stmt->inhOpt),
|
||||
stmt->name,
|
||||
stmt->def);
|
||||
break;
|
||||
case 'D': /* ALTER DROP */
|
||||
AlterTableDropColumn(stmt->relname, stmt->inh, stmt->name, stmt->behavior);
|
||||
AlterTableDropColumn(stmt->relname,
|
||||
interpretInhOption(stmt->inhOpt),
|
||||
stmt->name,
|
||||
stmt->behavior);
|
||||
break;
|
||||
case 'C': /* ADD CONSTRAINT */
|
||||
AlterTableAddConstraint(stmt->relname, stmt->inh, stmt->def);
|
||||
AlterTableAddConstraint(stmt->relname,
|
||||
interpretInhOption(stmt->inhOpt),
|
||||
stmt->def);
|
||||
break;
|
||||
case 'X': /* DROP CONSTRAINT */
|
||||
AlterTableDropConstraint(stmt->relname, stmt->inh, stmt->name, stmt->behavior);
|
||||
AlterTableDropConstraint(stmt->relname,
|
||||
interpretInhOption(stmt->inhOpt),
|
||||
stmt->name,
|
||||
stmt->behavior);
|
||||
break;
|
||||
case 'E': /* CREATE TOAST TABLE */
|
||||
AlterTableCreateToastTable(stmt->relname, false);
|
||||
AlterTableCreateToastTable(stmt->relname,
|
||||
false);
|
||||
break;
|
||||
case 'U': /* ALTER OWNER */
|
||||
AlterTableOwner(stmt->relname, stmt->name);
|
||||
AlterTableOwner(stmt->relname,
|
||||
stmt->name);
|
||||
break;
|
||||
default: /* oops */
|
||||
elog(ERROR, "T_AlterTableStmt: unknown subtype");
|
||||
|
@ -9,7 +9,7 @@ CREATE \[ TEMPORARY | TEMP \] TABLE table (
|
||||
\[, PRIMARY KEY ( column \[, ...\] ) \]
|
||||
\[, CHECK ( condition ) \]
|
||||
\[, table_constraint_clause \]
|
||||
) \[ UNDER inherited_table \[, ...\] \]
|
||||
) \[ INHERITS ( inherited_table \[, ...\] ) \]
|
||||
" {code} "
|
||||
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.
|
||||
|
@ -11,7 +11,7 @@ Let's create two classes. The capitals class contains state capitals which are a
|
||||
|
||||
CREATE TABLE capitals (
|
||||
state char2
|
||||
) UNDER cities;
|
||||
) INHERITS (cities);
|
||||
" {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.
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: parsenodes.h,v 1.122 2000/11/24 20:16:40 petere Exp $
|
||||
* $Id: parsenodes.h,v 1.123 2001/01/05 06:34:21 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -89,6 +89,13 @@ typedef struct Query
|
||||
} Query;
|
||||
|
||||
|
||||
typedef enum InhOption
|
||||
{
|
||||
INH_NO, /* Do NOT scan child tables */
|
||||
INH_YES, /* DO scan child tables */
|
||||
INH_DEFAULT /* Use current SQL_inheritance option */
|
||||
} InhOption;
|
||||
|
||||
/*****************************************************************************
|
||||
* Other Statements (no optimizations required)
|
||||
*
|
||||
@ -100,9 +107,11 @@ typedef struct Query
|
||||
|
||||
/* ----------------------
|
||||
* Alter Table
|
||||
*
|
||||
* The fields are used in different ways by the different variants of
|
||||
* this command.
|
||||
* ----------------------
|
||||
*/
|
||||
/* The fields are used in different ways by the different variants of this command */
|
||||
typedef struct AlterTableStmt
|
||||
{
|
||||
NodeTag type;
|
||||
@ -111,7 +120,7 @@ typedef struct AlterTableStmt
|
||||
* E = add toast table,
|
||||
* U = change owner */
|
||||
char *relname; /* table to work on */
|
||||
bool inh; /* recursively on children? */
|
||||
InhOption inhOpt; /* recursively act on children? */
|
||||
char *name; /* column or constraint name to act on, or new owner */
|
||||
Node *def; /* definition of new column or constraint */
|
||||
int behavior; /* CASCADE or RESTRICT drop behavior */
|
||||
@ -554,7 +563,7 @@ typedef struct RenameStmt
|
||||
{
|
||||
NodeTag type;
|
||||
char *relname; /* relation to be altered */
|
||||
bool inh; /* recursively alter children? */
|
||||
InhOption inhOpt; /* recursively act on children? */
|
||||
char *column; /* if NULL, rename the relation name to
|
||||
* the new name. Otherwise, rename this
|
||||
* column name. */
|
||||
@ -807,7 +816,7 @@ typedef struct DeleteStmt
|
||||
NodeTag type;
|
||||
char *relname; /* relation to delete from */
|
||||
Node *whereClause; /* qualifications */
|
||||
bool inh; /* delete from subclasses */
|
||||
InhOption inhOpt; /* recursively act on children? */
|
||||
} DeleteStmt;
|
||||
|
||||
/* ----------------------
|
||||
@ -821,7 +830,7 @@ typedef struct UpdateStmt
|
||||
List *targetList; /* the target list (of ResTarget) */
|
||||
Node *whereClause; /* qualifications */
|
||||
List *fromClause; /* the from clause */
|
||||
bool inh; /* update subclasses */
|
||||
InhOption inhOpt; /* recursively act on children? */
|
||||
} UpdateStmt;
|
||||
|
||||
/* ----------------------
|
||||
@ -1125,7 +1134,7 @@ typedef struct RangeVar
|
||||
{
|
||||
NodeTag type;
|
||||
char *relname; /* the relation name */
|
||||
bool inh; /* expand rel by inheritance? */
|
||||
InhOption inhOpt; /* expand rel by inheritance? */
|
||||
Attr *name; /* optional table alias & column aliases */
|
||||
} RangeVar;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: parse_clause.h,v 1.20 2000/11/08 22:10:02 tgl Exp $
|
||||
* $Id: parse_clause.h,v 1.21 2001/01/05 06:34:21 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -20,6 +20,7 @@ extern void makeRangeTable(ParseState *pstate, List *frmList);
|
||||
extern void lockTargetTable(ParseState *pstate, char *relname);
|
||||
extern void setTargetTable(ParseState *pstate, char *relname,
|
||||
bool inh, bool inJoinSet);
|
||||
extern bool interpretInhOption(InhOption inhOpt);
|
||||
extern Node *transformWhereClause(ParseState *pstate, Node *where);
|
||||
extern List *transformGroupClause(ParseState *pstate, List *grouplist,
|
||||
List *targetlist);
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.34 2000/12/18 11:33:55 meskes Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/keywords.c,v 1.35 2001/01/05 06:34:22 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -262,7 +262,6 @@ static ScanKeyword ScanKeywords[] = {
|
||||
{"truncate", TRUNCATE},
|
||||
{"trusted", TRUSTED},
|
||||
{"type", TYPE_P},
|
||||
{"under", UNDER},
|
||||
{"union", UNION},
|
||||
{"unique", UNIQUE},
|
||||
{"unlisten", UNLISTEN},
|
||||
|
@ -232,7 +232,7 @@ make_name(void)
|
||||
OPERATOR, OWNER, PASSWORD, PROCEDURAL, REINDEX, RENAME, RESET,
|
||||
RETURNS, ROW, RULE, SEQUENCE, SERIAL, SETOF, SHARE,
|
||||
SHOW, START, STATEMENT, STDIN, STDOUT, SYSID TEMP,
|
||||
TEMPLATE, TOAST, TRUNCATE, TRUSTED, UNDER, UNLISTEN, UNTIL, VACUUM,
|
||||
TEMPLATE, TOAST, TRUNCATE, TRUSTED, UNLISTEN, UNTIL, VACUUM,
|
||||
VALID, VERBOSE, VERSION
|
||||
|
||||
/* The grammar thinks these are keywords, but they are not in the keywords.c
|
||||
@ -281,7 +281,7 @@ make_name(void)
|
||||
|
||||
%type <str> Iconst Fconst Sconst TransactionStmt CreateStmt UserId
|
||||
%type <str> CreateAsElement OptCreateAs CreateAsList CreateAsStmt
|
||||
%type <str> OptUnder key_reference comment_text ConstraintDeferrabilitySpec
|
||||
%type <str> key_reference comment_text ConstraintDeferrabilitySpec
|
||||
%type <str> key_match ColLabel SpecialRuleRelation ColId columnDef
|
||||
%type <str> ColConstraint ColConstraintElem drop_type Bitconst
|
||||
%type <str> OptTableElementList OptTableElement TableConstraint
|
||||
@ -1043,10 +1043,10 @@ copy_null: WITH NULL_P AS StringConst { $$ = cat2_str(make_str("with null as"),
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
CreateStmt: CREATE OptTemp TABLE relation_name OptUnder '(' OptTableElementList ')'
|
||||
CreateStmt: CREATE OptTemp TABLE relation_name '(' OptTableElementList ')'
|
||||
OptInherit
|
||||
{
|
||||
$$ = cat_str(9, make_str("create"), $2, make_str("table"), $4, $5, make_str("("), $7, make_str(")"), $9);
|
||||
$$ = cat_str(8, make_str("create"), $2, make_str("table"), $4, make_str("("), $6, make_str(")"), $8);
|
||||
}
|
||||
;
|
||||
|
||||
@ -1241,15 +1241,10 @@ key_reference: NO ACTION { $$ = make_str("no action"); }
|
||||
| SET NULL_P { $$ = make_str("set null"); }
|
||||
;
|
||||
|
||||
OptUnder: UNDER relation_name_list { $$ = cat2_str(make_str("under"), $2); }
|
||||
| /*EMPTY*/ { $$ = EMPTY; }
|
||||
;
|
||||
|
||||
opt_only: ONLY { $$ = make_str("only"); }
|
||||
| /*EMPTY*/ { $$ = EMPTY; }
|
||||
;
|
||||
|
||||
/* INHERITS is Deprecated */
|
||||
OptInherit: INHERITS '(' relation_name_list ')' { $$ = cat_str(3, make_str("inherits ("), $3, make_str(")")); }
|
||||
| /*EMPTY*/ { $$ = EMPTY; }
|
||||
;
|
||||
@ -1259,15 +1254,12 @@ OptInherit: INHERITS '(' relation_name_list ')' { $$ = cat_str(3
|
||||
* SELECT ... INTO.
|
||||
*/
|
||||
|
||||
CreateAsStmt: CREATE OptTemp TABLE relation_name OptUnder OptCreateAs AS SelectStmt
|
||||
CreateAsStmt: CREATE OptTemp TABLE relation_name OptCreateAs AS SelectStmt
|
||||
{
|
||||
if (FoundInto == 1)
|
||||
mmerror(ET_ERROR, "CREATE TABLE/AS SELECT may not specify INTO");
|
||||
|
||||
if (strlen($5) > 0)
|
||||
mmerror(ET_ERROR, "CREATE TABLE/AS SELECT does not support UNDER");
|
||||
|
||||
$$ = cat_str(8, make_str("create"), $2, make_str("table"), $4, $5, $6, make_str("as"), $8);
|
||||
$$ = cat_str(7, make_str("create"), $2, make_str("table"), $4, $5, make_str("as"), $7);
|
||||
}
|
||||
;
|
||||
|
||||
@ -5084,7 +5076,6 @@ TokenId: ABSOLUTE { $$ = make_str("absolute"); }
|
||||
| TRIGGER { $$ = make_str("trigger"); }
|
||||
| TRUNCATE { $$ = make_str("truncate"); }
|
||||
| TRUSTED { $$ = make_str("trusted"); }
|
||||
| UNDER { $$ = make_str("under"); }
|
||||
| UNLISTEN { $$ = make_str("unlisten"); }
|
||||
| UNTIL { $$ = make_str("until"); }
|
||||
| UPDATE { $$ = make_str("update"); }
|
||||
|
@ -2,9 +2,9 @@
|
||||
-- Test inheritance features
|
||||
--
|
||||
CREATE TABLE a (aa TEXT);
|
||||
CREATE TABLE b UNDER a (bb TEXT);
|
||||
CREATE TABLE c UNDER a (cc TEXT);
|
||||
CREATE TABLE d UNDER b,c,a (dd TEXT);
|
||||
CREATE TABLE b (bb TEXT) INHERITS (a);
|
||||
CREATE TABLE c (cc TEXT) INHERITS (a);
|
||||
CREATE TABLE d (dd TEXT) INHERITS (b,c,a);
|
||||
INSERT INTO a(aa) VALUES('aaa');
|
||||
INSERT INTO a(aa) VALUES('aaaa');
|
||||
INSERT INTO a(aa) VALUES('aaaaa');
|
||||
|
@ -2,9 +2,9 @@
|
||||
-- Test inheritance features
|
||||
--
|
||||
CREATE TABLE a (aa TEXT);
|
||||
CREATE TABLE b UNDER a (bb TEXT);
|
||||
CREATE TABLE c UNDER a (cc TEXT);
|
||||
CREATE TABLE d UNDER b,c,a (dd TEXT);
|
||||
CREATE TABLE b (bb TEXT) INHERITS (a);
|
||||
CREATE TABLE c (cc TEXT) INHERITS (a);
|
||||
CREATE TABLE d (dd TEXT) INHERITS (b,c,a);
|
||||
|
||||
INSERT INTO a(aa) VALUES('aaa');
|
||||
INSERT INTO a(aa) VALUES('aaaa');
|
||||
|
Loading…
Reference in New Issue
Block a user