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

Commit8c1d09d

Browse files
committed
Inheritance overhaul by Chris Bitmead <chris@bitmead.com>
1 parentfb07046 commit8c1d09d

File tree

32 files changed

+478
-198
lines changed

32 files changed

+478
-198
lines changed

‎doc/FAQ_DEV

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,14 @@ s
9090
M-x set-variable tab-width
9191
or
9292
; Cmd to set tab stops &etc for working with PostgreSQL code
93-
(defun pgsql-mode ()
94-
"Set PostgreSQL C indenting conventions in current buffer."
95-
(interactive)
96-
(c-mode) ; necessary to make c-set
97-
-offset local!
98-
(setq tab-width 4) ; already buffer-local
99-
; (setq comment-column 48) ; already buffer-local
100-
(c-set-style "bsd")
101-
(c-set-offset 'case-label '+)
102-
)
93+
(c-add-style "pgsql"
94+
'("bsd"
95+
(indent-tabs-mode . t)
96+
(c-basic-offset . 4)
97+
(tab-width . 4)
98+
(c-offsets-alist .
99+
((case-label . +))))
100+
t) ; t = set this mode on
103101

104102
and add this to your autoload list (modify file path in macro):
105103

‎doc/src/sgml/advanced.sgml

Lines changed: 50 additions & 34 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.12 2000/05/02 20:01:51 thomas Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/advanced.sgml,v 1.13 2000/06/0901:43:55 momjian Exp $
33
-->
44

55
<chapter id="advanced">
@@ -35,7 +35,7 @@ CREATE TABLE cities (
3535

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

4141
In this case, an instance of capitals <firstterm>inherits</firstterm> all
@@ -60,57 +60,73 @@ CREATE TABLE capitals (
6060
</para>
6161
</note>
6262

63-
For example, the following query finds
64-
all the cities that are situated at an attitude of 500ft or higher:
65-
66-
<programlisting>
67-
SELECT name, altitude
68-
FROM cities
69-
WHERE altitude &gt; 500;
63+
<para>
64+
For example, the following query finds the names of all cities,
65+
including state capitals, that are located at an altitude
66+
over 500ft, the query is:
67+
68+
<programlisting>
69+
SELECT c.name, c.altitude
70+
FROM cities c
71+
WHERE c.altitude > 500;
72+
</programlisting>
73+
74+
which returns:
7075

76+
<programlisting>
7177
+----------+----------+
7278
|name | altitude |
7379
+----------+----------+
7480
|Las Vegas | 2174 |
7581
+----------+----------+
7682
|Mariposa | 1953 |
7783
+----------+----------+
78-
</programlisting>
79-
</para>
84+
|Madison | 845 |
85+
+----------+----------+
86+
</programlisting>
87+
</para>
8088

81-
<para>
82-
On the other hand,to findthenames of all cities,
83-
including state capitals, that are located at an altitude
84-
over 500ft, the query is:
89+
<para>
90+
On the other hand, thefollowing query finds
91+
all the cities, but not capital cities
92+
that are situated at an attitude of 500ft or higher:
8593

86-
<programlisting>
87-
SELECT c.name, c.altitude
88-
FROM cities* c
89-
WHERE c.altitude > 500;
90-
</programlisting>
94+
<programlisting>
95+
SELECT name, altitude
96+
FROM ONLY cities
97+
WHERE altitude &gt; 500;
9198

92-
which returns:
93-
94-
<programlisting>
9599
+----------+----------+
96100
|name | altitude |
97101
+----------+----------+
98102
|Las Vegas | 2174 |
99103
+----------+----------+
100104
|Mariposa | 1953 |
101105
+----------+----------+
102-
|Madison | 845 |
103-
+----------+----------+
104-
</programlisting>
106+
</programlisting>
107+
</para>
105108

106-
Here the "*" after cities indicates that the query should
107-
be run over cities and all classes below cities in the
108-
inheritance hierarchy. Many of the commands that we
109-
have already discussed (<command>SELECT</command>,
110-
<command>UPDATE</command> and <command>DELETE</command>)
111-
support this inheritance notation using "*" as do other commands like
112-
<command>ALTER</command>.
113-
</para>
109+
110+
Here the <quote>ONLY</quote> before cities indicates that the query should
111+
be run over only cities and not classes below cities in the
112+
inheritance hierarchy. Many of the commands that we
113+
have already discussed -- <command>SELECT</command>,
114+
<command>UPDATE</command> and <command>DELETE</command> --
115+
support this <quote>ONLY</quote> notation.
116+
</para>
117+
<para>
118+
Deprecated: In previous versions of postgres, the default was not to
119+
get access to child classes. By experience this was found to be error
120+
prone. Under the old syntax, to get the sub-classes you append "*"
121+
to the table name. For example
122+
<programlisting>
123+
SELECT * from cities*;
124+
</programlisting>
125+
This old behaviour is still available by using a SET command...
126+
<programlisting>
127+
SET EXAMINE_SUBCLASS TO on;
128+
</programlisting>
129+
</para>
114130
</sect1>
115131

116132
<sect1>

‎doc/src/sgml/catalogs.sgml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" This is -*-nroff-*-
22
.\" XXX standard disclaimer belongs here....
3-
.\" $Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.5 2000/02/17 03:39:39 tgl Exp $
3+
.\" $Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.6 2000/06/09 01:43:56 momjian Exp $
44
.TH "SYSTEM CATALOGS" INTRO 03/13/94 PostgreSQL PostgreSQL
55
.SH "Section 7 - System Catalogs"
66
.deLS
@@ -191,6 +191,8 @@ pg_class
191191
2=main memory */
192192
int2vector relkey/* - unused */
193193
oidvector relkeyop/* - unused */
194+
bool relhassubclass/* does the class have a subclass?
195+
*/
194196
aclitem relacl[1]/* access control lists */
195197
.fi
196198
.nfM

‎doc/src/sgml/inherit.sgml

Lines changed: 55 additions & 34 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.7 2000/05/02 20:01:51 thomas Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/inherit.sgml,v 1.8 2000/06/0901:43:56 momjian Exp $
33
-->
44

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

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

2525
In this case, an instance of capitals <firstterm>inherits</firstterm> all
@@ -41,50 +41,71 @@ CREATE TABLE capitals (
4141
</para>
4242
</note>
4343

44-
For example, the following query finds
45-
all the cities that are situated at an attitude of 500ft or higher:
46-
47-
<programlisting>
48-
SELECT name, altitude
49-
FROM cities
50-
WHERE altitude &gt; 500;
51-
52-
name | altitude
53-
-----------+----------
54-
Las Vegas | 2174
55-
Mariposa | 1953
56-
(2 rows)
57-
</programlisting>
58-
</para>
59-
6044
<para>
61-
Ontheother hand, to find the names of all cities,
45+
For example,the following query finds the names of all cities,
6246
including state capitals, that are located at an altitude
6347
over 500ft, the query is:
6448

65-
<programlisting>
66-
SELECT c.name, c.altitude
67-
FROM cities* c
49+
<programlisting>
50+
SELECT c.name, c.altitude
51+
FROM cities c
6852
WHERE c.altitude > 500;
6953
</programlisting>
7054

7155
which returns:
7256

73-
<programlisting>
74-
name | altitude
75-
-----------+----------
76-
Las Vegas | 2174
77-
Mariposa | 1953
78-
Madison | 845
79-
</programlisting>
57+
<programlisting>
58+
+----------+----------+
59+
|name | altitude |
60+
+----------+----------+
61+
|Las Vegas | 2174 |
62+
+----------+----------+
63+
|Mariposa | 1953 |
64+
+----------+----------+
65+
|Madison | 845 |
66+
+----------+----------+
67+
</programlisting>
68+
</para>
69+
70+
<para>
71+
On the other hand, the following query finds
72+
all the cities, but not capital cities
73+
that are situated at an attitude of 500ft or higher:
74+
75+
<programlisting>
76+
SELECT name, altitude
77+
FROM ONLY cities
78+
WHERE altitude &gt; 500;
8079

81-
Here the "*" after cities indicates that the query should
82-
be run over cities and all classes below cities in the
80+
+----------+----------+
81+
|name | altitude |
82+
+----------+----------+
83+
|Las Vegas | 2174 |
84+
+----------+----------+
85+
|Mariposa | 1953 |
86+
+----------+----------+
87+
</programlisting>
88+
</para>
89+
90+
Here the <quote>ONLY</quote> before cities indicates that the query should
91+
be run over only cities and not classes below cities in the
8392
inheritance hierarchy. Many of the commands that we
8493
have already discussed -- <command>SELECT</command>,
8594
<command>UPDATE</command> and <command>DELETE</command> --
86-
support this "*" notation, as do others, like
87-
<command>ALTER TABLE</command>.
95+
support this <quote>ONLY</quote> notation.
96+
</para>
97+
<para>
98+
Deprecated: In previous versions of postgres, the default was not to
99+
get access to child classes. By experience this was found to be error
100+
prone. Under the old syntax, to get the sub-classes you append "*"
101+
to the table name. For example
102+
<programlisting>
103+
SELECT * from cities*;
104+
</programlisting>
105+
This old behaviour is still available by using a SET command...
106+
<programlisting>
107+
SET EXAMINE_SUBCLASS TO on;
108+
</programlisting>
88109
</para>
89110
</chapter>
90111

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

Lines changed: 3 additions & 21 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.12 2000/04/11 14:43:54 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.13 2000/06/09 01:43:57 momjian 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 <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 <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> [ * ]
@@ -175,24 +175,6 @@ ALTER TABLE <replaceable class="PARAMETER">table</replaceable>
175175
The keyword <literal>COLUMN</literal> is noise and can be omitted.
176176
</para>
177177

178-
<para>
179-
<quote>*</quote> following a name of a table indicates that the statement
180-
should be run over that table and all tables below it in the
181-
inheritance hierarchy;
182-
by default, the attribute will not be added to or renamed in any of the subclasses.
183-
184-
This should always be done when adding or modifying an attribute in a
185-
superclass. If it is not, queries on the inheritance hierarchy
186-
such as
187-
188-
<programlisting>
189-
SELECT <replaceable>NewColumn</replaceable> FROM <replaceable>SuperClass</replaceable>*
190-
</programlisting>
191-
192-
will not work because the subclasses will be missing an attribute
193-
found in the superclass.
194-
</para>
195-
196178
<para>
197179
In the current implementation, default and constraint clauses for the
198180
new column will be ignored. You can use the <literal>SET DEFAULT</literal>

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

Lines changed: 7 additions & 7 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.29 2000/05/02 20:02:03 thomas Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v 1.30 2000/06/09 01:43:57 momjian Exp $
33
Postgres documentation
44
-->
55

@@ -31,7 +31,7 @@ CREATE [ TEMPORARY | TEMP ] TABLE <replaceable class="PARAMETER">table</replacea
3131
[, PRIMARY KEY ( <replaceable class="PARAMETER">column</replaceable> [, ...] ) ]
3232
[, CHECK ( <replaceable class="PARAMETER">condition</replaceable> ) ]
3333
[, <replaceable>table_constraint_clause</replaceable> ]
34-
) [INHERITS (<replaceable>inherited_table</replaceable> [, ...] ) ]
34+
) [UNDER<replaceable>inherited_table</replaceable> [, ...] ]
3535
</synopsis>
3636

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

132132
<varlistentry>
133-
<term>INHERITS <replaceable class="PARAMETER">inherited_table</replaceable></term>
133+
<term>UNDER <replaceable class="PARAMETER">inherited_table</replaceable></term>
134134
<listitem>
135135
<para>
136-
The optionalINHERITS clause specifies a collection of table
136+
The optionalUNDER clause specifies a collection of table
137137
names from which this table automatically inherits all fields.
138138
If any inherited field name appears more than once,
139139
<productname>Postgres</productname>
@@ -229,7 +229,7 @@ ERROR: DEFAULT: type mismatched
229229
</para>
230230

231231
<para>
232-
The optionalINHERITS
232+
The optionalUNDER
233233
clause specifies a collection of class names from which this class
234234
automatically inherits all fields. If any inherited field name
235235
appears more than once, Postgres reports an error. Postgres automatically
@@ -1838,8 +1838,8 @@ CREATE TABLE distributors (
18381838
Notes
18391839
</title>
18401840
<para>
1841-
CREATE TABLE/INHERITS isa <productname>Postgres</productname>
1842-
language extension.
1841+
CREATE TABLE/UNDER isdefined by SQL3. Multiple inheritance is a
1842+
<productname>Postgres</productname>language extension.
18431843
</para>
18441844
</refsect2>
18451845

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp