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

Commit337b22c

Browse files
committed
Code review for DOMAIN patch.
1 parent251282d commit337b22c

37 files changed

+859
-840
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 53 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
Documentation of the system catalogs, directed toward PostgreSQL developers
3-
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.34 2002/03/19 02:18:10 momjian Exp $
3+
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.35 2002/03/20 19:43:24 tgl Exp $
44
-->
55

66
<chapter id="catalogs">
@@ -2274,7 +2274,8 @@
22742274
This catalog stores information about datatypes. Scalar types
22752275
(<quote>base types</>) are created with <command>CREATE TYPE</command>.
22762276
A complex type is also created for each table in the database, to
2277-
represent the row structure of the table.
2277+
represent the row structure of the table. It is also possible to create
2278+
derived types with <command>CREATE DOMAIN</command>.
22782279
</para>
22792280

22802281
<table>
@@ -2345,11 +2346,10 @@
23452346
<entry></entry>
23462347
<entry>
23472348
<structfield>typtype</structfield> is <literal>b</literal> for
2348-
a base type and <literal>c</literal> for a complex type (i.e.,
2349-
a table's row type). If <structfield>typtype</structfield> is
2350-
<literal>c</literal>, <structfield>typrelid</structfield> is
2351-
the OID of the type's entry in
2352-
<structname>pg_class</structname>.
2349+
a base type, <literal>c</literal> for a complex type (i.e.,
2350+
a table's row type), or <literal>d</literal> for a derived type (i.e.,
2351+
a domain). See also <structfield>typrelid</structfield>
2352+
and <structfield>typbasetype</structfield>.
23532353
</entry>
23542354
</row>
23552355

@@ -2382,6 +2382,7 @@
23822382
the <structfield>pg_class</structfield> entry that defines the
23832383
corresponding table. A table could theoretically be used as a
23842384
composite data type, but this is not fully functional.
2385+
Zero for non-complex types.
23852386
</entry>
23862387
</row>
23872388

@@ -2511,38 +2512,53 @@
25112512
</row>
25122513

25132514
<row>
2514-
<entry>typbasetype</entry>
2515-
<entry><type>oid</type></entry>
2515+
<entry>typnotnull</entry>
2516+
<entry><type>bool</type></entry>
25162517
<entry></entry>
25172518
<entry><para>
2518-
<structfield>typbasetype</structfield>is the type that this one is based
2519-
on.Normally references the domainsparent type, and is 0 otherwise.
2519+
<structfield>typnotnull</structfield>represents a NOT NULL
2520+
constraint on a type.Presently used for domainsonly.
25202521
</para></entry>
25212522
</row>
25222523

2523-
<row>
2524-
<entry>typnotnull</entry>
2525-
<entry><type>boolean</type></entry>
2526-
<entry></entry>
2527-
<entry><para>
2528-
<structfield>typnotnull</structfield> represents a NOT NULL
2529-
constraint on a type. Used for domains only.
2530-
</para></entry>
2531-
</row>
2524+
<row>
2525+
<entry>typbasetype</entry>
2526+
<entry><type>oid</type></entry>
2527+
<entry>pg_type.oid</entry>
2528+
<entry><para>
2529+
If this is a derived type (see <structfield>typtype</structfield>),
2530+
then <structfield>typbasetype</structfield> identifies
2531+
the type that this one is based on. Zero if not a derived type.
2532+
</para></entry>
2533+
</row>
25322534

25332535
<row>
2534-
<entry>typmod</entry>
2535-
<entry><type>integer</type></entry>
2536+
<entry>typtypmod</entry>
2537+
<entry><type>int4</type></entry>
25362538
<entry></entry>
25372539
<entry><para>
2538-
<structfield>typmod</structfield> records type-specific data
2540+
<structfield>typtypmod</structfield> records type-specific data
25392541
supplied at table creation time (for example, the maximum
25402542
length of a <type>varchar</type> column). It is passed to
25412543
type-specific input and output functions as the third
25422544
argument. The value will generally be -1 for types that do not
2543-
need typmod. This data is copied to
2544-
<structfield>pg_attribute.atttypmod</structfield> on creation
2545-
of a table using a domain as it's field type.
2545+
need typmod. This value is copied to
2546+
<structfield>pg_attribute.atttypmod</structfield> when
2547+
creating a column of a domain type.
2548+
</para></entry>
2549+
</row>
2550+
2551+
<row>
2552+
<entry>typndims</entry>
2553+
<entry><type>int4</type></entry>
2554+
<entry></entry>
2555+
<entry><para>
2556+
<structfield>typndims</structfield> is the number of array dimensions
2557+
for a domain that is an array. (The array element type is
2558+
typbasetype.) Zero for non-domains and non-array domains.
2559+
This value is copied to
2560+
<structfield>pg_attribute.attndims</structfield> when
2561+
creating a column of a domain type.
25462562
</para></entry>
25472563
</row>
25482564

@@ -2551,9 +2567,9 @@
25512567
<entry><type>text</type></entry>
25522568
<entry></entry>
25532569
<entry><para>
2554-
<structfield>typdefaultbin</structfield> is NULL for types without a
2555-
default value. If it's not NULL, it contains the internal string
2556-
representation of the default expression node.
2570+
If<structfield>typdefaultbin</> isnotNULL, it is the nodeToString
2571+
representation of a default expression for the type. Currently this is
2572+
only used for domains.
25572573
</para></entry>
25582574
</row>
25592575

@@ -2562,9 +2578,14 @@
25622578
<entry><type>text</type></entry>
25632579
<entry></entry>
25642580
<entry><para>
2565-
<structfield>typdefault</structfield> is NULL for types without a
2566-
default value. If it's not NULL, it contains the external string
2567-
representation of the type's default value.
2581+
<structfield>typdefault</> is NULL if the type has no associated
2582+
default value. If <structfield>typdefaultbin</> is not NULL,
2583+
<structfield>typdefault</> must contain a human-readable version of the
2584+
default expression represented by <structfield>typdefaultbin</>. If
2585+
<structfield>typdefaultbin</> is NULL and <structfield>typdefault</> is
2586+
not, then <structfield>typdefault</> is the external representation of
2587+
the type's default value, which may be fed to the type's input
2588+
converter to produce a constant.
25682589
</para></entry>
25692590
</row>
25702591
</tbody>

‎doc/src/sgml/ref/create_domain.sgml

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_domain.sgml,v 1.3 2002/03/19 02:18:13 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_domain.sgml,v 1.4 2002/03/20 19:43:28 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -23,13 +23,14 @@ PostgreSQL documentation
2323
<date>2002-02-24</date>
2424
</refsynopsisdivinfo>
2525
<synopsis>
26-
CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> <replaceable class="parameter">data_type</replaceable> [ DEFAULT <replaceable>default_expr</> ] [ <replaceable class="PARAMETER">column_constraint</replaceable> [, ... ] ]
26+
CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> [AS] <replaceable class="parameter">data_type</replaceable>
27+
[ DEFAULT <replaceable>default_expr</> ]
28+
[ <replaceable class="PARAMETER">constraint</replaceable> [, ... ] ]
29+
30+
where <replaceable class="PARAMETER">constraint</replaceable> is:
31+
2732
[ CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ]
28-
{ NOT NULL | NULL <!-- | UNIQUE | PRIMARY KEY |
29-
CHECK (<replaceable class="PARAMETER">expression</replaceable>) |
30-
REFERENCES <replaceable class="PARAMETER">reftable</replaceable> [ ( <replaceable class="PARAMETER">refcolumn</replaceable> ) ] [ MATCH FULL | MATCH PARTIAL ]
31-
[ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ] --> }
32-
<!-- [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] -->
33+
{ NOT NULL | NULL }
3334
</synopsis>
3435

3536
<refsect2 id="R2-SQL-CREATEDOMAIN-1">
@@ -67,23 +68,26 @@ CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> <replaceab
6768
<replaceable>default_expr</replaceable></literal></term>
6869
<listitem>
6970
<para>
70-
The <literal>DEFAULT</> clauseassigns a default data value for
71-
thecolumn whose column definition it appears within. The value
72-
is any variable-free expression (subselectsand cross-references
73-
to other columns in the current table are not allowed).The
71+
The <literal>DEFAULT</> clausespecifies a default value for
72+
columns ofthedomain data type. The value
73+
is any variable-free expression (butsubselectsare not allowed).
74+
The
7475
data type of the default expression must match the data type of the
7576
domain.
7677
</para>
7778

7879
<para>
7980
The default expression will be used in any insert operation that
80-
does not specify a value for thedomain. If there is no default
81+
does not specify a value for thecolumn. If there is no default
8182
for a domain, then the default is NULL.
8283
</para>
8384

8485
<note>
8586
<para>
86-
The default of a column will be tested before that of the domain.
87+
If a default value is specified for a particular column, it
88+
overrides any default associated with the domain. In turn,
89+
the domain default overrides any default value associated with
90+
the underlying data type.
8791
</para>
8892
</note>
8993
</listitem>
@@ -93,7 +97,7 @@ CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> <replaceab
9397
<term><literal>CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable></literal></term>
9498
<listitem>
9599
<para>
96-
An optional name for adomain. If not specified,
100+
An optional name for aconstraint. If not specified,
97101
the system generates a name.
98102
</para>
99103
</listitem>
@@ -103,7 +107,7 @@ CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> <replaceab
103107
<term><literal>NOT NULL</></term>
104108
<listitem>
105109
<para>
106-
The column isnot allowed tocontain NULL values. This is
110+
Values of this domain arenot allowed tobe NULL. This is
107111
equivalent to the column constraint <literal>CHECK (<replaceable
108112
class="PARAMETER">column</replaceable> NOT NULL)</literal>.
109113
</para>
@@ -114,7 +118,7 @@ CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> <replaceab
114118
<term><literal>NULL</></term>
115119
<listitem>
116120
<para>
117-
The column isallowed tocontain NULL values. This is the default.
121+
Values of this domain areallowed tobe NULL. This is the default.
118122
</para>
119123

120124
<para>
@@ -175,7 +179,7 @@ CREATE DOMAIN
175179
Domains are useful for abstracting common fields between tables into
176180
a single location for maintenance. An email address column may be used
177181
in several tables, all with the same properties. Define a domain and
178-
use that rather than setting up eachtables constraints individually.
182+
use that rather than setting up eachtable's constraints individually.
179183
</para>
180184
</refsect1>
181185

@@ -195,9 +199,9 @@ CREATE TABLE countrylist (id INT4, country country_code);
195199
<title>Compatibility</title>
196200

197201
<para>
198-
This <command>CREATE DOMAIN</command> command is a
199-
<productname>PostgreSQL</productname> extension. CHECKand FOREIGN KEY
200-
constraints are currently unsupported.
202+
SQL99 definesCREATE DOMAIN, but says that the only allowed constraint
203+
type is CHECK constraints. CHECKconstraints for domains are not yet
204+
supported by <productname>PostgreSQL</productname>.
201205
</para>
202206
</refsect1>
203207

‎doc/src/sgml/ref/drop_domain.sgml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_domain.sgml,v 1.3 2002/03/19 02:18:13 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_domain.sgml,v 1.4 2002/03/20 19:43:28 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -23,7 +23,7 @@ PostgreSQL documentation
2323
<date>1999-07-20</date>
2424
</refsynopsisdivinfo>
2525
<synopsis>
26-
DROP DOMAIN <replaceable class="PARAMETER">domainname</replaceable> [, ...]
26+
DROP DOMAIN <replaceable class="PARAMETER">domainname</replaceable> [, ...] [ CASCADE | RESTRICT ]
2727
</synopsis>
2828

2929
<refsect2 id="R2-SQL-DROPDOMAIN-1">
@@ -43,6 +43,25 @@ DROP DOMAIN <replaceable class="PARAMETER">domainname</replaceable> [, ...]
4343
</para>
4444
</listitem>
4545
</varlistentry>
46+
47+
<varlistentry>
48+
<term><literal>CASCADE</></term>
49+
<listitem>
50+
<para>
51+
Automatically drop objects that depend on the domain. This
52+
behavior is not currently supported.
53+
</para>
54+
</listitem>
55+
</varlistentry>
56+
57+
<varlistentry>
58+
<term><literal>RESTRICT</></term>
59+
<listitem>
60+
<para>
61+
Do not drop dependent objects. This is the default.
62+
</para>
63+
</listitem>
64+
</varlistentry>
4665
</variablelist>
4766
</para>
4867
</refsect2>
@@ -117,7 +136,7 @@ ERROR: RemoveDomain: type '<replaceable class="parameter">domainname</replaceab
117136
To remove the <type>box</type> domain:
118137

119138
<programlisting>
120-
DROP DOMAIN box RESTRICT;
139+
DROP DOMAIN box;
121140
</programlisting>
122141
</para>
123142
</refsect1>
@@ -134,9 +153,8 @@ DROP DOMAIN box RESTRICT;
134153
<synopsis>
135154
DROP DOMAIN <replaceable>name</replaceable> { CASCADE | RESTRICT }
136155
</synopsis>
137-
<productname>PostgreSQL</productname> enforces the existance of
138-
RESTRICT or CASCADE but ignores their enforcement against the
139-
system tables.
156+
<productname>PostgreSQL</productname> accepts only the RESTRICT
157+
option, and currently does not check for existence of dependent objects.
140158
</para>
141159
</refsect1>
142160

‎doc/src/sgml/ref/psql-ref.sgml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.64 2002/03/19 02:32:19 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.65 2002/03/20 19:43:30 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -419,21 +419,10 @@ testdb=>
419419
<term><literal>\dD</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term>
420420
<listitem>
421421
<para>
422-
Lists all database domains.
423-
</para>
424-
425-
<para>
426-
Descriptions for objects can be generated with the <command>COMMENT ON</command>
427-
<acronym>SQL</acronym> command.
428-
</para>
429-
430-
<note>
431-
<para>
432-
<productname>PostgreSQL</productname> stores the object descriptions in the
433-
pg_description system table.
422+
Lists all available domains (derived types).
423+
If <replaceable class="parameter">pattern</replaceable>
424+
(a regular expression) is specified, only matching domains are shown.
434425
</para>
435-
</note>
436-
437426
</listitem>
438427
</varlistentry>
439428

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp