M-x set-variable tab-width
or
; Cmd to set tab stops &etc for working with PostgreSQL code
- (defun pgsql-mode ()
- "Set PostgreSQL C indenting conventions in current buffer."
- (interactive)
- (c-mode) ; necessary to make c-set
--offset local!
- (setq tab-width 4) ; already buffer-local
- ; (setq comment-column 48) ; already buffer-local
- (c-set-style "bsd")
- (c-set-offset 'case-label '+)
- )
+ (c-add-style "pgsql"
+ '("bsd"
+ (indent-tabs-mode . t)
+ (c-basic-offset . 4)
+ (tab-width . 4)
+ (c-offsets-alist .
+ ((case-label . +))))
+ t) ; t = set this mode on
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">
CREATE TABLE capitals (
state char(2)
-) INHERITS (cities);
+) UNDER cities;
</programlisting>
In this case, an instance of capitals <firstterm>inherits</firstterm> all
</para>
</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 > 500;
+ <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:
+
+ <programlisting>
+ SELECT c.name, c.altitude
+ FROM cities c
+ WHERE c.altitude > 500;
+ </programlisting>
+
+ which returns:
+ <programlisting>
+----------+----------+
|name | altitude |
+----------+----------+
+----------+----------+
|Mariposa | 1953 |
+----------+----------+
- </programlisting>
- </para>
+|Madison | 845 |
++----------+----------+
+ </programlisting>
+ </para>
- <para>
- On the other hand, to find the names of all cities,
- including state capitals, that are located at an altitude
- over 500ft, the query is:
+ <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 c.name, c.altitude
- FROM cities* c
- WHERE c.altitude > 500;
- </programlisting>
+ <programlisting>
+ SELECT name, altitude
+ FROM ONLY cities
+ WHERE altitude > 500;
- which returns:
-
- <programlisting>
+----------+----------+
|name | altitude |
+----------+----------+
+----------+----------+
|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
- inheritance hierarchy. Many of the commands that we
- have already discussed (<command>SELECT</command>,
- <command>UPDATE</command> and <command>DELETE</command>)
- support this inheritance notation using "*" as do other commands like
- <command>ALTER</command>.
- </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
+ inheritance hierarchy. Many of the commands that we
+ have already discussed -- <command>SELECT</command>,
+ <command>UPDATE</command> and <command>DELETE</command> --
+ support this <quote>ONLY</quote> notation.
+ </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>
</sect1>
<sect1>
.\" This is -*-nroff-*-
.\" 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
.SH "Section 7 - System Catalogs"
.de LS
2=main memory */
int2vector relkey /* - unused */
oidvector relkeyop /* - unused */
+ bool relhassubclass /* does the class have a subclass?
+ */
aclitem relacl[1] /* access control lists */
.fi
.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">
altitude int -- (in ft)
);
-CREATE TABLE capitals (
+CREATE TABLE capitals UNDER cities (
state char(2)
-) INHERITS (cities);
+);
</programlisting>
In this case, an instance of capitals <firstterm>inherits</firstterm> all
</para>
</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 > 500;
-
- name | altitude
------------+----------
- Las Vegas | 2174
- Mariposa | 1953
-(2 rows)
-</programlisting>
- </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
over 500ft, the query is:
-<programlisting>
-SELECT c.name, c.altitude
- FROM cities* c
+ <programlisting>
+ SELECT c.name, c.altitude
+ FROM cities c
WHERE c.altitude > 500;
</programlisting>
which returns:
-<programlisting>
- name | altitude
------------+----------
- Las Vegas | 2174
- Mariposa | 1953
- Madison | 845
-</programlisting>
+ <programlisting>
++----------+----------+
+|name | altitude |
++----------+----------+
+|Las Vegas | 2174 |
++----------+----------+
+|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 > 500;
- Here the "*" after cities indicates that the query should
- be run over cities and all classes below cities in the
++----------+----------+
+|name | altitude |
++----------+----------+
+|Las Vegas | 2174 |
++----------+----------+
+|Mariposa | 1953 |
++----------+----------+
+ </programlisting>
+ </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
inheritance hierarchy. Many of the commands that we
have already discussed -- <command>SELECT</command>,
<command>UPDATE</command> and <command>DELETE</command> --
- support this "*" notation, as do others, like
- <command>ALTER TABLE</command>.
+ support this <quote>ONLY</quote> notation.
+ </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>
</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
-->
<date>1999-07-20</date>
</refsynopsisdivinfo>
<synopsis>
-ALTER TABLE <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 <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> [ * ]
The keyword <literal>COLUMN</literal> is noise and can be omitted.
</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>
In the current implementation, default and constraint clauses for the
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
-->
[, PRIMARY KEY ( <replaceable class="PARAMETER">column</replaceable> [, ...] ) ]
[, CHECK ( <replaceable class="PARAMETER">condition</replaceable> ) ]
[, <replaceable>table_constraint_clause</replaceable> ]
- ) [ INHERITS ( <replaceable>inherited_table</replaceable> [, ...] ) ]
+ ) [ UNDER <replaceable>inherited_table</replaceable> [, ...] ]
</synopsis>
<refsect2 id="R2-SQL-CREATETABLE-1">
</varlistentry>
<varlistentry>
- <term>INHERITS <replaceable class="PARAMETER">inherited_table</replaceable></term>
+ <term>UNDER <replaceable class="PARAMETER">inherited_table</replaceable></term>
<listitem>
<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.
If any inherited field name appears more than once,
<productname>Postgres</productname>
</para>
<para>
- The optional INHERITS
+ The optional UNDER
clause specifies a collection of class names from which this class
automatically inherits all fields. If any inherited field name
appears more than once, Postgres reports an error. Postgres automatically
Notes
</title>
<para>
- CREATE TABLE/INHERITS is a <productname>Postgres</productname>
- language extension.
+ CREATE TABLE/UNDER is defined by SQL3. Multiple inheritance is a
+ <productname>Postgres</productname> language extension.
</para>
</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
-->
<date>1999-07-20</date>
</refsynopsisdivinfo>
<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>
<refsect2 id="R2-SQL-DELETE-1">
</tip>
</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>
You must have write access to the table in order to modify
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
-->
SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replaceable> [, ...] ) ] ]
<replaceable class="PARAMETER">expression</replaceable> [ AS <replaceable class="PARAMETER">name</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> ]
[ GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...] ]
[ HAVING <replaceable class="PARAMETER">condition</replaceable> [, ...] ]
if WHERE is omitted, all rows are candidates.
(See <xref linkend="sql-where" endterm="sql-where-title">.)
</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>
<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
-->
</listitem>
</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>
<term>ENABLE_SEQSCAN</term>
<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
-->
<date>1999-07-20</date>
</refsynopsisdivinfo>
<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> ]
[ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
</synopsis>
it, as well as read access to any table whose values are
mentioned in the WHERE condition.
</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 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">
defines one or more instance variables to range over the class
indicated in <replaceable>class_reference</replaceable>.
One can also request
- the instance variable to range over all classes that are beneath the
- indicated class in the inheritance hierarchy by postpending the
- designator asterisk ("*").
+ the instance variable to range over only the specific class
+ and not those that are beneath the
+ indicated class in the inheritance hierarchy by specifying ONLY before
+ before the classname.
</para>
</sect2>
</sect1>
*
*
* 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
*
*-------------------------------------------------------------------------
*/
const char *attributeType, List *schema);
static List *MergeAttributes(List *schema, List *supers, List **supconstr);
static void StoreCatalogInheritance(Oid relationId, List *supers);
+static void
+setRelhassubclassInRelation(Oid relationId, bool relhassubclass);
+
/* ----------------------------------------------------------------
* DefineRelation
TupleConstr *constr;
relation = heap_openr(name, AccessShareLock);
+ setRelhassubclassInRelation(relation->rd_id, true);
tupleDesc = RelationGetDescr(relation);
constr = tupleDesc->constr;
}
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);
+}
+
+
+
+
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
static bool parse_random_seed(char *);
static bool show_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
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
#endif
else if (strcasecmp(name, "random_seed")==0)
parse_random_seed(pstrdup(value));
+ else if (strcasecmp(name, "examine_subclass")==0)
+ parse_examine_subclass(pstrdup(value));
else
SetConfigOption(name, value, superuser() ? PGC_SUSET : PGC_USERSET);
}
#endif
else if (strcasecmp(name, "random_seed")==0)
show_random_seed();
+ else if (strcasecmp(name, "examine_subclass")==0)
+ show_examine_subclass();
else
{
const char * val = GetConfigOption(name, superuser());
}
}
-
void
ResetPGVariable(const char *name)
{
#endif
else if (strcasecmp(name, "random_seed")==0)
reset_random_seed();
+ else if (strcasecmp(name, "examine_subclass")==0)
+ reset_examine_subclass();
else
SetConfigOption(name, NULL, superuser() ? PGC_SUSET : PGC_USERSET);
}
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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
*
*
* 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
* XXX a few of the following functions are duplicated to handle
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.
*/
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
Plan *
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
parse->qual = eval_const_expressions(parse->qual);
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.
*
*
*
* 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
*
*-------------------------------------------------------------------------
*/
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
/*
* VersionGetParents
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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 $
*
*-------------------------------------------------------------------------
*/
/* set up a range table */
makeRangeTable(pstate, NULL);
- setTargetTable(pstate, stmt->relname);
+ setTargetTable(pstate, stmt->relname, stmt->inh);
qry->distinctClause = NIL;
* (We didn't want it there until now since it shouldn't be visible in
* the SELECT part.)
*/
- setTargetTable(pstate, stmt->relname);
+ setTargetTable(pstate, stmt->relname, FALSE);
/* now the range table will not change */
qry->rtable = pstate->p_rtable;
* do this with REPLACE in POSTQUEL so we keep the feature.
*/
makeRangeTable(pstate, stmt->fromClause);
- setTargetTable(pstate, stmt->relname);
+ setTargetTable(pstate, stmt->relname, stmt->inh);
qry->targetList = transformTargetList(pstate, stmt->targetList);
*
*
* 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
* AUTHOR DATE MAJOR EVENT
#include "storage/lmgr.h"
#include "utils/acl.h"
#include "utils/numeric.h"
+#include "commands/variable.h"
#ifdef MULTIBYTE
#include "miscadmin.h"
%type <list> stmtblock, stmtmulti,
result, OptTempTableName, relation_name_list, OptTableElementList,
- OptInherit, definition, opt_distinct,
+ OptUnder, 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,
%type <list> substr_list, substr_from, substr_for, trim_list
%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
%type <boolean> opt_cursor
IMMEDIATE, INITIALLY,
PENDANT,
RESTRICT,
- TRIGGER,
+ TRIGGER,
+ UNDER,
OFF
/* Keywords (in SQL92 non-reserved words) */
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'A';
n->relname = $3;
- n->inh = $4;
+ n->inh = $4 || examine_subclass;
n->def = $7;
$$ = (Node *)n;
}
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'T';
n->relname = $3;
- n->inh = $4;
+ n->inh = $4 || examine_subclass;
n->name = $7;
n->def = $8;
$$ = (Node *)n;
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'D';
n->relname = $3;
- n->inh = $4;
+ n->inh = $4 || examine_subclass;
n->name = $7;
n->behavior = $8;
$$ = (Node *)n;
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'C';
n->relname = $3;
- n->inh = $4;
+ n->inh = $4 || examine_subclass;
n->def = $6;
$$ = (Node *)n;
}
AlterTableStmt *n = makeNode(AlterTableStmt);
n->subtype = 'X';
n->relname = $3;
- n->inh = $4;
+ n->inh = $4 || examine_subclass;
n->name = $7;
n->behavior = $8;
$$ = (Node *)n;
*
*****************************************************************************/
-CreateStmt: CREATE OptTemp TABLE relation_name '(' OptTableElementList ')'
- OptInherit
+CreateStmt: CREATE OptTemp TABLE relation_name OptUnder '(' OptTableElementList ')' OptInherit
{
CreateStmt *n = makeNode(CreateStmt);
n->istemp = $2;
n->relname = $4;
- n->tableElts = $6;
- n->inhRelnames = $8;
+ n->tableElts = $7;
+ n->inhRelnames = nconc($5, $9);
+/* if ($5 != NIL)
+ {
+ n->inhRelnames = $5;
+ }
+ else
+ { */
+ /* INHERITS is deprecated */
+ /* n->inhRelnames = $9;
+ } */
n->constraints = NIL;
$$ = (Node *)n;
}
| 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; }
- | /*EMPTY*/ { $$ = NIL; }
+ | /*EMPTY*/ { $$ = NIL; }
;
/*
* 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;
- if ($5 != NIL)
- mapTargetColumns($5, n->targetList);
+ SelectStmt *n = (SelectStmt *)$8;
+ if ($5 != NIL)
+ yyerror("CREATE TABLE/AS SELECT does not support UNDER");
+ if ($6 != NIL)
+ mapTargetColumns($6, n->targetList);
if (n->into != NULL)
elog(ERROR,"CREATE TABLE/AS SELECT may not specify INTO");
n->istemp = $2;
*****************************************************************************/
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;
+ n->inh = $4 || examine_subclass;
n->column = $7;
n->newname = $9;
$$ = (Node *)n;
*
*****************************************************************************/
-DeleteStmt: DELETE FROM relation_name
- where_clause
+DeleteStmt: DELETE FROM opt_only relation_name where_clause
{
DeleteStmt *n = makeNode(DeleteStmt);
- n->relname = $3;
- n->whereClause = $4;
+ n->inh = $3;
+ n->relname = $4;
+ n->whereClause = $5;
$$ = (Node *)n;
}
;
*
*****************************************************************************/
-UpdateStmt: UPDATE relation_name
+UpdateStmt: UPDATE opt_only relation_name
SET update_target_list
from_clause
where_clause
{
UpdateStmt *n = makeNode(UpdateStmt);
- n->relname = $2;
- n->targetList = $4;
- n->fromClause = $5;
- n->whereClause = $6;
+ n->inh = $2;
+ n->relname = $3;
+ n->targetList = $5;
+ n->fromClause = $6;
+ n->whereClause = $7;
$$ = (Node *)n;
}
;
relation_expr: relation_name
{
- /* normal relations */
+ /* default inheritance */
$$ = makeNode(RelExpr);
$$->relname = $1;
- $$->inh = FALSE;
+ $$->inh = examine_subclass;
}
| relation_name '*' %prec '='
{
$$->relname = $1;
$$->inh = TRUE;
}
+ | ONLY relation_name %prec '='
+ {
+ /* no inheritance */
+ $$ = makeNode(RelExpr);
+ $$->relname = $2;
+ $$->inh = FALSE;
+ }
+ ;
opt_array_bounds: '[' ']' opt_array_bounds
{ $$ = lcons(makeInteger(-1), $3); }
| NOTIFY { $$ = "notify"; }
| OF { $$ = "of"; }
| OIDS { $$ = "oids"; }
- | ONLY { $$ = "only"; }
| OPERATOR { $$ = "operator"; }
| OPTION { $$ = "option"; }
| PARTIAL { $$ = "partial"; }
| TRIGGER { $$ = "trigger"; }
| TRUNCATE { $$ = "truncate"; }
| TRUSTED { $$ = "trusted"; }
+ | UNDER { $$ = "under"; }
| UNLISTEN { $$ = "unlisten"; }
| UNTIL { $$ = "until"; }
| UPDATE { $$ = "update"; }
| OFF { $$ = "off"; }
| OFFSET { $$ = "offset"; }
| ON { $$ = "on"; }
+ | ONLY { $$ = "only"; }
| OR { $$ = "or"; }
| ORDER { $$ = "order"; }
| OUTER_P { $$ = "outer"; }
*
*
* 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
*
*-------------------------------------------------------------------------
*/
{"truncate", TRUNCATE},
{"trusted", TRUSTED},
{"type", TYPE_P},
+ {"under", UNDER},
{"union", UNION},
{"unique", UNIQUE},
{"unlisten", UNLISTEN},
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
* there is no other use of any of its attributes. Tricky, eh?
*/
void
-setTargetTable(ParseState *pstate, char *relname)
+setTargetTable(ParseState *pstate, char *relname, bool inh)
{
RangeTblEntry *rte;
if (refnameRangeTablePosn(pstate, relname, NULL) == 0)
rte = addRangeTableEntry(pstate, relname,
makeAttr(relname, NULL),
- FALSE, FALSE, FALSE);
+ inh, FALSE, FALSE);
else
rte = refnameRangeTableEntry(pstate, relname);
\[, PRIMARY KEY ( column \[, ...\] ) \]
\[, CHECK ( condition ) \]
\[, table_constraint_clause \]
- ) \[ INHERITS ( inherited_table \[, ...\] ) \]
+ ) \[ UNDER 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.
CREATE TABLE capitals (
state char2
- ) INHERITS (cities);
+ ) UNDER 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.
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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
* the genbki.sh script reads this file and generates .bki
{ 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, {"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 reltype 26 0 4 2 0 -1 -1 t p f i 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 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 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));
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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
* ``pg_relation'' is being replaced by ``pg_class''. currently
int2 relrefs; /* # of references to this relation */
bool relhaspkey; /* has PRIMARY KEY */
bool relhasrules;
+ bool relhassubclass;
aclitem relacl[1]; /* this is here for the catalog */
} FormData_pg_class;
#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
* relacl field.
* ----------------
*/
-#define Natts_pg_class_fixed 18
-#define Natts_pg_class 19
+#define Natts_pg_class_fixed 19
+#define Natts_pg_class 20
#define Anum_pg_class_relname 1
#define Anum_pg_class_reltype 2
#define Anum_pg_class_relowner 3
#define Anum_pg_class_relrefs 16
#define Anum_pg_class_relhaspkey 17
#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
* ----------------
*/
-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("");
-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("");
-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("");
-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("");
-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("");
-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("");
-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("");
-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("");
-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("");
-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("");
-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("");
-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("");
-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("");
#define RelOid_pg_type 1247
* Headers for handling of 'SET var TO', 'SHOW var' and 'RESET var'
* 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
extern void ResetPGVariable(const char *name);
extern void set_default_datestyle(void);
+extern bool examine_subclass;
#endif /* VARIABLE_H */
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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 $
*
*-------------------------------------------------------------------------
*/
NodeTag type;
char *relname; /* relation to delete from */
Node *whereClause; /* qualifications */
+ bool inh; /* delete from subclasses */
} DeleteStmt;
/* ----------------------
List *targetList; /* the target list (of ResTarget) */
Node *whereClause; /* qualifications */
List *fromClause; /* the from clause */
+ bool inh; /* update subclasses */
} UpdateStmt;
/* ----------------------
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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 $
*
*-------------------------------------------------------------------------
*/
extern List *set_difference(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 *LispUnioni(List *list1, List *list2);
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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 $
*
*-------------------------------------------------------------------------
*/
#include "parser/parse_node.h"
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 List *transformGroupClause(ParseState *pstate, List *grouplist,
List *targetlist);
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
{"truncate", TRUNCATE},
{"trusted", TRUSTED},
{"type", TYPE_P},
+ {"under", UNDER},
{"union", UNION},
{"unique", UNIQUE},
{"unlisten", UNLISTEN},
REINDEX, RENAME, RESET, RETURNS, ROW, RULE,
SEQUENCE, SERIAL, SETOF, SHARE, SHOW, START, STATEMENT, STDIN, STDOUT, SYSID
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 */
%token <str> IDENT SCONST Op CSTRING CVARIABLE CPP_LINE
%type <str> Iconst Fconst Sconst TransactionStmt CreateStmt UserId
%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> ColConstraint ColConstraintElem NumericOnly FloatOnly
%type <str> OptTableElementList OptTableElement TableConstraint
*****************************************************************************/
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);
}
| 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; }
;
/* inheritance query */
$$ = cat2_str($1, make_str("*"));
}
+ | ONLY relation_name %prec '='
+ {
+ /* inheritance query */
+ $$ = cat2_str(make_str("ONLY "), $2);
+ }
opt_array_bounds: '[' ']' opt_array_bounds
{
| 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"); }
test create_aggregate
test create_operator
test create_index
+ test inherit
endparallel
test create_view # Depends on the above