Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2fb6cc9

Browse files
committed
Remove not-really-standard implementation of CREATE TABLE's UNDER clause,
and revert documentation to describe the existing INHERITS clauseinstead, per recent discussion in pghackers. Also fix implementationof SQL_inheritance SET variable: it is not cool to look at this varduring the initial parsing phase, only during parse_analyze(). Seerecent bug report concerning misinterpretation of date constants justafter a SET TIMEZONE command. gram.y really has to be an invarianttransformation of the query string to a raw parsetree; anything thatcan vary with time must be done during parse analysis.
1 parente62c38d commit2fb6cc9

File tree

19 files changed

+227
-173
lines changed

19 files changed

+227
-173
lines changed

‎doc/src/sgml/advanced.sgml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.19 2000/12/30 19:11:45 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.20 2001/01/05 06:34:15 tgl Exp $
33
-->
44

55
<chapter id="advanced">
@@ -33,9 +33,9 @@ CREATE TABLE cities (
3333
altitude int -- (in ft)
3434
);
3535

36-
CREATE TABLE capitalsUNDER cities(
36+
CREATE TABLE capitals (
3737
state char(2)
38-
);
38+
) INHERITS (cities);
3939
</programlisting>
4040

4141
In this case, an instance of capitals <firstterm>inherits</firstterm> all
@@ -64,12 +64,12 @@ CREATE TABLE capitals UNDER cities (
6464
<para>
6565
For example, the following query finds the names of all cities,
6666
including state capitals, that are located at an altitude
67-
over 500ft, the query is:
67+
over 500ft:
6868

6969
<programlisting>
70-
SELECTc.name,c.altitude
71-
FROM cities c
72-
WHEREc.altitude> 500;
70+
SELECT name, altitude
71+
FROM cities
72+
WHERE altitude&gt; 500;
7373
</programlisting>
7474

7575
which returns:
@@ -89,8 +89,8 @@ SELECT c.name, c.altitude
8989

9090
<para>
9191
On the other hand, the following query finds
92-
all the cities, butnotcapital cities
93-
thatare situated at anattitude of 500ft or higher:
92+
all the cities that arenotstate capitals and
93+
are situated at analtitude of 500ft or higher:
9494

9595
<programlisting>
9696
SELECT name, altitude
@@ -109,7 +109,7 @@ SELECT name, altitude
109109

110110
<para>
111111
Here the <quote>ONLY</quote> before cities indicates that the query should
112-
be run over only cities and not classes below cities in the
112+
be run over onlythecities table, and not classes below cities in the
113113
inheritance hierarchy. Many of the commands that we
114114
have already discussed -- <command>SELECT</command>,
115115
<command>UPDATE</command> and <command>DELETE</command> --
@@ -121,13 +121,18 @@ SELECT name, altitude
121121
<para>
122122
In previous versions of <productname>Postgres</productname>, the
123123
default was not to get access to child tables. This was found to
124-
be error prone and is also in violation ofSQL. Under the old
124+
be error prone and is also in violation ofSQL99. Under the old
125125
syntax, to get the sub-classes you append "*" to the table name.
126126
For example
127127
<programlisting>
128128
SELECT * from cities*;
129129
</programlisting>
130-
To get the old behavior, the set configuration option
130+
You can still explicitly specify scanning child tables by appending
131+
"*", as well as explicitly specify not scanning child tables by
132+
writing <quote>ONLY</quote>. But beginning in version 7.1, the default
133+
behavior for an undecorated table name is to scan its child tables
134+
too, whereas before the default was not to do so. To get the old
135+
default behavior, set the configuration option
131136
<literal>SQL_Inheritance</literal> to off, e.g.,
132137
<programlisting>
133138
SET SQL_Inheritance TO OFF;

‎doc/src/sgml/inherit.sgml

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/inherit.sgml,v 1.11 2000/07/02 22:00:23 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/inherit.sgml,v 1.12 2001/01/05 06:34:15 tgl Exp $
33
-->
44

55
<chapter id="inherit">
@@ -17,9 +17,9 @@ CREATE TABLE cities (
1717
altitude int -- (in ft)
1818
);
1919

20-
CREATE TABLE capitalsUNDER cities(
20+
CREATE TABLE capitals (
2121
state char(2)
22-
);
22+
) INHERITS (cities);
2323
</programlisting>
2424

2525
In this case, an instance of capitals <firstterm>inherits</firstterm> all
@@ -43,15 +43,15 @@ CREATE TABLE capitals UNDER cities (
4343
</para>
4444

4545
<para>
46-
For example, the following query finds the names of all cities,
47-
including state capitals, that are located at an altitude
48-
over 500ft, the query is:
46+
For example, the following query finds the names of all cities,
47+
including state capitals, that are located at an altitude
48+
over 500ft:
4949

50-
<programlisting>
51-
SELECTc.name,c.altitude
52-
FROM cities c
53-
WHEREc.altitude> 500;
54-
</programlisting>
50+
<programlisting>
51+
SELECT name, altitude
52+
FROM cities
53+
WHERE altitude&gt; 500;
54+
</programlisting>
5555

5656
which returns:
5757

@@ -69,12 +69,12 @@ CREATE TABLE capitals UNDER cities (
6969
</para>
7070

7171
<para>
72-
On the other hand, the following query finds
73-
all the cities, butnotcapital cities
74-
that are situated at anattitude of 500ft or higher:
72+
On the other hand, the following query finds
73+
all the cities that arenotstate capitals and
74+
are situated at analtitude of 500ft or higher:
7575

7676
<programlisting>
77-
SELECT name, altitude
77+
SELECT name, altitude
7878
FROM ONLY cities
7979
WHERE altitude &gt; 500;
8080

@@ -106,7 +106,7 @@ CREATE TABLE capitals UNDER cities (
106106
<programlisting>
107107
SELECT c.tableoid, c.name, c.altitude
108108
FROM cities c
109-
WHERE c.altitude> 500;
109+
WHERE c.altitude&gt; 500;
110110
</programlisting>
111111

112112
which returns:
@@ -128,7 +128,7 @@ CREATE TABLE capitals UNDER cities (
128128
<programlisting>
129129
SELECT p.relname, c.name, c.altitude
130130
FROM cities c, pg_class p
131-
WHERE c.altitude> 500 and c.tableoid = p.oid;
131+
WHERE c.altitude&gt; 500 and c.tableoid = p.oid;
132132
</programlisting>
133133

134134
which returns:
@@ -150,20 +150,25 @@ CREATE TABLE capitals UNDER cities (
150150
<note>
151151
<title>Deprecated</title>
152152
<para>
153-
In previous versions of <productname>Postgres</productname>, the
154-
default was not to get access to child tables. This was found to
155-
be error prone and is also in violation ofSQL. Under the old
156-
syntax, to get the sub-classes you append "*" to the table name.
157-
For example
153+
In previous versions of <productname>Postgres</productname>, the
154+
default was not to get access to child tables. This was found to
155+
be error prone and is also in violation ofSQL99. Under the old
156+
syntax, to get the sub-classes you append "*" to the table name.
157+
For example
158158
<programlisting>
159159
SELECT * from cities*;
160160
</programlisting>
161-
To get the old behavior, the set configuration option
162-
<literal>SQL_Inheritance</literal> to off, e.g.,
161+
You can still explicitly specify scanning child tables by appending
162+
"*", as well as explicitly specify not scanning child tables by
163+
writing <quote>ONLY</quote>. But beginning in version 7.1, the default
164+
behavior for an undecorated table name is to scan its child tables
165+
too, whereas before the default was not to do so. To get the old
166+
default behavior, set the configuration option
167+
<literal>SQL_Inheritance</literal> to off, e.g.,
163168
<programlisting>
164169
SET SQL_Inheritance TO OFF;
165170
</programlisting>
166-
or add a line in your <filename>postgresql.conf</filename> file.
171+
or add a line in your <filename>postgresql.conf</filename> file.
167172
</para>
168173
</note>
169174
</chapter>

‎doc/src/sgml/ref/alter_table.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.17 2000/12/25 23:15:26 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.18 2001/01/05 06:34:16 tgl Exp $
33
Postgres documentation
44
-->
55

@@ -23,10 +23,10 @@ Postgres documentation
2323
<date>1999-07-20</date>
2424
</refsynopsisdivinfo>
2525
<synopsis>
26-
ALTER TABLE [ ONLY ]<replaceable class="PARAMETER">table</replaceable> [ * ]
26+
ALTER TABLE [ ONLY ]<replaceable class="PARAMETER">table</replaceable> [ * ]
2727
ADD [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> <replaceable
2828
class="PARAMETER">type</replaceable>
29-
ALTER TABLE [ ONLY ]<replaceable class="PARAMETER">table</replaceable> [ * ]
29+
ALTER TABLE [ ONLY ]<replaceable class="PARAMETER">table</replaceable> [ * ]
3030
ALTER [ COLUMN ] <replaceable class="PARAMETER">column</replaceable> { SET DEFAULT <replaceable
3131
class="PARAMETER">value</replaceable> | DROP DEFAULT }
3232
ALTER TABLE <replaceable class="PARAMETER">table</replaceable> [ * ]

‎doc/src/sgml/ref/create_table.sgml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v 1.38 2000/12/30 19:00:11 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v 1.39 2001/01/05 06:34:16 tgl Exp $
33
Postgres documentation
44
-->
55

@@ -20,20 +20,18 @@ Postgres documentation
2020
</refnamediv>
2121
<refsynopsisdiv>
2222
<refsynopsisdivinfo>
23-
<date>2000-03-25</date>
23+
<date>2001-01-04</date>
2424
</refsynopsisdivinfo>
2525
<synopsis>
26-
CREATE [ TEMPORARY | TEMP ] TABLE <replaceable class="PARAMETER">table</replaceable>
27-
[ UNDER <replaceable>inherited_table</replaceable> [, ...] ]
28-
(
26+
CREATE [ TEMPORARY | TEMP ] TABLE <replaceable class="PARAMETER">table</replaceable> (
2927
<replaceable class="PARAMETER">column</replaceable> <replaceable class="PARAMETER">type</replaceable>
3028
[ NULL | NOT NULL ] [ UNIQUE ] [ DEFAULT <replaceable class="PARAMETER">value</replaceable> ]
3129
[<replaceable>column_constraint_clause</replaceable> | PRIMARY KEY } [ ... ] ]
3230
[, ... ]
3331
[, PRIMARY KEY ( <replaceable class="PARAMETER">column</replaceable> [, ...] ) ]
3432
[, CHECK ( <replaceable class="PARAMETER">condition</replaceable> ) ]
3533
[, <replaceable>table_constraint_clause</replaceable> ]
36-
)
34+
) [ INHERITS ( <replaceable>inherited_table</replaceable> [, ...] ) ]
3735
</synopsis>
3836

3937
<refsect2 id="R2-SQL-CREATETABLE-1">
@@ -132,10 +130,10 @@ CREATE [ TEMPORARY | TEMP ] TABLE <replaceable class="PARAMETER">table</replacea
132130
</varlistentry>
133131

134132
<varlistentry>
135-
<term>UNDER <replaceable class="PARAMETER">inherited_table</replaceable></term>
133+
<term>INHERITS <replaceable class="PARAMETER">inherited_table</replaceable></term>
136134
<listitem>
137135
<para>
138-
The optionalUNDER clause specifies acollection of table
136+
The optionalINHERITS clause specifies alist of table
139137
names from which this table automatically inherits all fields.
140138
If any inherited field name appears more than once,
141139
<productname>Postgres</productname>
@@ -231,7 +229,7 @@ ERROR: DEFAULT: type mismatched
231229
</para>
232230

233231
<para>
234-
The optionalUNDER
232+
The optionalINHERITS
235233
clause specifies a collection of table names from which this table
236234
automatically inherits all fields. If any inherited field name
237235
appears more than once, Postgres reports an error. Postgres automatically
@@ -2154,6 +2152,19 @@ ALTER DOMAIN cities
21542152
</synopsis>
21552153
</para>
21562154
</refsect3>
2155+
2156+
<refsect3 id="R3-SQL-INHERITANCE-1">
2157+
<title>
2158+
Inheritance
2159+
</title>
2160+
<para>
2161+
Multiple inheritance via the INHERITS clause is a
2162+
<productname>Postgres</productname> language extension.
2163+
SQL99 (but not SQL92) defines single inheritance using a different
2164+
syntax and different semantics. SQL99-style inheritance is not yet
2165+
supported by <productname>Postgres</productname>.
2166+
</para>
2167+
</refsect3>
21572168
</refsect2>
21582169
</refsect1>
21592170
</refentry>

‎src/backend/nodes/copyfuncs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.135 2000/12/14 22:30:42 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.136 2001/01/05 06:34:17 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -1675,7 +1675,7 @@ _copyRangeVar(RangeVar *from)
16751675

16761676
if (from->relname)
16771677
newnode->relname=pstrdup(from->relname);
1678-
newnode->inh=from->inh;
1678+
newnode->inhOpt=from->inhOpt;
16791679
Node_Copy(from,newnode,name);
16801680

16811681
returnnewnode;
@@ -1829,7 +1829,7 @@ _copyDeleteStmt(DeleteStmt *from)
18291829
if (from->relname)
18301830
newnode->relname=pstrdup(from->relname);
18311831
Node_Copy(from,newnode,whereClause);
1832-
newnode->inh=from->inh;
1832+
newnode->inhOpt=from->inhOpt;
18331833

18341834
returnnewnode;
18351835
}
@@ -1844,7 +1844,7 @@ _copyUpdateStmt(UpdateStmt *from)
18441844
Node_Copy(from,newnode,targetList);
18451845
Node_Copy(from,newnode,whereClause);
18461846
Node_Copy(from,newnode,fromClause);
1847-
newnode->inh=from->inh;
1847+
newnode->inhOpt=from->inhOpt;
18481848

18491849
returnnewnode;
18501850
}
@@ -1900,7 +1900,7 @@ _copyAlterTableStmt(AlterTableStmt *from)
19001900
newnode->subtype=from->subtype;
19011901
if (from->relname)
19021902
newnode->relname=pstrdup(from->relname);
1903-
newnode->inh=from->inh;
1903+
newnode->inhOpt=from->inhOpt;
19041904
if (from->name)
19051905
newnode->name=pstrdup(from->name);
19061906
Node_Copy(from,newnode,def);
@@ -2137,7 +2137,7 @@ _copyRenameStmt(RenameStmt *from)
21372137
RenameStmt*newnode=makeNode(RenameStmt);
21382138

21392139
newnode->relname=pstrdup(from->relname);
2140-
newnode->inh=from->inh;
2140+
newnode->inhOpt=from->inhOpt;
21412141
if (from->column)
21422142
newnode->column=pstrdup(from->column);
21432143
if (from->newname)

‎src/backend/nodes/equalfuncs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* Portions Copyright (c) 1994, Regents of the University of California
2121
*
2222
* IDENTIFICATION
23-
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.85 2000/12/14 22:30:42 tgl Exp $
23+
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.86 2001/01/05 06:34:17 tgl Exp $
2424
*
2525
*-------------------------------------------------------------------------
2626
*/
@@ -651,7 +651,7 @@ _equalDeleteStmt(DeleteStmt *a, DeleteStmt *b)
651651
return false;
652652
if (!equal(a->whereClause,b->whereClause))
653653
return false;
654-
if (a->inh!=b->inh)
654+
if (a->inhOpt!=b->inhOpt)
655655
return false;
656656

657657
return true;
@@ -668,7 +668,7 @@ _equalUpdateStmt(UpdateStmt *a, UpdateStmt *b)
668668
return false;
669669
if (!equal(a->fromClause,b->fromClause))
670670
return false;
671-
if (a->inh!=b->inh)
671+
if (a->inhOpt!=b->inhOpt)
672672
return false;
673673

674674
return true;
@@ -741,7 +741,7 @@ _equalAlterTableStmt(AlterTableStmt *a, AlterTableStmt *b)
741741
return false;
742742
if (!equalstr(a->relname,b->relname))
743743
return false;
744-
if (a->inh!=b->inh)
744+
if (a->inhOpt!=b->inhOpt)
745745
return false;
746746
if (!equalstr(a->name,b->name))
747747
return false;
@@ -998,7 +998,7 @@ _equalRenameStmt(RenameStmt *a, RenameStmt *b)
998998
{
999999
if (!equalstr(a->relname,b->relname))
10001000
return false;
1001-
if (a->inh!=b->inh)
1001+
if (a->inhOpt!=b->inhOpt)
10021002
return false;
10031003
if (!equalstr(a->column,b->column))
10041004
return false;
@@ -1501,7 +1501,7 @@ _equalRangeVar(RangeVar *a, RangeVar *b)
15011501
{
15021502
if (!equalstr(a->relname,b->relname))
15031503
return false;
1504-
if (a->inh!=b->inh)
1504+
if (a->inhOpt!=b->inhOpt)
15051505
return false;
15061506
if (!equal(a->name,b->name))
15071507
return false;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp