Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
337b22cb
Commit
337b22cb
authored
Mar 20, 2002
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code review for DOMAIN patch.
parent
251282d4
Changes
37
Show whitespace changes
Inline
Side-by-side
Showing
37 changed files
with
859 additions
and
840 deletions
+859
-840
doc/src/sgml/catalogs.sgml
doc/src/sgml/catalogs.sgml
+53
-32
doc/src/sgml/ref/create_domain.sgml
doc/src/sgml/ref/create_domain.sgml
+24
-20
doc/src/sgml/ref/drop_domain.sgml
doc/src/sgml/ref/drop_domain.sgml
+24
-6
doc/src/sgml/ref/psql-ref.sgml
doc/src/sgml/ref/psql-ref.sgml
+4
-15
src/backend/catalog/heap.c
src/backend/catalog/heap.c
+23
-31
src/backend/catalog/pg_aggregate.c
src/backend/catalog/pg_aggregate.c
+3
-4
src/backend/catalog/pg_proc.c
src/backend/catalog/pg_proc.c
+4
-4
src/backend/catalog/pg_type.c
src/backend/catalog/pg_type.c
+13
-26
src/backend/commands/creatinh.c
src/backend/commands/creatinh.c
+16
-27
src/backend/commands/define.c
src/backend/commands/define.c
+83
-153
src/backend/commands/indexcmds.c
src/backend/commands/indexcmds.c
+4
-6
src/backend/commands/remove.c
src/backend/commands/remove.c
+4
-12
src/backend/executor/nodeAgg.c
src/backend/executor/nodeAgg.c
+2
-3
src/backend/nodes/copyfuncs.c
src/backend/nodes/copyfuncs.c
+2
-2
src/backend/nodes/equalfuncs.c
src/backend/nodes/equalfuncs.c
+3
-1
src/backend/nodes/makefuncs.c
src/backend/nodes/makefuncs.c
+17
-10
src/backend/optimizer/path/indxpath.c
src/backend/optimizer/path/indxpath.c
+3
-3
src/backend/optimizer/prep/preptlist.c
src/backend/optimizer/prep/preptlist.c
+60
-84
src/backend/parser/gram.y
src/backend/parser/gram.y
+20
-35
src/backend/parser/parse_coerce.c
src/backend/parser/parse_coerce.c
+187
-91
src/backend/parser/parse_expr.c
src/backend/parser/parse_expr.c
+3
-4
src/backend/parser/parse_func.c
src/backend/parser/parse_func.c
+4
-8
src/backend/parser/parse_oper.c
src/backend/parser/parse_oper.c
+4
-8
src/backend/tcop/utility.c
src/backend/tcop/utility.c
+3
-3
src/backend/utils/adt/format_type.c
src/backend/utils/adt/format_type.c
+8
-26
src/backend/utils/cache/lsyscache.c
src/backend/utils/cache/lsyscache.c
+87
-33
src/bin/psql/describe.c
src/bin/psql/describe.c
+2
-2
src/include/catalog/catversion.h
src/include/catalog/catversion.h
+2
-2
src/include/catalog/heap.h
src/include/catalog/heap.h
+6
-6
src/include/catalog/pg_attribute.h
src/include/catalog/pg_attribute.h
+5
-5
src/include/catalog/pg_type.h
src/include/catalog/pg_type.h
+120
-115
src/include/nodes/makefuncs.h
src/include/nodes/makefuncs.h
+3
-1
src/include/nodes/parsenodes.h
src/include/nodes/parsenodes.h
+16
-21
src/include/parser/parse_coerce.h
src/include/parser/parse_coerce.h
+2
-34
src/include/utils/lsyscache.h
src/include/utils/lsyscache.h
+3
-2
src/test/regress/expected/domain.out
src/test/regress/expected/domain.out
+33
-3
src/test/regress/sql/domain.sql
src/test/regress/sql/domain.sql
+9
-2
No files found.
doc/src/sgml/catalogs.sgml
View file @
337b22cb
<!--
<!--
Documentation of the system catalogs, directed toward PostgreSQL developers
Documentation of the system catalogs, directed toward PostgreSQL developers
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.3
4 2002/03/19 02:18:10 momjian
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/catalogs.sgml,v 2.3
5 2002/03/20 19:43:24 tgl
Exp $
-->
-->
<chapter id="catalogs">
<chapter id="catalogs">
...
@@ -2274,7 +2274,8 @@
...
@@ -2274,7 +2274,8 @@
This catalog stores information about datatypes. Scalar types
This catalog stores information about datatypes. Scalar types
(<quote>base types</>) are created with <command>CREATE TYPE</command>.
(<quote>base types</>) are created with <command>CREATE TYPE</command>.
A complex type is also created for each table in the database, to
A complex type is also created for each table in the database, to
represent the row structure of the table.
represent the row structure of the table. It is also possible to create
derived types with <command>CREATE DOMAIN</command>.
</para>
</para>
<table>
<table>
...
@@ -2345,11 +2346,10 @@
...
@@ -2345,11 +2346,10 @@
<entry></entry>
<entry></entry>
<entry>
<entry>
<structfield>typtype</structfield> is <literal>b</literal> for
<structfield>typtype</structfield> is <literal>b</literal> for
a base type and <literal>c</literal> for a complex type (i.e.,
a base type, <literal>c</literal> for a complex type (i.e.,
a table's row type). If <structfield>typtype</structfield> is
a table's row type), or <literal>d</literal> for a derived type (i.e.,
<literal>c</literal>, <structfield>typrelid</structfield> is
a domain). See also <structfield>typrelid</structfield>
the OID of the type's entry in
and <structfield>typbasetype</structfield>.
<structname>pg_class</structname>.
</entry>
</entry>
</row>
</row>
...
@@ -2382,6 +2382,7 @@
...
@@ -2382,6 +2382,7 @@
the <structfield>pg_class</structfield> entry that defines the
the <structfield>pg_class</structfield> entry that defines the
corresponding table. A table could theoretically be used as a
corresponding table. A table could theoretically be used as a
composite data type, but this is not fully functional.
composite data type, but this is not fully functional.
Zero for non-complex types.
</entry>
</entry>
</row>
</row>
...
@@ -2511,38 +2512,53 @@
...
@@ -2511,38 +2512,53 @@
</row>
</row>
<row>
<row>
<entry>typ
basetype
</entry>
<entry>typ
notnull
</entry>
<entry><type>
oid
</type></entry>
<entry><type>
bool
</type></entry>
<entry></entry>
<entry></entry>
<entry><para>
<entry><para>
<structfield>typ
basetype</structfield> is the type that this one is based
<structfield>typ
notnull</structfield> represents a NOT NULL
on. Normally references the domains parent type, and is 0 otherwise
.
constraint on a type. Presently used for domains only
.
</para></entry>
</para></entry>
</row>
</row>
<row>
<row>
<entry>typnotnull
</entry>
<entry>typbasetype
</entry>
<entry><type>boolean
</type></entry>
<entry><type>oid
</type></entry>
<entry>
</entry>
<entry>pg_type.oid
</entry>
<entry><para>
<entry><para>
<structfield>typnotnull</structfield> represents a NOT NULL
If this is a derived type (see <structfield>typtype</structfield>),
constraint on a type. Used for domains only.
then <structfield>typbasetype</structfield> identifies
the type that this one is based on. Zero if not a derived type.
</para></entry>
</para></entry>
</row>
</row>
<row>
<row>
<entry>typmod</entry>
<entry>typ
typ
mod</entry>
<entry><type>int
eger
</type></entry>
<entry><type>int
4
</type></entry>
<entry></entry>
<entry></entry>
<entry><para>
<entry><para>
<structfield>typmod</structfield> records type-specific data
<structfield>typ
typ
mod</structfield> records type-specific data
supplied at table creation time (for example, the maximum
supplied at table creation time (for example, the maximum
length of a <type>varchar</type> column). It is passed to
length of a <type>varchar</type> column). It is passed to
type-specific input and output functions as the third
type-specific input and output functions as the third
argument. The value will generally be -1 for types that do not
argument. The value will generally be -1 for types that do not
need typmod. This data is copied to
need typmod. This value is copied to
<structfield>pg_attribute.atttypmod</structfield> on creation
<structfield>pg_attribute.atttypmod</structfield> when
of a table using a domain as it's field type.
creating a column of a domain type.
</para></entry>
</row>
<row>
<entry>typndims</entry>
<entry><type>int4</type></entry>
<entry></entry>
<entry><para>
<structfield>typndims</structfield> is the number of array dimensions
for a domain that is an array. (The array element type is
typbasetype.) Zero for non-domains and non-array domains.
This value is copied to
<structfield>pg_attribute.attndims</structfield> when
creating a column of a domain type.
</para></entry>
</para></entry>
</row>
</row>
...
@@ -2551,9 +2567,9 @@
...
@@ -2551,9 +2567,9 @@
<entry><type>text</type></entry>
<entry><type>text</type></entry>
<entry></entry>
<entry></entry>
<entry><para>
<entry><para>
<structfield>typdefaultbin</structfield> is NULL for types without a
If <structfield>typdefaultbin</> is not NULL, it is the nodeToString
default value. If it's not NULL, it contains the internal string
representation of a default expression for the type. Currently this is
representation of the default expression node
.
only used for domains
.
</para></entry>
</para></entry>
</row>
</row>
...
@@ -2562,9 +2578,14 @@
...
@@ -2562,9 +2578,14 @@
<entry><type>text</type></entry>
<entry><type>text</type></entry>
<entry></entry>
<entry></entry>
<entry><para>
<entry><para>
<structfield>typdefault</structfield> is NULL for types without a
<structfield>typdefault</> is NULL if the type has no associated
default value. If it's not NULL, it contains the external string
default value. If <structfield>typdefaultbin</> is not NULL,
representation of the type's default value.
<structfield>typdefault</> must contain a human-readable version of the
default expression represented by <structfield>typdefaultbin</>. If
<structfield>typdefaultbin</> is NULL and <structfield>typdefault</> is
not, then <structfield>typdefault</> is the external representation of
the type's default value, which may be fed to the type's input
converter to produce a constant.
</para></entry>
</para></entry>
</row>
</row>
</tbody>
</tbody>
...
...
doc/src/sgml/ref/create_domain.sgml
View file @
337b22cb
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_domain.sgml,v 1.
3 2002/03/19 02:18:13 momjian
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_domain.sgml,v 1.
4 2002/03/20 19:43:28 tgl
Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -23,13 +23,14 @@ PostgreSQL documentation
...
@@ -23,13 +23,14 @@ PostgreSQL documentation
<date>2002-02-24</date>
<date>2002-02-24</date>
</refsynopsisdivinfo>
</refsynopsisdivinfo>
<synopsis>
<synopsis>
CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> <replaceable class="parameter">data_type</replaceable> [ DEFAULT <replaceable>default_expr</> ] [ <replaceable class="PARAMETER">column_constraint</replaceable> [, ... ] ]
CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> [AS] <replaceable class="parameter">data_type</replaceable>
[ DEFAULT <replaceable>default_expr</> ]
[ <replaceable class="PARAMETER">constraint</replaceable> [, ... ] ]
where <replaceable class="PARAMETER">constraint</replaceable> is:
[ CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ]
[ CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ]
{ NOT NULL | NULL <!-- | UNIQUE | PRIMARY KEY |
{ NOT NULL | NULL }
CHECK (<replaceable class="PARAMETER">expression</replaceable>) |
REFERENCES <replaceable class="PARAMETER">reftable</replaceable> [ ( <replaceable class="PARAMETER">refcolumn</replaceable> ) ] [ MATCH FULL | MATCH PARTIAL ]
[ ON DELETE <replaceable class="parameter">action</replaceable> ] [ ON UPDATE <replaceable class="parameter">action</replaceable> ] --> }
<!-- [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] -->
</synopsis>
</synopsis>
<refsect2 id="R2-SQL-CREATEDOMAIN-1">
<refsect2 id="R2-SQL-CREATEDOMAIN-1">
...
@@ -67,23 +68,26 @@ CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> <replaceab
...
@@ -67,23 +68,26 @@ CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> <replaceab
<replaceable>default_expr</replaceable></literal></term>
<replaceable>default_expr</replaceable></literal></term>
<listitem>
<listitem>
<para>
<para>
The <literal>DEFAULT</> clause
assigns a default data
value for
The <literal>DEFAULT</> clause
specifies a default
value for
the column whose column definition it appears within
. The value
columns of the domain data type
. The value
is any variable-free expression (
subselects and cross-references
is any variable-free expression (
but subselects are not allowed).
to other columns in the current table are not allowed).
The
The
data type of the default expression must match the data type of the
data type of the default expression must match the data type of the
domain.
domain.
</para>
</para>
<para>
<para>
The default expression will be used in any insert operation that
The default expression will be used in any insert operation that
does not specify a value for the
domai
n. If there is no default
does not specify a value for the
colum
n. If there is no default
for a domain, then the default is NULL.
for a domain, then the default is NULL.
</para>
</para>
<note>
<note>
<para>
<para>
The default of a column will be tested before that of the domain.
If a default value is specified for a particular column, it
overrides any default associated with the domain. In turn,
the domain default overrides any default value associated with
the underlying data type.
</para>
</para>
</note>
</note>
</listitem>
</listitem>
...
@@ -93,7 +97,7 @@ CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> <replaceab
...
@@ -93,7 +97,7 @@ CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> <replaceab
<term><literal>CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable></literal></term>
<term><literal>CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable></literal></term>
<listitem>
<listitem>
<para>
<para>
An optional name for a
domain
. If not specified,
An optional name for a
constraint
. If not specified,
the system generates a name.
the system generates a name.
</para>
</para>
</listitem>
</listitem>
...
@@ -103,7 +107,7 @@ CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> <replaceab
...
@@ -103,7 +107,7 @@ CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> <replaceab
<term><literal>NOT NULL</></term>
<term><literal>NOT NULL</></term>
<listitem>
<listitem>
<para>
<para>
The column is not allowed to contain NULL values
. This is
Values of this domain are not allowed to be NULL
. This is
equivalent to the column constraint <literal>CHECK (<replaceable
equivalent to the column constraint <literal>CHECK (<replaceable
class="PARAMETER">column</replaceable> NOT NULL)</literal>.
class="PARAMETER">column</replaceable> NOT NULL)</literal>.
</para>
</para>
...
@@ -114,7 +118,7 @@ CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> <replaceab
...
@@ -114,7 +118,7 @@ CREATE DOMAIN <replaceable class="parameter">domainname</replaceable> <replaceab
<term><literal>NULL</></term>
<term><literal>NULL</></term>
<listitem>
<listitem>
<para>
<para>
The column is allowed to contain NULL values.
This is the default.
Values of this domain are allowed to be NULL.
This is the default.
</para>
</para>
<para>
<para>
...
@@ -175,7 +179,7 @@ CREATE DOMAIN
...
@@ -175,7 +179,7 @@ CREATE DOMAIN
Domains are useful for abstracting common fields between tables into
Domains are useful for abstracting common fields between tables into
a single location for maintenance. An email address column may be used
a single location for maintenance. An email address column may be used
in several tables, all with the same properties. Define a domain and
in several tables, all with the same properties. Define a domain and
use that rather than setting up each tables constraints individually.
use that rather than setting up each table
'
s constraints individually.
</para>
</para>
</refsect1>
</refsect1>
...
@@ -195,9 +199,9 @@ CREATE TABLE countrylist (id INT4, country country_code);
...
@@ -195,9 +199,9 @@ CREATE TABLE countrylist (id INT4, country country_code);
<title>Compatibility</title>
<title>Compatibility</title>
<para>
<para>
This <command>CREATE DOMAIN</command> command is a
SQL99 defines CREATE DOMAIN, but says that the only allowed constraint
<productname>PostgreSQL</productname> extension. CHECK and FOREIGN KEY
type is CHECK constraints. CHECK constraints for domains are not yet
constraints are currently unsupported
.
supported by <productname>PostgreSQL</productname>
.
</para>
</para>
</refsect1>
</refsect1>
...
...
doc/src/sgml/ref/drop_domain.sgml
View file @
337b22cb
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_domain.sgml,v 1.
3 2002/03/19 02:18:13 momjian
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_domain.sgml,v 1.
4 2002/03/20 19:43:28 tgl
Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -23,7 +23,7 @@ PostgreSQL documentation
...
@@ -23,7 +23,7 @@ PostgreSQL documentation
<date>1999-07-20</date>
<date>1999-07-20</date>
</refsynopsisdivinfo>
</refsynopsisdivinfo>
<synopsis>
<synopsis>
DROP DOMAIN <replaceable class="PARAMETER">domainname</replaceable> [, ...]
DROP DOMAIN <replaceable class="PARAMETER">domainname</replaceable> [, ...]
[ CASCADE | RESTRICT ]
</synopsis>
</synopsis>
<refsect2 id="R2-SQL-DROPDOMAIN-1">
<refsect2 id="R2-SQL-DROPDOMAIN-1">
...
@@ -43,6 +43,25 @@ DROP DOMAIN <replaceable class="PARAMETER">domainname</replaceable> [, ...]
...
@@ -43,6 +43,25 @@ DROP DOMAIN <replaceable class="PARAMETER">domainname</replaceable> [, ...]
</para>
</para>
</listitem>
</listitem>
</varlistentry>
</varlistentry>
<varlistentry>
<term><literal>CASCADE</></term>
<listitem>
<para>
Automatically drop objects that depend on the domain. This
behavior is not currently supported.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>RESTRICT</></term>
<listitem>
<para>
Do not drop dependent objects. This is the default.
</para>
</listitem>
</varlistentry>
</variablelist>
</variablelist>
</para>
</para>
</refsect2>
</refsect2>
...
@@ -117,7 +136,7 @@ ERROR: RemoveDomain: type '<replaceable class="parameter">domainname</replaceab
...
@@ -117,7 +136,7 @@ ERROR: RemoveDomain: type '<replaceable class="parameter">domainname</replaceab
To remove the <type>box</type> domain:
To remove the <type>box</type> domain:
<programlisting>
<programlisting>
DROP DOMAIN box
RESTRICT
;
DROP DOMAIN box;
</programlisting>
</programlisting>
</para>
</para>
</refsect1>
</refsect1>
...
@@ -134,9 +153,8 @@ DROP DOMAIN box RESTRICT;
...
@@ -134,9 +153,8 @@ DROP DOMAIN box RESTRICT;
<synopsis>
<synopsis>
DROP DOMAIN <replaceable>name</replaceable> { CASCADE | RESTRICT }
DROP DOMAIN <replaceable>name</replaceable> { CASCADE | RESTRICT }
</synopsis>
</synopsis>
<productname>PostgreSQL</productname> enforces the existance of
<productname>PostgreSQL</productname> accepts only the RESTRICT
RESTRICT or CASCADE but ignores their enforcement against the
option, and currently does not check for existence of dependent objects.
system tables.
</para>
</para>
</refsect1>
</refsect1>
...
...
doc/src/sgml/ref/psql-ref.sgml
View file @
337b22cb
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.6
4 2002/03/19 02:32:19 momjian
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.6
5 2002/03/20 19:43:30 tgl
Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -419,21 +419,10 @@ testdb=>
...
@@ -419,21 +419,10 @@ testdb=>
<term><literal>\dD</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term>
<term><literal>\dD</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term>
<listitem>
<listitem>
<para>
<para>
Lists all database domains.
Lists all available domains (derived types).
</para>
If <replaceable class="parameter">pattern</replaceable>
(a regular expression) is specified, only matching domains are shown.
<para>
Descriptions for objects can be generated with the <command>COMMENT ON</command>
<acronym>SQL</acronym> command.
</para>
<note>
<para>
<productname>PostgreSQL</productname> stores the object descriptions in the
pg_description system table.
</para>
</para>
</note>
</listitem>
</listitem>
</varlistentry>
</varlistentry>
...
...
src/backend/catalog/heap.c
View file @
337b22cb
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.18
8 2002/03/19 02:58:19 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.18
9 2002/03/20 19:43:34 tgl
Exp $
*
*
*
*
* INTERFACE ROUTINES
* INTERFACE ROUTINES
...
@@ -705,7 +705,7 @@ AddNewRelationType(char *typeName, Oid new_rel_oid, Oid new_type_oid)
...
@@ -705,7 +705,7 @@ AddNewRelationType(char *typeName, Oid new_rel_oid, Oid new_type_oid)
true
,
/* passed by value */
true
,
/* passed by value */
'i'
,
/* default alignment - same as for OID */
'i'
,
/* default alignment - same as for OID */
'p'
,
/* Not TOASTable */
'p'
,
/* Not TOASTable */
-
1
,
/*
Type mod length
*/
-
1
,
/*
typmod
*/
0
,
/* array dimensions for typBaseType */
0
,
/* array dimensions for typBaseType */
false
);
/* Type NOT NULL */
false
);
/* Type NOT NULL */
}
}
...
@@ -1589,10 +1589,7 @@ AddRelationRawConstraints(Relation rel,
...
@@ -1589,10 +1589,7 @@ AddRelationRawConstraints(Relation rel,
RangeTblEntry
*
rte
;
RangeTblEntry
*
rte
;
int
numchecks
;
int
numchecks
;
List
*
listptr
;
List
*
listptr
;
Node
*
expr
;
/* Probably shouldn't be null by default */
Node
*
expr
=
NULL
;
/*
/*
* Get info about existing constraints.
* Get info about existing constraints.
...
@@ -1624,17 +1621,11 @@ AddRelationRawConstraints(Relation rel,
...
@@ -1624,17 +1621,11 @@ AddRelationRawConstraints(Relation rel,
foreach
(
listptr
,
rawColDefaults
)
foreach
(
listptr
,
rawColDefaults
)
{
{
RawColumnDefault
*
colDef
=
(
RawColumnDefault
*
)
lfirst
(
listptr
);
RawColumnDefault
*
colDef
=
(
RawColumnDefault
*
)
lfirst
(
listptr
);
Form_pg_attribute
atp
=
rel
->
rd_att
->
attrs
[
colDef
->
attnum
-
1
];
Form_pg_attribute
atp
=
rel
->
rd_att
->
attrs
[
colDef
->
attnum
-
1
];
expr
=
cookDefault
(
pstate
,
colDef
->
raw_default
expr
=
cookDefault
(
pstate
,
colDef
->
raw_default
,
,
atp
->
atttypid
,
atp
->
atttypmod
atp
->
atttypid
,
atp
->
atttypmod
,
,
NameStr
(
atp
->
attname
));
NameStr
(
atp
->
attname
));
/*
* OK, store it.
*/
StoreAttrDefault
(
rel
,
colDef
->
attnum
,
nodeToString
(
expr
));
StoreAttrDefault
(
rel
,
colDef
->
attnum
,
nodeToString
(
expr
));
}
}
...
@@ -1646,7 +1637,6 @@ AddRelationRawConstraints(Relation rel,
...
@@ -1646,7 +1637,6 @@ AddRelationRawConstraints(Relation rel,
{
{
Constraint
*
cdef
=
(
Constraint
*
)
lfirst
(
listptr
);
Constraint
*
cdef
=
(
Constraint
*
)
lfirst
(
listptr
);
char
*
ccname
;
char
*
ccname
;
Node
*
expr
;
if
(
cdef
->
contype
!=
CONSTR_CHECK
||
cdef
->
raw_expr
==
NULL
)
if
(
cdef
->
contype
!=
CONSTR_CHECK
||
cdef
->
raw_expr
==
NULL
)
continue
;
continue
;
...
@@ -1851,17 +1841,21 @@ SetRelationNumChecks(Relation rel, int numchecks)
...
@@ -1851,17 +1841,21 @@ SetRelationNumChecks(Relation rel, int numchecks)
* Take a raw default and convert it to a cooked format ready for
* Take a raw default and convert it to a cooked format ready for
* storage.
* storage.
*
*
* Parse state, attypid, attypmod and attname are required for
* Parse state should be set up to recognize any vars that might appear
* CoerceTargetExpr() and more importantly transformExpr().
* in the expression. (Even though we plan to reject vars, it's more
* user-friendly to give the correct error message than "unknown var".)
*
* If atttypid is not InvalidOid, check that the expression is coercible
* to the specified type. atttypmod is needed in this case, and attname
* is used in the error message if any.
*/
*/
Node
*
Node
*
cookDefault
(
ParseState
*
pstate
,
cookDefault
(
ParseState
*
pstate
,
Node
*
raw_default
,
Node
*
raw_default
,
Oid
atttypid
,
Oid
atttypid
,
int32
atttypmod
,
int32
atttypmod
,
char
*
attname
)
{
char
*
attname
)
{
Oid
type_id
;
Node
*
expr
;
Node
*
expr
;
Assert
(
raw_default
!=
NULL
);
Assert
(
raw_default
!=
NULL
);
...
@@ -1896,15 +1890,14 @@ cookDefault(ParseState *pstate,
...
@@ -1896,15 +1890,14 @@ cookDefault(ParseState *pstate,
* will actually do the coercion, to ensure we don't accept an
* will actually do the coercion, to ensure we don't accept an
* unusable default expression.
* unusable default expression.
*/
*/
type_id
=
exprType
(
expr
);
if
(
OidIsValid
(
atttypid
))
if
(
type_id
!=
InvalidOid
&&
atttypid
!=
InvalidOid
)
{
{
if
(
type_id
!=
atttypid
)
{
Oid
type_id
=
exprType
(
expr
);
/* Try coercing to the base type of the domain if available */
if
(
type_id
!=
atttypid
)
{
if
(
CoerceTargetExpr
(
pstate
,
expr
,
type_id
,
if
(
CoerceTargetExpr
(
pstate
,
expr
,
type_id
,
getBaseType
(
atttypid
),
atttypid
,
atttypmod
)
==
NULL
)
atttypmod
)
==
NULL
)
{
elog
(
ERROR
,
"Column
\"
%s
\"
is of type %s"
elog
(
ERROR
,
"Column
\"
%s
\"
is of type %s"
" but default expression is of type %s"
" but default expression is of type %s"
"
\n\t
You will need to rewrite or cast the expression"
,
"
\n\t
You will need to rewrite or cast the expression"
,
...
@@ -1913,7 +1906,6 @@ cookDefault(ParseState *pstate,
...
@@ -1913,7 +1906,6 @@ cookDefault(ParseState *pstate,
format_type_be
(
type_id
));
format_type_be
(
type_id
));
}
}
}
}
}
/*
/*
* Might as well try to reduce any constant expressions.
* Might as well try to reduce any constant expressions.
...
...
src/backend/catalog/pg_aggregate.c
View file @
337b22cb
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.4
0 2001/10/25 05:49:23 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.4
1 2002/03/20 19:43:35 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -135,14 +135,13 @@ AggregateCreate(char *aggName,
...
@@ -135,14 +135,13 @@ AggregateCreate(char *aggName,
/*
/*
* If the transfn is strict and the initval is NULL, make sure input
* If the transfn is strict and the initval is NULL, make sure input
* type and transtype are the same (or at least binary-
compatible),
* type and transtype are the same (or at least binary-compatible),
* so that it's OK to use the first input value as the initial
* so that it's OK to use the first input value as the initial
* transValue.
* transValue.
*/
*/
if
(
proc
->
proisstrict
&&
agginitval
==
NULL
)
if
(
proc
->
proisstrict
&&
agginitval
==
NULL
)
{
{
if
(
basetype
!=
transtype
&&
if
(
!
IsBinaryCompatible
(
basetype
,
transtype
))
!
IS_BINARY_COMPATIBLE
(
basetype
,
transtype
))
elog
(
ERROR
,
"must not omit initval when transfn is strict and transtype is not compatible with input type"
);
elog
(
ERROR
,
"must not omit initval when transfn is strict and transtype is not compatible with input type"
);
}
}
ReleaseSysCache
(
tup
);
ReleaseSysCache
(
tup
);
...
...
src/backend/catalog/pg_proc.c
View file @
337b22cb
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.6
5 2002/03/06 06:09:26 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.6
6 2002/03/20 19:43:36 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -423,7 +423,7 @@ checkretval(Oid rettype, List *queryTreeList)
...
@@ -423,7 +423,7 @@ checkretval(Oid rettype, List *queryTreeList)
format_type_be
(
rettype
));
format_type_be
(
rettype
));
restype
=
((
TargetEntry
*
)
lfirst
(
tlist
))
->
resdom
->
restype
;
restype
=
((
TargetEntry
*
)
lfirst
(
tlist
))
->
resdom
->
restype
;
if
(
restype
!=
rettype
&&
!
IS_BINARY_COMPATIBLE
(
restype
,
rettype
))
if
(
!
IsBinaryCompatible
(
restype
,
rettype
))
elog
(
ERROR
,
"return type mismatch in function: declared to return %s, returns %s"
,
elog
(
ERROR
,
"return type mismatch in function: declared to return %s, returns %s"
,
format_type_be
(
rettype
),
format_type_be
(
restype
));
format_type_be
(
rettype
),
format_type_be
(
restype
));
...
@@ -440,7 +440,7 @@ checkretval(Oid rettype, List *queryTreeList)
...
@@ -440,7 +440,7 @@ checkretval(Oid rettype, List *queryTreeList)
if
(
tlistlen
==
1
)
if
(
tlistlen
==
1
)
{
{
restype
=
((
TargetEntry
*
)
lfirst
(
tlist
))
->
resdom
->
restype
;
restype
=
((
TargetEntry
*
)
lfirst
(
tlist
))
->
resdom
->
restype
;
if
(
restype
==
rettype
||
IS_BINARY_COMPATIBLE
(
restype
,
rettype
))
if
(
IsBinaryCompatible
(
restype
,
rettype
))
return
;
return
;
}
}
...
@@ -470,7 +470,7 @@ checkretval(Oid rettype, List *queryTreeList)
...
@@ -470,7 +470,7 @@ checkretval(Oid rettype, List *queryTreeList)
continue
;
continue
;
tletype
=
exprType
(
tle
->
expr
);
tletype
=
exprType
(
tle
->
expr
);
atttype
=
reln
->
rd_att
->
attrs
[
i
]
->
atttypid
;
atttype
=
reln
->
rd_att
->
attrs
[
i
]
->
atttypid
;
if
(
tletype
!=
atttype
&&
!
IS_BINARY_COMPATIBLE
(
tletype
,
atttype
))
if
(
!
IsBinaryCompatible
(
tletype
,
atttype
))
elog
(
ERROR
,
"function declared to return %s returns %s instead of %s at column %d"
,
elog
(
ERROR
,
"function declared to return %s returns %s instead of %s at column %d"
,
format_type_be
(
rettype
),
format_type_be
(
rettype
),
format_type_be
(
tletype
),
format_type_be
(
tletype
),
...
...
src/backend/catalog/pg_type.c
View file @
337b22cb
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.6
8 2002/03/19 02:18:14 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.6
9 2002/03/20 19:43:38 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -179,13 +179,11 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName)
...
@@ -179,13 +179,11 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName)
values
[
i
++
]
=
CharGetDatum
(
'i'
);
/* 15 */
values
[
i
++
]
=
CharGetDatum
(
'i'
);
/* 15 */
values
[
i
++
]
=
CharGetDatum
(
'p'
);
/* 16 */
values
[
i
++
]
=
CharGetDatum
(
'p'
);
/* 16 */
values
[
i
++
]
=
BoolGetDatum
(
false
);
/* 17 */
values
[
i
++
]
=
BoolGetDatum
(
false
);
/* 17 */
values
[
i
++
]
=
Int32GetDatum
(
-
1
);
/* 18 */
values
[
i
++
]
=
ObjectIdGetDatum
(
InvalidOid
);
/* 18 */
values
[
i
++
]
=
ObjectIdGetDatum
(
InvalidOid
);
/* 19 */
values
[
i
++
]
=
Int32GetDatum
(
-
1
);
/* 19 */
values
[
i
++
]
=
Int32GetDatum
(
0
);
/* 20 */
values
[
i
++
]
=
Int32GetDatum
(
0
);
/* 20 */
values
[
i
++
]
=
DirectFunctionCall1
(
textin
,
nulls
[
i
++
]
=
'n'
;
/* 21 */
CStringGetDatum
(
typeName
));
/* 21 */
nulls
[
i
++
]
=
'n'
;
/* 22 */
values
[
i
++
]
=
DirectFunctionCall1
(
textin
,
CStringGetDatum
(
typeName
));
/* 22 */
/*
/*
* create a new type tuple with FormHeapTuple
* create a new type tuple with FormHeapTuple
...
@@ -288,7 +286,7 @@ TypeCreate(char *typeName,
...
@@ -288,7 +286,7 @@ TypeCreate(char *typeName,
char
storage
,
char
storage
,
int32
typeMod
,
int32
typeMod
,
int32
typNDims
,
/* Array dimensions for baseTypeName */
int32
typNDims
,
/* Array dimensions for baseTypeName */
bool
typeNotNull
)
/* binary default representation (cooked) */
bool
typeNotNull
)
{
{
int
i
,
int
i
,
j
;
j
;
...
@@ -452,21 +450,10 @@ TypeCreate(char *typeName,
...
@@ -452,21 +450,10 @@ TypeCreate(char *typeName,
*/
*/
values
[
i
++
]
=
CharGetDatum
(
storage
);
/* 16 */
values
[
i
++
]
=
CharGetDatum
(
storage
);
/* 16 */
/*
/* set typnotnull, typbasetype, typtypmod, typndims */
* set the typenotnull value
*/
values
[
i
++
]
=
BoolGetDatum
(
typeNotNull
);
/* 17 */
values
[
i
++
]
=
BoolGetDatum
(
typeNotNull
);
/* 17 */
values
[
i
++
]
=
ObjectIdGetDatum
(
baseObjectId
);
/* 18 */
/*
values
[
i
++
]
=
Int32GetDatum
(
typeMod
);
/* 19 */
* set the typemod value
*/
values
[
i
++
]
=
Int32GetDatum
(
typeMod
);
/* 18 */
values
[
i
++
]
=
ObjectIdGetDatum
(
baseObjectId
);
/* 19 */
/*
* Dimension number for an array base type
*/
values
[
i
++
]
=
Int32GetDatum
(
typNDims
);
/* 20 */
values
[
i
++
]
=
Int32GetDatum
(
typNDims
);
/* 20 */
/*
/*
...
...
src/backend/commands/creatinh.c
View file @
337b22cb
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.8
7 2002/03/19 02:58:19 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.8
8 2002/03/20 19:43:42 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -42,6 +42,7 @@ static int findAttrByName(const char *attributeName, List *schema);
...
@@ -42,6 +42,7 @@ static int findAttrByName(const char *attributeName, List *schema);
static
void
setRelhassubclassInRelation
(
Oid
relationId
,
bool
relhassubclass
);
static
void
setRelhassubclassInRelation
(
Oid
relationId
,
bool
relhassubclass
);
static
List
*
MergeDomainAttributes
(
List
*
schema
);
static
List
*
MergeDomainAttributes
(
List
*
schema
);
/* ----------------------------------------------------------------
/* ----------------------------------------------------------------
* DefineRelation
* DefineRelation
* Creates a new relation.
* Creates a new relation.
...
@@ -71,9 +72,9 @@ DefineRelation(CreateStmt *stmt, char relkind)
...
@@ -71,9 +72,9 @@ DefineRelation(CreateStmt *stmt, char relkind)
StrNCpy
(
relname
,
stmt
->
relname
,
NAMEDATALEN
);
StrNCpy
(
relname
,
stmt
->
relname
,
NAMEDATALEN
);
/*
/*
*
Inherit domain attributes into the known columns before table inheritanc
e
*
Merge domain attributes into the known columns before processing tabl
e
*
applies it's changes otherwise we risk adding double constraints
*
inheritance. Otherwise we risk adding double constraints to a
*
to a domain that
s inherited.
*
domain-type column that'
s inherited.
*/
*/
schema
=
MergeDomainAttributes
(
schema
);
schema
=
MergeDomainAttributes
(
schema
);
...
@@ -273,11 +274,8 @@ TruncateRelation(const char *relname)
...
@@ -273,11 +274,8 @@ TruncateRelation(const char *relname)
/*
/*
* MergeDomainAttributes
* MergeDomainAttributes
* Returns a new table schema with the constraints, types, and other
* Returns a new table schema with the constraints, types, and other
* attributes of
the domain resolved for fields using the
domain as
* attributes of
domains resolved for fields using a
domain as
* their type.
* their type.
*
* Defaults are pulled out by the table attribute as required, similar to
* how all types defaults are processed.
*/
*/
static
List
*
static
List
*
MergeDomainAttributes
(
List
*
schema
)
MergeDomainAttributes
(
List
*
schema
)
...
@@ -295,34 +293,25 @@ MergeDomainAttributes(List *schema)
...
@@ -295,34 +293,25 @@ MergeDomainAttributes(List *schema)
HeapTuple
tuple
;
HeapTuple
tuple
;
Form_pg_type
typeTup
;
Form_pg_type
typeTup
;
tuple
=
SearchSysCache
(
TYPENAME
,
tuple
=
SearchSysCache
(
TYPENAME
,
CStringGetDatum
(
coldef
->
typename
->
name
),
CStringGetDatum
(
coldef
->
typename
->
name
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tuple
))
if
(
!
HeapTupleIsValid
(
tuple
))
elog
(
ERROR
,
"MergeDomainAttributes: Type %s does not exist"
,
elog
(
ERROR
,
"MergeDomainAttributes: Type %s does not exist"
,
coldef
->
typename
->
name
);
coldef
->
typename
->
name
);
typeTup
=
(
Form_pg_type
)
GETSTRUCT
(
tuple
);
typeTup
=
(
Form_pg_type
)
GETSTRUCT
(
tuple
);
if
(
typeTup
->
typtype
==
'd'
)
{
/*
* This is a domain, lets force the properties of the domain on to
* the new column.
*/
/* Enforce the typmod value */
if
(
typeTup
->
typtype
==
'd'
)
coldef
->
typename
->
typmod
=
typeTup
->
typmod
;
{
/* Force the column to have the correct typmod. */
coldef
->
typename
->
typmod
=
typeTup
->
typtypmod
;
/* XXX more to do here? */
}
/* Enforce type NOT NULL || column definition NOT NULL -> NOT NULL */
/* Enforce type NOT NULL || column definition NOT NULL -> NOT NULL */
/* Currently only used for domains, but could be valid for all */
coldef
->
is_not_null
|=
typeTup
->
typnotnull
;
coldef
->
is_not_null
|=
typeTup
->
typnotnull
;
/* Enforce the element type in the event the domain is an array
*
* BUG: How do we fill out arrayBounds and attrname from typelem and typNDimms?
*/
}
ReleaseSysCache
(
tuple
);
ReleaseSysCache
(
tuple
);
}
}
...
...
src/backend/commands/define.c
View file @
337b22cb
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.7
0 2002/03/19 02:18:15 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.7
1 2002/03/20 19:43:44 tgl
Exp $
*
*
* DESCRIPTION
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
* The "DefineFoo" routines take the parse tree and pick out the
...
@@ -483,38 +483,29 @@ DefineAggregate(char *aggName, List *parameters)
...
@@ -483,38 +483,29 @@ DefineAggregate(char *aggName, List *parameters)
void
void
DefineDomain
(
CreateDomainStmt
*
stmt
)
DefineDomain
(
CreateDomainStmt
*
stmt
)
{
{
int16
internalLength
=
-
1
;
/* int2 */
int16
internalLength
;
int16
externalLength
=
-
1
;
/* int2 */
int16
externalLength
;
char
*
inputName
=
NULL
;
char
*
inputName
;
char
*
outputName
=
NULL
;
char
*
outputName
;
char
*
sendName
=
NULL
;
char
*
sendName
;
char
*
receiveName
=
NULL
;
char
*
receiveName
;
bool
byValue
;
/*
char
delimiter
;
* Domains store the external representation in defaultValue
char
alignment
;
* and the interal Node representation in defaultValueBin
char
storage
;
*/
char
*
defaultValue
=
NULL
;
char
*
defaultValueBin
=
NULL
;
bool
byValue
=
false
;
char
delimiter
=
DEFAULT_TYPDELIM
;
char
alignment
=
'i'
;
/* default alignment */
char
storage
=
'p'
;
/* default TOAST storage method */
char
typtype
;
char
typtype
;
Datum
datum
;
Datum
datum
;
bool
isnull
;
char
*
defaultValue
=
NULL
;
char
*
defaultValueBin
=
NULL
;
bool
typNotNull
=
false
;
bool
typNotNull
=
false
;
Oid
basetypelem
;
char
*
elemName
=
NULL
;
char
*
elemName
=
NULL
;
int32
typNDims
=
0
;
/* No array dimensions by default */
int32
typNDims
=
0
;
/* No array dimensions by default */
bool
isnull
;
Relation
pg_type_rel
;
TupleDesc
pg_type_dsc
;
HeapTuple
typeTup
;
HeapTuple
typeTup
;
char
*
typeName
=
stmt
->
typename
->
name
;
char
*
typeName
=
stmt
->
typename
->
name
;
List
*
listptr
;
List
*
schema
=
stmt
->
constraints
;
List
*
schema
=
stmt
->
constraints
;
List
*
listptr
;
/*
/*
* Domainnames, unlike typenames don't need to account for the '_'
* Domainnames, unlike typenames don't need to account for the '_'
...
@@ -524,25 +515,13 @@ DefineDomain(CreateDomainStmt *stmt)
...
@@ -524,25 +515,13 @@ DefineDomain(CreateDomainStmt *stmt)
elog
(
ERROR
,
"CREATE DOMAIN: domain names must be %d characters or less"
,
elog
(
ERROR
,
"CREATE DOMAIN: domain names must be %d characters or less"
,
NAMEDATALEN
-
1
);
NAMEDATALEN
-
1
);
/* Test for existing Domain (or type) of that name */
/* Test for existing Domain (or type) of that name */
typeTup
=
SearchSysCache
(
TYPENAME
typeTup
=
SearchSysCache
(
TYPENAME
,
,
PointerGetDatum
(
stmt
->
domainname
)
PointerGetDatum
(
stmt
->
domainname
),
,
0
,
0
,
0
0
,
0
,
0
);
);
if
(
HeapTupleIsValid
(
typeTup
))
if
(
HeapTupleIsValid
(
typeTup
))
{
elog
(
ERROR
,
"CREATE DOMAIN: domain or type %s already exists"
,
elog
(
ERROR
,
"CREATE DOMAIN: domain or type %s already exists"
,
stmt
->
domainname
);
stmt
->
domainname
);
}
/*
* Get the information about old types
*/
pg_type_rel
=
heap_openr
(
TypeRelationName
,
RowExclusiveLock
);
pg_type_dsc
=
RelationGetDescr
(
pg_type_rel
);
/*
/*
* When the type is an array for some reason we don't actually receive
* When the type is an array for some reason we don't actually receive
...
@@ -555,22 +534,12 @@ DefineDomain(CreateDomainStmt *stmt)
...
@@ -555,22 +534,12 @@ DefineDomain(CreateDomainStmt *stmt)
typNDims
=
length
(
stmt
->
typename
->
arrayBounds
);
typNDims
=
length
(
stmt
->
typename
->
arrayBounds
);
}
}
typeTup
=
SearchSysCache
(
TYPENAME
,
typeTup
=
SearchSysCache
(
TYPENAME
PointerGetDatum
(
typeName
),
,
PointerGetDatum
(
typeName
)
0
,
0
,
0
);
,
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
typeTup
))
if
(
!
HeapTupleIsValid
(
typeTup
))
{
elog
(
ERROR
,
"CREATE DOMAIN: type %s does not exist"
,
elog
(
ERROR
,
"CREATE DOMAIN: type %s does not exist"
,
stmt
->
typename
->
name
);
stmt
->
typename
->
name
);
}
/* Check that this is a basetype */
typtype
=
DatumGetChar
(
heap_getattr
(
typeTup
,
Anum_pg_type_typtype
,
pg_type_dsc
,
&
isnull
));
Assert
(
!
isnull
);
/*
/*
* What we really don't want is domains of domains. This could cause all sorts
* What we really don't want is domains of domains. This could cause all sorts
...
@@ -578,9 +547,10 @@ DefineDomain(CreateDomainStmt *stmt)
...
@@ -578,9 +547,10 @@ DefineDomain(CreateDomainStmt *stmt)
*
*
* With testing, we may determine complex types should be allowed
* With testing, we may determine complex types should be allowed
*/
*/
if
(
typtype
!=
'b'
)
{
typtype
=
((
Form_pg_type
)
GETSTRUCT
(
typeTup
))
->
typtype
;
elog
(
ERROR
,
"DefineDomain: %s is not a basetype"
,
stmt
->
typename
->
name
);
if
(
typtype
!=
'b'
)
}
elog
(
ERROR
,
"DefineDomain: %s is not a basetype"
,
stmt
->
typename
->
name
);
/* passed by value */
/* passed by value */
byValue
=
((
Form_pg_type
)
GETSTRUCT
(
typeTup
))
->
typbyval
;
byValue
=
((
Form_pg_type
)
GETSTRUCT
(
typeTup
))
->
typbyval
;
...
@@ -588,6 +558,9 @@ DefineDomain(CreateDomainStmt *stmt)
...
@@ -588,6 +558,9 @@ DefineDomain(CreateDomainStmt *stmt)
/* Required Alignment */
/* Required Alignment */
alignment
=
((
Form_pg_type
)
GETSTRUCT
(
typeTup
))
->
typalign
;
alignment
=
((
Form_pg_type
)
GETSTRUCT
(
typeTup
))
->
typalign
;
/* TOAST Strategy */
storage
=
((
Form_pg_type
)
GETSTRUCT
(
typeTup
))
->
typstorage
;
/* Storage Length */
/* Storage Length */
internalLength
=
((
Form_pg_type
)
GETSTRUCT
(
typeTup
))
->
typlen
;
internalLength
=
((
Form_pg_type
)
GETSTRUCT
(
typeTup
))
->
typlen
;
...
@@ -597,70 +570,66 @@ DefineDomain(CreateDomainStmt *stmt)
...
@@ -597,70 +570,66 @@ DefineDomain(CreateDomainStmt *stmt)
/* Array element Delimiter */
/* Array element Delimiter */
delimiter
=
((
Form_pg_type
)
GETSTRUCT
(
typeTup
))
->
typdelim
;
delimiter
=
((
Form_pg_type
)
GETSTRUCT
(
typeTup
))
->
typdelim
;
/*
* XXX this is pretty bogus: should be passing function OIDs to
* TypeCreate, not names which aren't unique.
*/
/* Input Function Name */
/* Input Function Name */
datum
=
heap_getattr
(
typeTup
,
Anum_pg_type_typinput
,
pg_type_dsc
,
&
isnull
);
datum
=
SysCacheGetAttr
(
TYPENAME
,
typeTup
,
Anum_pg_type_typinput
,
&
isnull
);
Assert
(
!
isnull
);
Assert
(
!
isnull
);
inputName
=
DatumGetCString
(
DirectFunctionCall1
(
regprocout
,
datum
));
inputName
=
DatumGetCString
(
DirectFunctionCall1
(
regprocout
,
datum
));
/* Output Function Name */
/* Output Function Name */
datum
=
heap_getattr
(
typeTup
,
Anum_pg_type_typoutput
,
pg_type_dsc
,
&
isnull
);
datum
=
SysCacheGetAttr
(
TYPENAME
,
typeTup
,
Anum_pg_type_typoutput
,
&
isnull
);
Assert
(
!
isnull
);
Assert
(
!
isnull
);
outputName
=
DatumGetCString
(
DirectFunctionCall1
(
regprocout
,
datum
));
outputName
=
DatumGetCString
(
DirectFunctionCall1
(
regprocout
,
datum
));
/* ReceiveName */
/* ReceiveName */
datum
=
heap_getattr
(
typeTup
,
Anum_pg_type_typreceive
,
pg_type_dsc
,
&
isnull
);
datum
=
SysCacheGetAttr
(
TYPENAME
,
typeTup
,
Anum_pg_type_typreceive
,
&
isnull
);
Assert
(
!
isnull
);
Assert
(
!
isnull
);
receiveName
=
DatumGetCString
(
DirectFunctionCall1
(
regprocout
,
datum
));
receiveName
=
DatumGetCString
(
DirectFunctionCall1
(
regprocout
,
datum
));
/* SendName */
/* SendName */
datum
=
heap_getattr
(
typeTup
,
Anum_pg_type_typsend
,
pg_type_dsc
,
&
isnull
);
datum
=
SysCacheGetAttr
(
TYPENAME
,
typeTup
,
Anum_pg_type_typsend
,
&
isnull
);
Assert
(
!
isnull
);
Assert
(
!
isnull
);
sendName
=
DatumGetCString
(
DirectFunctionCall1
(
regprocout
,
datum
));
sendName
=
DatumGetCString
(
DirectFunctionCall1
(
regprocout
,
datum
));
/* TOAST Strategy */
storage
=
((
Form_pg_type
)
GETSTRUCT
(
typeTup
))
->
typstorage
;
Assert
(
!
isnull
);
/* Inherited default value */
/* Inherited default value */
datum
=
heap_getattr
(
typeTup
,
Anum_pg_type_typdefault
,
pg_type_dsc
,
&
isnull
);
datum
=
SysCacheGetAttr
(
TYPENAME
,
typeTup
,
if
(
!
isnull
)
{
Anum_pg_type_typdefault
,
&
isnull
);
if
(
!
isnull
)
defaultValue
=
DatumGetCString
(
DirectFunctionCall1
(
textout
,
datum
));
defaultValue
=
DatumGetCString
(
DirectFunctionCall1
(
textout
,
datum
));
}
/* Inherited default binary value */
/* Inherited default binary value */
datum
=
heap_getattr
(
typeTup
,
Anum_pg_type_typdefaultbin
,
pg_type_dsc
,
&
isnull
);
datum
=
SysCacheGetAttr
(
TYPENAME
,
typeTup
,
if
(
!
isnull
)
{
Anum_pg_type_typdefaultbin
,
&
isnull
);
if
(
!
isnull
)
defaultValueBin
=
DatumGetCString
(
DirectFunctionCall1
(
textout
,
datum
));
defaultValueBin
=
DatumGetCString
(
DirectFunctionCall1
(
textout
,
datum
));
}
/*
/*
* Pull out the typelem name of the parent OID.
* Pull out the typelem name of the parent OID.
*
*
* This is what enables us to make a domain of an array
* This is what enables us to make a domain of an array
*/
*/
datum
=
heap_getattr
(
typeTup
,
Anum_pg_type_typelem
,
pg_type_dsc
,
&
isnull
);
basetypelem
=
((
Form_pg_type
)
GETSTRUCT
(
typeTup
))
->
typelem
;
Assert
(
!
isnull
);
if
(
basetypelem
!=
InvalidOid
)
{
if
(
DatumGetObjectId
(
datum
)
!=
InvalidOid
)
{
HeapTuple
tup
;
HeapTuple
tup
;
tup
=
SearchSysCache
(
TYPEOID
tup
=
SearchSysCache
(
TYPEOID
,
,
datum
ObjectIdGetDatum
(
basetypelem
),
,
0
,
0
,
0
0
,
0
,
0
);
);
elemName
=
pstrdup
(
NameStr
(((
Form_pg_type
)
GETSTRUCT
(
tup
))
->
typname
));
elemName
=
NameStr
(((
Form_pg_type
)
GETSTRUCT
(
tup
))
->
typname
);
ReleaseSysCache
(
tup
);
ReleaseSysCache
(
tup
);
}
}
/*
/*
* Run through constraints manually
avoids
the additional
* Run through constraints manually
to avoid
the additional
* processing conducted by DefineRelation() and friends.
* processing conducted by DefineRelation() and friends.
*
*
* Besides, we don't want any constraints to be cooked. We'll
* Besides, we don't want any constraints to be cooked. We'll
...
@@ -668,20 +637,13 @@ DefineDomain(CreateDomainStmt *stmt)
...
@@ -668,20 +637,13 @@ DefineDomain(CreateDomainStmt *stmt)
*/
*/
foreach
(
listptr
,
schema
)
foreach
(
listptr
,
schema
)
{
{
Constraint
*
colDef
=
lfirst
(
listptr
);
bool
nullDefined
=
false
;
bool
nullDefined
=
false
;
Node
*
expr
;
Node
*
expr
;
Constraint
*
colDef
=
lfirst
(
listptr
);
/* Used for the statement transformation */
ParseState
*
pstate
;
ParseState
*
pstate
;
/*
switch
(
colDef
->
contype
)
* Create a dummy ParseState and insert the target relation as its
{
* sole rangetable entry. We need a ParseState for transformExpr.
*/
pstate
=
make_parsestate
(
NULL
);
switch
(
colDef
->
contype
)
{
/*
/*
* The inherited default value may be overridden by the user
* The inherited default value may be overridden by the user
* with the DEFAULT <expr> statement.
* with the DEFAULT <expr> statement.
...
@@ -690,27 +652,26 @@ DefineDomain(CreateDomainStmt *stmt)
...
@@ -690,27 +652,26 @@ DefineDomain(CreateDomainStmt *stmt)
* don't want to cook or fiddle too much.
* don't want to cook or fiddle too much.
*/
*/
case
CONSTR_DEFAULT
:
case
CONSTR_DEFAULT
:
/* Create a dummy ParseState for transformExpr */
pstate
=
make_parsestate
(
NULL
);
/*
/*
* Cook the colDef->raw_expr into an expression to ensure
* Cook the colDef->raw_expr into an expression.
* that it can be done. We store the text version of the
* raw value.
*
* Note: Name is strictly for error message
* Note: Name is strictly for error message
*/
*/
expr
=
cookDefault
(
pstate
,
colDef
->
raw_expr
expr
=
cookDefault
(
pstate
,
colDef
->
raw_expr
,
,
typeTup
->
t_data
->
t_oid
typeTup
->
t_data
->
t_oid
,
,
stmt
->
typename
->
typmod
stmt
->
typename
->
typmod
,
,
stmt
->
typename
->
name
);
stmt
->
typename
->
name
);
/*
/* Binary default required */
* Expression must be stored as a nodeToString result,
* but we also require a valid textual representation
* (mainly to make life easier for pg_dump).
*/
defaultValue
=
deparse_expression
(
expr
,
defaultValue
=
deparse_expression
(
expr
,
deparse_context_for
(
stmt
->
domainname
,
deparse_context_for
(
stmt
->
domainname
,
InvalidOid
),
InvalidOid
),
false
);
false
);
defaultValueBin
=
nodeToString
(
expr
);
defaultValueBin
=
nodeToString
(
expr
);
break
;
break
;
/*
/*
...
@@ -723,7 +684,6 @@ DefineDomain(CreateDomainStmt *stmt)
...
@@ -723,7 +684,6 @@ DefineDomain(CreateDomainStmt *stmt)
typNotNull
=
true
;
typNotNull
=
true
;
nullDefined
=
true
;
nullDefined
=
true
;
}
}
break
;
break
;
case
CONSTR_NULL
:
case
CONSTR_NULL
:
...
@@ -733,31 +693,31 @@ DefineDomain(CreateDomainStmt *stmt)
...
@@ -733,31 +693,31 @@ DefineDomain(CreateDomainStmt *stmt)
typNotNull
=
false
;
typNotNull
=
false
;
nullDefined
=
true
;
nullDefined
=
true
;
}
}
break
;
break
;
case
CONSTR_UNIQUE
:
case
CONSTR_UNIQUE
:
elog
(
ERROR
,
"CREATE DOMAIN / UNIQUE inde
ci
es not supported"
);
elog
(
ERROR
,
"CREATE DOMAIN / UNIQUE inde
x
es not supported"
);
break
;
break
;
case
CONSTR_PRIMARY
:
case
CONSTR_PRIMARY
:
elog
(
ERROR
,
"CREATE DOMAIN / PRIMARY KEY inde
ci
es not supported"
);
elog
(
ERROR
,
"CREATE DOMAIN / PRIMARY KEY inde
x
es not supported"
);
break
;
break
;
case
CONSTR_CHECK
:
case
CONSTR_CHECK
:
elog
(
ERROR
,
"DefineDomain: CHECK Constraints not supported"
);
elog
(
ERROR
,
"defineDomain: CHECK Constraints not supported"
);
break
;
break
;
case
CONSTR_ATTR_DEFERRABLE
:
case
CONSTR_ATTR_DEFERRABLE
:
case
CONSTR_ATTR_NOT_DEFERRABLE
:
case
CONSTR_ATTR_NOT_DEFERRABLE
:
case
CONSTR_ATTR_DEFERRED
:
case
CONSTR_ATTR_DEFERRED
:
case
CONSTR_ATTR_IMMEDIATE
:
case
CONSTR_ATTR_IMMEDIATE
:
elog
(
ERROR
,
"
d
efineDomain: DEFERRABLE, NON DEFERRABLE, DEFERRED and IMMEDIATE not supported"
);
elog
(
ERROR
,
"
D
efineDomain: DEFERRABLE, NON DEFERRABLE, DEFERRED and IMMEDIATE not supported"
);
break
;
break
;
}
default:
elog
(
ERROR
,
"DefineDomain: unrecognized constraint node type"
);
break
;
}
}
}
/*
/*
...
@@ -776,8 +736,8 @@ DefineDomain(CreateDomainStmt *stmt)
...
@@ -776,8 +736,8 @@ DefineDomain(CreateDomainStmt *stmt)
sendName
,
/* send procedure */
sendName
,
/* send procedure */
elemName
,
/* element type name */
elemName
,
/* element type name */
typeName
,
/* base type name */
typeName
,
/* base type name */
defaultValue
,
/* default type value */
defaultValue
,
/* default type value
(text)
*/
defaultValueBin
,
/* default type value */
defaultValueBin
,
/* default type value
(binary)
*/
byValue
,
/* passed by value */
byValue
,
/* passed by value */
alignment
,
/* required alignment */
alignment
,
/* required alignment */
storage
,
/* TOAST strategy */
storage
,
/* TOAST strategy */
...
@@ -789,10 +749,8 @@ DefineDomain(CreateDomainStmt *stmt)
...
@@ -789,10 +749,8 @@ DefineDomain(CreateDomainStmt *stmt)
* Now we can clean up.
* Now we can clean up.
*/
*/
ReleaseSysCache
(
typeTup
);
ReleaseSysCache
(
typeTup
);
heap_close
(
pg_type_rel
,
NoLock
);
}
}
/*
/*
* DefineType
* DefineType
* Registers a new type.
* Registers a new type.
...
@@ -808,8 +766,6 @@ DefineType(char *typeName, List *parameters)
...
@@ -808,8 +766,6 @@ DefineType(char *typeName, List *parameters)
char
*
sendName
=
NULL
;
char
*
sendName
=
NULL
;
char
*
receiveName
=
NULL
;
char
*
receiveName
=
NULL
;
char
*
defaultValue
=
NULL
;
char
*
defaultValue
=
NULL
;
char
*
defaultValueBin
=
NULL
;
Node
*
defaultRaw
=
(
Node
*
)
NULL
;
bool
byValue
=
false
;
bool
byValue
=
false
;
char
delimiter
=
DEFAULT_TYPDELIM
;
char
delimiter
=
DEFAULT_TYPDELIM
;
char
*
shadow_type
;
char
*
shadow_type
;
...
@@ -851,7 +807,7 @@ DefineType(char *typeName, List *parameters)
...
@@ -851,7 +807,7 @@ DefineType(char *typeName, List *parameters)
else
if
(
strcasecmp
(
defel
->
defname
,
"element"
)
==
0
)
else
if
(
strcasecmp
(
defel
->
defname
,
"element"
)
==
0
)
elemName
=
defGetString
(
defel
);
elemName
=
defGetString
(
defel
);
else
if
(
strcasecmp
(
defel
->
defname
,
"default"
)
==
0
)
else
if
(
strcasecmp
(
defel
->
defname
,
"default"
)
==
0
)
default
Raw
=
defel
->
arg
;
default
Value
=
defGetString
(
defel
)
;
else
if
(
strcasecmp
(
defel
->
defname
,
"passedbyvalue"
)
==
0
)
else
if
(
strcasecmp
(
defel
->
defname
,
"passedbyvalue"
)
==
0
)
byValue
=
true
;
byValue
=
true
;
else
if
(
strcasecmp
(
defel
->
defname
,
"alignment"
)
==
0
)
else
if
(
strcasecmp
(
defel
->
defname
,
"alignment"
)
==
0
)
...
@@ -911,32 +867,6 @@ DefineType(char *typeName, List *parameters)
...
@@ -911,32 +867,6 @@ DefineType(char *typeName, List *parameters)
if
(
outputName
==
NULL
)
if
(
outputName
==
NULL
)
elog
(
ERROR
,
"Define:
\"
output
\"
unspecified"
);
elog
(
ERROR
,
"Define:
\"
output
\"
unspecified"
);
if
(
defaultRaw
)
{
Node
*
expr
;
ParseState
*
pstate
;
/*
* Create a dummy ParseState and insert the target relation as its
* sole rangetable entry. We need a ParseState for transformExpr.
*/
pstate
=
make_parsestate
(
NULL
);
expr
=
cookDefault
(
pstate
,
defaultRaw
,
InvalidOid
,
-
1
,
typeName
);
/* Binary default required */
defaultValue
=
deparse_expression
(
expr
,
deparse_context_for
(
typeName
,
InvalidOid
),
false
);
defaultValueBin
=
nodeToString
(
expr
);
}
/*
/*
* now have TypeCreate do all the real work.
* now have TypeCreate do all the real work.
*/
*/
...
@@ -952,9 +882,9 @@ DefineType(char *typeName, List *parameters)
...
@@ -952,9 +882,9 @@ DefineType(char *typeName, List *parameters)
receiveName
,
/* receive procedure */
receiveName
,
/* receive procedure */
sendName
,
/* send procedure */
sendName
,
/* send procedure */
elemName
,
/* element type name */
elemName
,
/* element type name */
NULL
,
/* base type name (
Non-zero
for domains) */
NULL
,
/* base type name (
only
for domains) */
defaultValue
,
/* default type value */
defaultValue
,
/* default type value */
defaultValueBin
,
/* default type value (Binary form)
*/
NULL
,
/* no binary form available
*/
byValue
,
/* passed by value */
byValue
,
/* passed by value */
alignment
,
/* required alignment */
alignment
,
/* required alignment */
storage
,
/* TOAST strategy */
storage
,
/* TOAST strategy */
...
...
src/backend/commands/indexcmds.c
View file @
337b22cb
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.6
3 2002/03/06 06:09:33 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.6
4 2002/03/20 19:43:47 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -314,8 +314,7 @@ FuncIndexArgs(IndexInfo *indexInfo,
...
@@ -314,8 +314,7 @@ FuncIndexArgs(IndexInfo *indexInfo,
for
(
i
=
0
;
i
<
nargs
;
i
++
)
for
(
i
=
0
;
i
<
nargs
;
i
++
)
{
{
if
(
argTypes
[
i
]
!=
true_typeids
[
i
]
&&
if
(
!
IsBinaryCompatible
(
argTypes
[
i
],
true_typeids
[
i
]))
!
IS_BINARY_COMPATIBLE
(
argTypes
[
i
],
true_typeids
[
i
]))
func_error
(
"DefineIndex"
,
funcIndex
->
name
,
nargs
,
argTypes
,
func_error
(
"DefineIndex"
,
funcIndex
->
name
,
nargs
,
argTypes
,
"Index function must be binary-compatible with table datatype"
);
"Index function must be binary-compatible with table datatype"
);
}
}
...
@@ -418,8 +417,7 @@ GetAttrOpClass(IndexElem *attribute, Oid attrType,
...
@@ -418,8 +417,7 @@ GetAttrOpClass(IndexElem *attribute, Oid attrType,
opInputType
=
((
Form_pg_opclass
)
GETSTRUCT
(
tuple
))
->
opcintype
;
opInputType
=
((
Form_pg_opclass
)
GETSTRUCT
(
tuple
))
->
opcintype
;
ReleaseSysCache
(
tuple
);
ReleaseSysCache
(
tuple
);
if
(
attrType
!=
opInputType
&&
if
(
!
IsBinaryCompatible
(
attrType
,
opInputType
))
!
IS_BINARY_COMPATIBLE
(
attrType
,
opInputType
))
elog
(
ERROR
,
"operator class
\"
%s
\"
does not accept data type %s"
,
elog
(
ERROR
,
"operator class
\"
%s
\"
does not accept data type %s"
,
attribute
->
class
,
format_type_be
(
attrType
));
attribute
->
class
,
format_type_be
(
attrType
));
...
@@ -470,7 +468,7 @@ GetDefaultOpClass(Oid attrType, Oid accessMethodId)
...
@@ -470,7 +468,7 @@ GetDefaultOpClass(Oid attrType, Oid accessMethodId)
nexact
++
;
nexact
++
;
exactOid
=
tuple
->
t_data
->
t_oid
;
exactOid
=
tuple
->
t_data
->
t_oid
;
}
}
else
if
(
I
S_BINARY_COMPATIBLE
(
opclass
->
opcintype
,
attrType
))
else
if
(
I
sBinaryCompatible
(
opclass
->
opcintype
,
attrType
))
{
{
ncompatible
++
;
ncompatible
++
;
compatibleOid
=
tuple
->
t_data
->
t_oid
;
compatibleOid
=
tuple
->
t_data
->
t_oid
;
...
...
src/backend/commands/remove.c
View file @
337b22cb
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.
69 2002/03/19 02:18:16 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.
70 2002/03/20 19:43:49 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -282,23 +282,18 @@ RemoveType(char *typeName) /* type name to be removed */
...
@@ -282,23 +282,18 @@ RemoveType(char *typeName) /* type name to be removed */
* use it.
* use it.
*/
*/
void
void
RemoveDomain
(
char
*
domainName
,
int
behavior
)
/* domain name to be removed */
RemoveDomain
(
char
*
domainName
,
int
behavior
)
{
{
Relation
relation
;
Relation
relation
;
HeapTuple
tup
;
HeapTuple
tup
;
TupleDesc
description
;
char
typtype
;
char
typtype
;
bool
isnull
;
/* Domains are stored as types. Check for permissions on the type */
/* Domains are stored as types. Check for permissions on the type */
if
(
!
pg_ownercheck
(
GetUserId
(),
domainName
,
TYPENAME
))
if
(
!
pg_ownercheck
(
GetUserId
(),
domainName
,
TYPENAME
))
elog
(
ERROR
,
"RemoveDomain: type '%s': permission denied"
,
elog
(
ERROR
,
"RemoveDomain: type '%s': permission denied"
,
domainName
);
domainName
);
relation
=
heap_openr
(
TypeRelationName
,
RowExclusiveLock
);
relation
=
heap_openr
(
TypeRelationName
,
RowExclusiveLock
);
description
=
RelationGetDescr
(
relation
);
tup
=
SearchSysCache
(
TYPENAME
,
tup
=
SearchSysCache
(
TYPENAME
,
PointerGetDatum
(
domainName
),
PointerGetDatum
(
domainName
),
...
@@ -306,14 +301,11 @@ RemoveDomain(char *domainName, int behavior) /* domain name to be removed */
...
@@ -306,14 +301,11 @@ RemoveDomain(char *domainName, int behavior) /* domain name to be removed */
if
(
!
HeapTupleIsValid
(
tup
))
if
(
!
HeapTupleIsValid
(
tup
))
elog
(
ERROR
,
"RemoveType: type '%s' does not exist"
,
domainName
);
elog
(
ERROR
,
"RemoveType: type '%s' does not exist"
,
domainName
);
/* Check that this is actually a domain */
/* Check that this is actually a domain */
typtype
=
DatumGetChar
(
heap_getattr
(
tup
,
Anum_pg_type_typtype
,
description
,
&
isnull
));
typtype
=
((
Form_pg_type
)
GETSTRUCT
(
tup
))
->
typtype
;
Assert
(
!
isnull
);
if
(
typtype
!=
'd'
)
{
if
(
typtype
!=
'd'
)
elog
(
ERROR
,
"%s is not a domain"
,
domainName
);
elog
(
ERROR
,
"%s is not a domain"
,
domainName
);
}
/* CASCADE unsupported */
/* CASCADE unsupported */
if
(
behavior
==
CASCADE
)
{
if
(
behavior
==
CASCADE
)
{
...
...
src/backend/executor/nodeAgg.c
View file @
337b22cb
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.
79 2002/03/02 21:39:25 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.
80 2002/03/20 19:43:54 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -896,8 +896,7 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
...
@@ -896,8 +896,7 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
*/
*/
Oid
inputType
=
exprType
(
aggref
->
target
);
Oid
inputType
=
exprType
(
aggref
->
target
);
if
(
inputType
!=
aggform
->
aggtranstype
&&
if
(
!
IsBinaryCompatible
(
inputType
,
aggform
->
aggtranstype
))
!
IS_BINARY_COMPATIBLE
(
inputType
,
aggform
->
aggtranstype
))
elog
(
ERROR
,
"Aggregate %s needs to have compatible input type and transition type"
,
elog
(
ERROR
,
"Aggregate %s needs to have compatible input type and transition type"
,
aggname
);
aggname
);
}
}
...
...
src/backend/nodes/copyfuncs.c
View file @
337b22cb
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.17
0 2002/03/19 02:18:16 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.17
1 2002/03/20 19:43:58 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -2026,6 +2026,7 @@ _copyDropStmt(DropStmt *from)
...
@@ -2026,6 +2026,7 @@ _copyDropStmt(DropStmt *from)
Node_Copy
(
from
,
newnode
,
names
);
Node_Copy
(
from
,
newnode
,
names
);
newnode
->
removeType
=
from
->
removeType
;
newnode
->
removeType
=
from
->
removeType
;
newnode
->
behavior
=
from
->
behavior
;
return
newnode
;
return
newnode
;
}
}
...
@@ -2238,7 +2239,6 @@ _copyCreateDomainStmt(CreateDomainStmt *from)
...
@@ -2238,7 +2239,6 @@ _copyCreateDomainStmt(CreateDomainStmt *from)
if
(
from
->
domainname
)
if
(
from
->
domainname
)
newnode
->
domainname
=
pstrdup
(
from
->
domainname
);
newnode
->
domainname
=
pstrdup
(
from
->
domainname
);
Node_Copy
(
from
,
newnode
,
typename
);
Node_Copy
(
from
,
newnode
,
typename
);
Node_Copy
(
from
,
newnode
,
constraints
);
Node_Copy
(
from
,
newnode
,
constraints
);
...
...
src/backend/nodes/equalfuncs.c
View file @
337b22cb
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.11
8 2002/03/19 02:18:16 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.11
9 2002/03/20 19:44:01 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -878,6 +878,8 @@ _equalDropStmt(DropStmt *a, DropStmt *b)
...
@@ -878,6 +878,8 @@ _equalDropStmt(DropStmt *a, DropStmt *b)
return
false
;
return
false
;
if
(
a
->
removeType
!=
b
->
removeType
)
if
(
a
->
removeType
!=
b
->
removeType
)
return
false
;
return
false
;
if
(
a
->
behavior
!=
b
->
behavior
)
return
false
;
return
true
;
return
true
;
}
}
...
...
src/backend/nodes/makefuncs.c
View file @
337b22cb
...
@@ -8,16 +8,7 @@
...
@@ -8,16 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.26 2001/03/22 03:59:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.27 2002/03/20 19:44:04 tgl Exp $
*
* NOTES
* Creator functions in POSTGRES 4.2 are generated automatically. Most of
* them are rarely used. Now we don't generate them any more. If you want
* one, you have to write it yourself.
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
* Andrew Yu Oct 20, 1994 file creation
*/
*/
#include "postgres.h"
#include "postgres.h"
...
@@ -184,3 +175,19 @@ makeAttr(char *relname, char *attname)
...
@@ -184,3 +175,19 @@ makeAttr(char *relname, char *attname)
return
a
;
return
a
;
}
}
/*
* makeRelabelType -
* creates a RelabelType node
*/
RelabelType
*
makeRelabelType
(
Node
*
arg
,
Oid
rtype
,
int32
rtypmod
)
{
RelabelType
*
r
=
makeNode
(
RelabelType
);
r
->
arg
=
arg
;
r
->
resulttype
=
rtype
;
r
->
resulttypmod
=
rtypmod
;
return
r
;
}
src/backend/optimizer/path/indxpath.c
View file @
337b22cb
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.11
3 2002/03/02 21:39:26 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.11
4 2002/03/20 19:44:09 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -900,9 +900,9 @@ indexable_operator(Expr *clause, Oid opclass, bool indexkey_on_left)
...
@@ -900,9 +900,9 @@ indexable_operator(Expr *clause, Oid opclass, bool indexkey_on_left)
*/
*/
if
(
ltype
==
indexkeytype
&&
rtype
==
indexkeytype
)
if
(
ltype
==
indexkeytype
&&
rtype
==
indexkeytype
)
return
InvalidOid
;
/* no chance for a different operator */
return
InvalidOid
;
/* no chance for a different operator */
if
(
ltype
!=
indexkeytype
&&
!
IS_BINARY_COMPATIBLE
(
ltype
,
indexkeytype
))
if
(
!
IsBinaryCompatible
(
ltype
,
indexkeytype
))
return
InvalidOid
;
return
InvalidOid
;
if
(
rtype
!=
indexkeytype
&&
!
IS_BINARY_COMPATIBLE
(
rtype
,
indexkeytype
))
if
(
!
IsBinaryCompatible
(
rtype
,
indexkeytype
))
return
InvalidOid
;
return
InvalidOid
;
/*
/*
...
...
src/backend/optimizer/prep/preptlist.c
View file @
337b22cb
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.
49 2002/03/19 02:18:17 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.
50 2002/03/20 19:44:15 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -355,9 +355,9 @@ build_column_default(Relation rel, int attrno)
...
@@ -355,9 +355,9 @@ build_column_default(Relation rel, int attrno)
Form_pg_attribute
att_tup
=
rd_att
->
attrs
[
attrno
-
1
];
Form_pg_attribute
att_tup
=
rd_att
->
attrs
[
attrno
-
1
];
Oid
atttype
=
att_tup
->
atttypid
;
Oid
atttype
=
att_tup
->
atttypid
;
int32
atttypmod
=
att_tup
->
atttypmod
;
int32
atttypmod
=
att_tup
->
atttypmod
;
int16
typlen
;
int16
typlen
=
att_tup
->
attlen
;
bool
typbyval
;
bool
typbyval
=
att_tup
->
attbyval
;
Node
*
expr
;
Node
*
expr
=
NULL
;
/*
/*
* Scan to see if relation has a default for this column.
* Scan to see if relation has a default for this column.
...
@@ -371,55 +371,19 @@ build_column_default(Relation rel, int attrno)
...
@@ -371,55 +371,19 @@ build_column_default(Relation rel, int attrno)
{
{
if
(
attrno
==
defval
[
ndef
].
adnum
)
if
(
attrno
==
defval
[
ndef
].
adnum
)
{
{
Oid
type_id
;
/*
/*
* Found it, convert string representation to node tree.
* Found it, convert string representation to node tree.
*/
*/
expr
=
stringToNode
(
defval
[
ndef
].
adbin
);
expr
=
stringToNode
(
defval
[
ndef
].
adbin
);
break
;
/*
* Make sure the value is coerced to the target column
* type (might not be right type yet if it's not a
* constant!) This should match the parser's processing of
* non-defaulted expressions --- see
* updateTargetListEntry().
*/
type_id
=
exprType
(
expr
);
if
(
type_id
!=
atttype
)
{
expr
=
CoerceTargetExpr
(
NULL
,
expr
,
type_id
,
getBaseType
(
atttype
),
atttypmod
);
/*
* This really shouldn't fail; should have checked the
* default's type when it was created ...
*/
if
(
expr
==
NULL
)
elog
(
ERROR
,
"Column
\"
%s
\"
is of type %s"
" but default expression is of type %s"
"
\n\t
You will need to rewrite or cast the expression"
,
NameStr
(
att_tup
->
attname
),
format_type_be
(
atttype
),
format_type_be
(
type_id
));
}
/*
* If the column is a fixed-length type, it may need a
* length coercion as well as a type coercion.
*/
expr
=
coerce_type_typmod
(
NULL
,
expr
,
atttype
,
atttypmod
);
return
expr
;
}
}
}
}
}
}
if
(
expr
==
NULL
)
{
/*
/*
* No per-column default, so look for a default for the type itself.
* No per-column default, so look for a default for the type itself.
* If there isn't one, we generate a NULL constant of the correct
* type.
*/
*/
if
(
att_tup
->
attisset
)
if
(
att_tup
->
attisset
)
{
{
...
@@ -430,51 +394,63 @@ build_column_default(Relation rel, int attrno)
...
@@ -430,51 +394,63 @@ build_column_default(Relation rel, int attrno)
*/
*/
typlen
=
sizeof
(
Oid
);
typlen
=
sizeof
(
Oid
);
typbyval
=
true
;
typbyval
=
true
;
expr
=
(
Node
*
)
makeConst
(
atttype
,
typlen
,
(
Datum
)
0
,
true
,
typbyval
,
false
,
/* not a set */
false
);
}
}
else
else
{
{
#ifdef _DROP_COLUMN_HACK__
expr
=
get_typdefault
(
atttype
);
if
(
COLUMN_IS_DROPPED
(
att_tup
))
}
{
}
if
(
expr
==
NULL
)
{
/*
* No default anywhere, so generate a NULL constant.
*/
expr
=
(
Node
*
)
makeConst
(
atttype
,
expr
=
(
Node
*
)
makeConst
(
atttype
,
typlen
,
typlen
,
(
Datum
)
0
,
(
Datum
)
0
,
true
,
true
,
/* isnull */
typbyval
,
typbyval
,
false
,
/* not a set */
false
,
/* not a set */
false
);
false
);
}
}
else
else
#endif
/* _DROP_COLUMN_HACK__ */
{
expr
=
get_typdefault
(
atttype
,
atttypmod
)
;
Oid
exprtype
;
if
(
expr
==
NULL
)
{
/*
expr
=
(
Node
*
)
makeConst
(
atttype
,
* Make sure the value is coerced to the target column
typlen
,
* type (might not be right type yet if it's not a
(
Datum
)
0
,
* constant!) This should match the parser's processing of
true
,
* non-defaulted expressions --- see
typbyval
,
* updateTargetListEntry().
false
,
/* not a set */
*/
false
);
exprtype
=
exprType
(
expr
);
}
get_typlenbyval
(
atttype
,
&
typlen
,
&
typbyval
);
if
(
exprtype
!=
atttype
)
{
expr
=
CoerceTargetExpr
(
NULL
,
expr
,
exprtype
,
atttype
,
atttypmod
);
/*
* This really shouldn't fail; should have checked the
* default's type when it was created ...
*/
if
(
expr
==
NULL
)
elog
(
ERROR
,
"Column
\"
%s
\"
is of type %s"
" but default expression is of type %s"
"
\n\t
You will need to rewrite or cast the expression"
,
NameStr
(
att_tup
->
attname
),
format_type_be
(
atttype
),
format_type_be
(
exprtype
));
}
}
/*
/*
* If the column is a fixed-length type, it may need a length coercion
* If the column is a fixed-length type, it may need a
* as well as a type coercion, as well as direction to the final type
.
* length coercion as well as a type coercion
.
*/
*/
expr
=
coerce_type_typmod
(
NULL
,
expr
,
expr
=
coerce_type_typmod
(
NULL
,
expr
,
atttype
,
atttypmod
);
atttype
,
atttypmod
);
}
return
expr
;
return
expr
;
}
}
src/backend/parser/gram.y
View file @
337b22cb
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.29
3 2002/03/19 12:52:20 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.29
4 2002/03/20 19:44:21 tgl
Exp $
*
*
* HISTORY
* HISTORY
* AUTHOR DATE MAJOR EVENT
* AUTHOR DATE MAJOR EVENT
...
@@ -135,8 +135,7 @@ static void doNegateFloat(Value *v);
...
@@ -135,8 +135,7 @@ static void doNegateFloat(Value *v);
ClosePortalStmt, ClusterStmt, CommentStmt, ConstraintsSetStmt,
ClosePortalStmt, ClusterStmt, CommentStmt, ConstraintsSetStmt,
CopyStmt, CreateAsStmt, CreateDomainStmt, CreateGroupStmt, CreatePLangStmt,
CopyStmt, CreateAsStmt, CreateDomainStmt, CreateGroupStmt, CreatePLangStmt,
CreateSchemaStmt, CreateSeqStmt, CreateStmt, CreateTrigStmt,
CreateSchemaStmt, CreateSeqStmt, CreateStmt, CreateTrigStmt,
CreateUserStmt, CreatedbStmt, CursorStmt,
CreateUserStmt, CreatedbStmt, CursorStmt, DefineStmt, DeleteStmt,
DefineStmt, DeleteStmt,
DropGroupStmt, DropPLangStmt, DropSchemaStmt, DropStmt, DropTrigStmt,
DropGroupStmt, DropPLangStmt, DropSchemaStmt, DropStmt, DropTrigStmt,
DropUserStmt, DropdbStmt, ExplainStmt, FetchStmt,
DropUserStmt, DropdbStmt, ExplainStmt, FetchStmt,
GrantStmt, IndexStmt, InsertStmt, ListenStmt, LoadStmt, LockStmt,
GrantStmt, IndexStmt, InsertStmt, ListenStmt, LoadStmt, LockStmt,
...
@@ -151,7 +150,7 @@ static void doNegateFloat(Value *v);
...
@@ -151,7 +150,7 @@ static void doNegateFloat(Value *v);
simple_select
simple_select
%type <node> alter_column_default
%type <node> alter_column_default
%type <ival> drop_behavior
%type <ival> drop_behavior
, opt_drop_behavior
%type <list> createdb_opt_list, createdb_opt_item
%type <list> createdb_opt_list, createdb_opt_item
%type <boolean> opt_equal
%type <boolean> opt_equal
...
@@ -1181,6 +1180,10 @@ drop_behavior: CASCADE { $$ = CASCADE; }
...
@@ -1181,6 +1180,10 @@ drop_behavior: CASCADE { $$ = CASCADE; }
| RESTRICT { $$ = RESTRICT; }
| RESTRICT { $$ = RESTRICT; }
;
;
opt_drop_behavior: CASCADE { $$ = CASCADE; }
| RESTRICT { $$ = RESTRICT; }
| /* EMPTY */ { $$ = RESTRICT; /* default */ }
;
/*****************************************************************************
/*****************************************************************************
...
@@ -2030,22 +2033,13 @@ def_list: def_elem { $$ = makeList1($1); }
...
@@ -2030,22 +2033,13 @@ def_list: def_elem { $$ = makeList1($1); }
| def_list ',' def_elem { $$ = lappend($1, $3); }
| def_list ',' def_elem { $$ = lappend($1, $3); }
;
;
def_elem: DEFAULT '=' b_expr
def_elem: ColLabel '=' def_arg
{
$$ = makeNode(DefElem);
$$->defname = "default";
if (exprIsNullConstant($3))
$$->arg = (Node *)NULL;
else
$$->arg = $3;
}
| ColId '=' def_arg
{
{
$$ = makeNode(DefElem);
$$ = makeNode(DefElem);
$$->defname = $1;
$$->defname = $1;
$$->arg = (Node *)$3;
$$->arg = (Node *)$3;
}
}
| Col
Id
| Col
Label
{
{
$$ = makeNode(DefElem);
$$ = makeNode(DefElem);
$$->defname = $1;
$$->defname = $1;
...
@@ -2069,19 +2063,11 @@ def_arg: func_return { $$ = (Node *)$1; }
...
@@ -2069,19 +2063,11 @@ def_arg: func_return { $$ = (Node *)$1; }
*
*
*****************************************************************************/
*****************************************************************************/
DropStmt: DROP drop_type name_list
DropStmt: DROP drop_type name_list
opt_drop_behavior
{
{
DropStmt *n = makeNode(DropStmt);
DropStmt *n = makeNode(DropStmt);
n->removeType = $2;
n->removeType = $2;
n->names = $3;
n->names = $3;
n->behavior = RESTRICT; /* Restricted by default */
$$ = (Node *)n;
}
| DROP DOMAIN_P name_list drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = DROP_DOMAIN_P;
n->names = $3;
n->behavior = $4;
n->behavior = $4;
$$ = (Node *)n;
$$ = (Node *)n;
}
}
...
@@ -2092,7 +2078,8 @@ drop_type: TABLE { $$ = DROP_TABLE; }
...
@@ -2092,7 +2078,8 @@ drop_type: TABLE { $$ = DROP_TABLE; }
| VIEW { $$ = DROP_VIEW; }
| VIEW { $$ = DROP_VIEW; }
| INDEX { $$ = DROP_INDEX; }
| INDEX { $$ = DROP_INDEX; }
| RULE { $$ = DROP_RULE; }
| RULE { $$ = DROP_RULE; }
| TYPE_P { $$ = DROP_TYPE_P; }
| TYPE_P { $$ = DROP_TYPE; }
| DOMAIN_P { $$ = DROP_DOMAIN; }
;
;
/*****************************************************************************
/*****************************************************************************
...
@@ -3194,12 +3181,19 @@ createdb_opt_item: LOCATION opt_equal Sconst
...
@@ -3194,12 +3181,19 @@ createdb_opt_item: LOCATION opt_equal Sconst
}
}
;
;
/*
* Though the equals sign doesn't match other WITH options, pg_dump uses
* equals for backward compability, and it doesn't seem worth remove it.
*/
opt_equal: '=' { $$ = TRUE; }
| /*EMPTY*/ { $$ = FALSE; }
;
/*****************************************************************************
/*****************************************************************************
*
*
* DROP DATABASE
* DROP DATABASE
*
*
*
*****************************************************************************/
*****************************************************************************/
DropdbStmt: DROP DATABASE database_name
DropdbStmt: DROP DATABASE database_name
...
@@ -3210,20 +3204,11 @@ DropdbStmt: DROP DATABASE database_name
...
@@ -3210,20 +3204,11 @@ DropdbStmt: DROP DATABASE database_name
}
}
;
;
/*
* Though the equals sign doesn't match other WITH options, pg_dump uses
* equals for backward compability, and it doesn't seem worth remove it.
*/
opt_equal: '=' { $$ = TRUE; }
| /*EMPTY*/ { $$ = FALSE; }
;
/*****************************************************************************
/*****************************************************************************
*
*
* ALTER DATABASE
* ALTER DATABASE
*
*
*
*****************************************************************************/
*****************************************************************************/
AlterDatabaseSetStmt: ALTER DATABASE database_name VariableSetStmt
AlterDatabaseSetStmt: ALTER DATABASE database_name VariableSetStmt
...
...
src/backend/parser/parse_coerce.c
View file @
337b22cb
...
@@ -8,25 +8,31 @@
...
@@ -8,25 +8,31 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.6
7 2002/03/19 02:18:20 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.6
8 2002/03/20 19:44:22 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
#include "postgres.h"
#include "postgres.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_proc.h"
#include "nodes/makefuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/clauses.h"
#include "parser/parse_coerce.h"
#include "parser/parse_coerce.h"
#include "parser/parse_expr.h"
#include "parser/parse_expr.h"
#include "parser/parse_func.h"
#include "parser/parse_func.h"
#include "parser/parse_type.h"
#include "parser/parse_type.h"
#include "utils/builtins.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
#include "utils/syscache.h"
Oid
DemoteType
(
Oid
inType
);
Oid
DemoteType
(
Oid
inType
);
Oid
PromoteTypeToNext
(
Oid
inType
);
Oid
PromoteTypeToNext
(
Oid
inType
);
static
Oid
PreferredType
(
CATEGORY
category
,
Oid
type
);
static
Oid
PreferredType
(
CATEGORY
category
,
Oid
type
);
static
Node
*
build_func_call
(
Oid
funcid
,
Oid
rettype
,
List
*
args
);
static
Oid
find_coercion_function
(
Oid
targetTypeId
,
Oid
inputTypeId
,
Oid
secondArgType
);
/* coerce_type()
/* coerce_type()
...
@@ -87,32 +93,28 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
...
@@ -87,32 +93,28 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
result
=
(
Node
*
)
newcon
;
result
=
(
Node
*
)
newcon
;
}
}
else
if
(
I
S_BINARY_COMPATIBLE
(
inputTypeId
,
targetTypeId
))
else
if
(
I
sBinaryCompatible
(
inputTypeId
,
targetTypeId
))
{
{
/*
/*
* We don't really need to do a conversion, but we do need to
* We don't really need to do a conversion, but we do need to
* attach a RelabelType node so that the expression will be seen
* attach a RelabelType node so that the expression will be seen
* to have the intended type when inspected by higher-level code.
* to have the intended type when inspected by higher-level code.
*/
*
RelabelType
*
relabel
=
makeNode
(
RelabelType
);
relabel
->
arg
=
node
;
relabel
->
resulttype
=
targetTypeId
;
/*
* XXX could we label result with exprTypmod(node) instead of
* XXX could we label result with exprTypmod(node) instead of
* default -1 typmod, to save a possible length-coercion later?
* default -1 typmod, to save a possible length-coercion later?
* Would work if both types have same interpretation of typmod,
* Would work if both types have same interpretation of typmod,
* which is likely but not certain.
* which is likely but not certain.
*/
*/
relabel
->
resulttypmod
=
-
1
;
result
=
(
Node
*
)
makeRelabelType
(
node
,
targetTypeId
,
-
1
);
result
=
(
Node
*
)
relabel
;
}
}
else
if
(
typeInheritsFrom
(
inputTypeId
,
targetTypeId
))
else
if
(
typeInheritsFrom
(
inputTypeId
,
targetTypeId
))
{
{
/* Input class type is a subclass of target, so nothing to do */
/*
result
=
node
;
* Input class type is a subclass of target, so nothing to do
* --- except relabel the type. This is binary compatibility
* for complex types.
*/
result
=
(
Node
*
)
makeRelabelType
(
node
,
targetTypeId
,
-
1
);
}
}
else
else
{
{
...
@@ -121,21 +123,24 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
...
@@ -121,21 +123,24 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
* (caller should have determined that there is one), and generate
* (caller should have determined that there is one), and generate
* an expression tree representing run-time application of the
* an expression tree representing run-time application of the
* conversion function.
* conversion function.
*
* For domains, we use the coercion function for the base type.
*/
*/
FuncCall
*
n
=
makeNode
(
FuncCall
);
Oid
baseTypeId
=
getBaseType
(
targetTypeId
);
Oid
funcId
;
n
->
funcname
=
typeidTypeName
(
targetTypeId
);
funcId
=
find_coercion_function
(
baseTypeId
,
n
->
args
=
makeList1
(
node
);
getBaseType
(
inputTypeId
),
n
->
agg_star
=
false
;
InvalidOid
);
n
->
agg_distinct
=
false
;
if
(
!
OidIsValid
(
funcId
))
elog
(
ERROR
,
"coerce_type: no conversion function from %s to %s"
,
format_type_be
(
inputTypeId
),
format_type_be
(
targetTypeId
));
result
=
transformExpr
(
pstate
,
(
Node
*
)
n
,
EXPR_COLUMN_FIRST
);
result
=
build_func_call
(
funcId
,
baseTypeId
,
makeList1
(
node
)
);
/* safety check that we got the right thing */
/* if domain, relabel with domain type ID */
if
(
exprType
(
result
)
!=
targetTypeId
)
if
(
targetTypeId
!=
baseTypeId
)
elog
(
ERROR
,
"coerce_type: conversion function %s produced %s"
,
result
=
(
Node
*
)
makeRelabelType
(
result
,
targetTypeId
,
-
1
);
typeidTypeName
(
targetTypeId
),
typeidTypeName
(
exprType
(
result
)));
/*
/*
* If the input is a constant, apply the type conversion function
* If the input is a constant, apply the type conversion function
...
@@ -152,7 +157,8 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
...
@@ -152,7 +157,8 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
* nodes that mustn't be collapsed. (It'd be a lot cleaner to
* nodes that mustn't be collapsed. (It'd be a lot cleaner to
* make a separate node type for that purpose...)
* make a separate node type for that purpose...)
*/
*/
if
(
IsA
(
node
,
Const
)
&&!
((
Const
*
)
node
)
->
constisnull
)
if
(
IsA
(
node
,
Const
)
&&
!
((
Const
*
)
node
)
->
constisnull
)
result
=
eval_const_expressions
(
result
);
result
=
eval_const_expressions
(
result
);
}
}
...
@@ -169,23 +175,18 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
...
@@ -169,23 +175,18 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
*
*
* Notes:
* Notes:
* This uses the same mechanism as the CAST() SQL construct in gram.y.
* This uses the same mechanism as the CAST() SQL construct in gram.y.
* We should also check the function return type on candidate conversion
* routines just to be safe but we do not do that yet...
* - thomas 1998-03-31
*/
*/
bool
bool
can_coerce_type
(
int
nargs
,
Oid
*
input_typeids
,
Oid
*
func_typeids
)
can_coerce_type
(
int
nargs
,
Oid
*
input_typeids
,
Oid
*
func_typeids
)
{
{
int
i
;
int
i
;
HeapTuple
ftup
;
Form_pg_proc
pform
;
Oid
oid_array
[
FUNC_MAX_ARGS
];
/* run through argument list... */
/* run through argument list... */
for
(
i
=
0
;
i
<
nargs
;
i
++
)
for
(
i
=
0
;
i
<
nargs
;
i
++
)
{
{
Oid
inputTypeId
=
input_typeids
[
i
];
Oid
inputTypeId
=
input_typeids
[
i
];
Oid
targetTypeId
=
func_typeids
[
i
];
Oid
targetTypeId
=
func_typeids
[
i
];
Oid
funcId
;
/* no problem if same type */
/* no problem if same type */
if
(
inputTypeId
==
targetTypeId
)
if
(
inputTypeId
==
targetTypeId
)
...
@@ -195,7 +196,7 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids)
...
@@ -195,7 +196,7 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids)
* one of the known-good transparent conversions? then drop
* one of the known-good transparent conversions? then drop
* through...
* through...
*/
*/
if
(
I
S_BINARY_COMPATIBLE
(
inputTypeId
,
targetTypeId
))
if
(
I
sBinaryCompatible
(
inputTypeId
,
targetTypeId
))
continue
;
continue
;
/* don't know what to do for the output type? then quit... */
/* don't know what to do for the output type? then quit... */
...
@@ -232,26 +233,15 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids)
...
@@ -232,26 +233,15 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids)
* Else, try for explicit conversion using functions: look for a
* Else, try for explicit conversion using functions: look for a
* single-argument function named with the target type name and
* single-argument function named with the target type name and
* accepting the source type.
* accepting the source type.
*
* If either type is a domain, use its base type instead.
*/
*/
MemSet
(
oid_array
,
0
,
FUNC_MAX_ARGS
*
sizeof
(
Oid
));
funcId
=
find_coercion_function
(
getBaseType
(
targetTypeId
),
oid_array
[
0
]
=
inputTypeId
;
getBaseType
(
inputTypeId
),
InvalidOid
);
ftup
=
SearchSysCache
(
PROCNAME
,
if
(
!
OidIsValid
(
funcId
))
PointerGetDatum
(
typeidTypeName
(
targetTypeId
)),
Int32GetDatum
(
1
),
PointerGetDatum
(
oid_array
),
0
);
if
(
!
HeapTupleIsValid
(
ftup
))
return
false
;
/* Make sure the function's result type is as expected, too */
pform
=
(
Form_pg_proc
)
GETSTRUCT
(
ftup
);
if
(
pform
->
prorettype
!=
targetTypeId
)
{
ReleaseSysCache
(
ftup
);
return
false
;
return
false
;
}
}
ReleaseSysCache
(
ftup
);
}
return
true
;
return
true
;
}
}
...
@@ -277,8 +267,8 @@ Node *
...
@@ -277,8 +267,8 @@ Node *
coerce_type_typmod
(
ParseState
*
pstate
,
Node
*
node
,
coerce_type_typmod
(
ParseState
*
pstate
,
Node
*
node
,
Oid
targetTypeId
,
int32
atttypmod
)
Oid
targetTypeId
,
int32
atttypmod
)
{
{
char
*
funcname
;
Oid
baseTypeId
;
Oid
oid_array
[
FUNC_MAX_ARGS
]
;
Oid
funcId
;
/*
/*
* A negative typmod is assumed to mean that no coercion is wanted.
* A negative typmod is assumed to mean that no coercion is wanted.
...
@@ -286,30 +276,28 @@ coerce_type_typmod(ParseState *pstate, Node *node,
...
@@ -286,30 +276,28 @@ coerce_type_typmod(ParseState *pstate, Node *node,
if
(
atttypmod
<
0
||
atttypmod
==
exprTypmod
(
node
))
if
(
atttypmod
<
0
||
atttypmod
==
exprTypmod
(
node
))
return
node
;
return
node
;
funcname
=
typeidTypeName
(
targetTypeId
);
/* If given type is a domain, use base type instead */
MemSet
(
oid_array
,
0
,
FUNC_MAX_ARGS
*
sizeof
(
Oid
));
baseTypeId
=
getBaseType
(
targetTypeId
);
oid_array
[
0
]
=
targetTypeId
;
oid_array
[
1
]
=
INT4OID
;
/* attempt to find with arguments exactly as specified... */
funcId
=
find_coercion_function
(
baseTypeId
,
baseTypeId
,
INT4OID
);
if
(
SearchSysCacheExists
(
PROCNAME
,
PointerGetDatum
(
funcname
),
if
(
OidIsValid
(
funcId
))
Int32GetDatum
(
2
),
PointerGetDatum
(
oid_array
),
0
))
{
{
A_Const
*
cons
=
makeNode
(
A_Const
);
Const
*
cons
;
FuncCall
*
func
=
makeNode
(
FuncCall
);
cons
->
val
.
type
=
T_Integer
;
cons
=
makeConst
(
INT4OID
,
cons
->
val
.
val
.
ival
=
atttypmod
;
sizeof
(
int32
),
Int32GetDatum
(
atttypmod
),
false
,
true
,
false
,
false
);
func
->
funcname
=
funcname
;
node
=
build_func_call
(
funcId
,
baseTypeId
,
makeList2
(
node
,
cons
));
func
->
args
=
makeList2
(
node
,
cons
);
func
->
agg_star
=
false
;
func
->
agg_distinct
=
false
;
node
=
transformExpr
(
pstate
,
(
Node
*
)
func
,
EXPR_COLUMN_FIRST
);
/* relabel if it's domain case */
if
(
targetTypeId
!=
baseTypeId
)
node
=
(
Node
*
)
makeRelabelType
(
node
,
targetTypeId
,
atttypmod
);
}
}
return
node
;
return
node
;
...
@@ -532,6 +520,64 @@ TypeCategory(Oid inType)
...
@@ -532,6 +520,64 @@ TypeCategory(Oid inType)
}
/* TypeCategory() */
}
/* TypeCategory() */
/* IsBinaryCompatible()
* Check if two types are binary-compatible.
*
* This notion allows us to cheat and directly exchange values without
* going through the trouble of calling a conversion function.
*
* XXX This should be moved to system catalog lookups
* to allow for better type extensibility.
*/
/*
* This macro describes hard-coded knowledge of binary compatibility
* for built-in types.
*/
#define IS_BINARY_COMPATIBLE(a,b) \
(((a) == BPCHAROID && (b) == TEXTOID) \
|| ((a) == BPCHAROID && (b) == VARCHAROID) \
|| ((a) == VARCHAROID && (b) == TEXTOID) \
|| ((a) == VARCHAROID && (b) == BPCHAROID) \
|| ((a) == TEXTOID && (b) == BPCHAROID) \
|| ((a) == TEXTOID && (b) == VARCHAROID) \
|| ((a) == OIDOID && (b) == INT4OID) \
|| ((a) == OIDOID && (b) == REGPROCOID) \
|| ((a) == INT4OID && (b) == OIDOID) \
|| ((a) == INT4OID && (b) == REGPROCOID) \
|| ((a) == REGPROCOID && (b) == OIDOID) \
|| ((a) == REGPROCOID && (b) == INT4OID) \
|| ((a) == ABSTIMEOID && (b) == INT4OID) \
|| ((a) == INT4OID && (b) == ABSTIMEOID) \
|| ((a) == RELTIMEOID && (b) == INT4OID) \
|| ((a) == INT4OID && (b) == RELTIMEOID) \
|| ((a) == INETOID && (b) == CIDROID) \
|| ((a) == CIDROID && (b) == INETOID) \
|| ((a) == BITOID && (b) == VARBITOID) \
|| ((a) == VARBITOID && (b) == BITOID))
bool
IsBinaryCompatible
(
Oid
type1
,
Oid
type2
)
{
if
(
type1
==
type2
)
return
true
;
if
(
IS_BINARY_COMPATIBLE
(
type1
,
type2
))
return
true
;
/*
* Perhaps the types are domains; if so, look at their base types
*/
if
(
OidIsValid
(
type1
))
type1
=
getBaseType
(
type1
);
if
(
OidIsValid
(
type2
))
type2
=
getBaseType
(
type2
);
if
(
type1
==
type2
)
return
true
;
if
(
IS_BINARY_COMPATIBLE
(
type1
,
type2
))
return
true
;
return
false
;
}
/* IsPreferredType()
/* IsPreferredType()
* Check if this type is a preferred type.
* Check if this type is a preferred type.
* XXX This should be moved to system catalog lookups
* XXX This should be moved to system catalog lookups
...
@@ -606,31 +652,81 @@ PreferredType(CATEGORY category, Oid type)
...
@@ -606,31 +652,81 @@ PreferredType(CATEGORY category, Oid type)
return
result
;
return
result
;
}
/* PreferredType() */
}
/* PreferredType() */
/*
/*
* If the targetTypeId is a domain, we really want to coerce
* find_coercion_function
* the tuple to the domain type -- not the domain itself
* Look for a coercion function between two types.
*
* A coercion function must be named after (the internal name of) its
* result type, and must accept exactly the specified input type.
*
* This routine is also used to look for length-coercion functions, which
* are similar but accept a second argument. secondArgType is the type
* of the second argument (normally INT4OID), or InvalidOid if we are
* looking for a regular coercion function.
*
* If a function is found, return its pg_proc OID; else return InvalidOid.
*/
*/
Oid
static
Oid
getBaseType
(
Oid
in
Type
)
find_coercion_function
(
Oid
targetTypeId
,
Oid
inputTypeId
,
Oid
secondArg
Type
)
{
{
HeapTuple
tup
;
char
*
funcname
;
Form_pg_type
typTup
;
Oid
oid_array
[
FUNC_MAX_ARGS
];
int
nargs
;
HeapTuple
ftup
;
Form_pg_proc
pform
;
Oid
funcid
;
tup
=
SearchSysCache
(
TYPEOID
,
funcname
=
typeidTypeName
(
targetTypeId
);
ObjectIdGetDatum
(
inType
),
MemSet
(
oid_array
,
0
,
FUNC_MAX_ARGS
*
sizeof
(
Oid
));
0
,
0
,
0
);
oid_array
[
0
]
=
inputTypeId
;
if
(
OidIsValid
(
secondArgType
))
{
oid_array
[
1
]
=
secondArgType
;
nargs
=
2
;
}
else
nargs
=
1
;
typTup
=
((
Form_pg_type
)
GETSTRUCT
(
tup
));
ftup
=
SearchSysCache
(
PROCNAME
,
PointerGetDatum
(
funcname
),
Int32GetDatum
(
nargs
),
PointerGetDatum
(
oid_array
),
0
);
if
(
!
HeapTupleIsValid
(
ftup
))
return
InvalidOid
;
/* Make sure the function's result type is as expected, too */
pform
=
(
Form_pg_proc
)
GETSTRUCT
(
ftup
);
if
(
pform
->
prorettype
!=
targetTypeId
)
{
ReleaseSysCache
(
ftup
);
return
InvalidOid
;
}
funcid
=
ftup
->
t_data
->
t_oid
;
ReleaseSysCache
(
ftup
);
return
funcid
;
}
/*
/*
* Assume that typbasetype exists and is a base type, where inType
* Build an expression tree representing a function call.
* was a domain
*
* The argument expressions must have been transformed already.
*/
*/
if
(
typTup
->
typtype
==
'd'
)
static
Node
*
inType
=
typTup
->
typbasetype
;
build_func_call
(
Oid
funcid
,
Oid
rettype
,
List
*
args
)
{
Func
*
funcnode
;
Expr
*
expr
;
funcnode
=
makeNode
(
Func
);
funcnode
->
funcid
=
funcid
;
funcnode
->
functype
=
rettype
;
funcnode
->
func_fcache
=
NULL
;
ReleaseSysCache
(
tup
);
expr
=
makeNode
(
Expr
);
expr
->
typeOid
=
rettype
;
expr
->
opType
=
FUNC_EXPR
;
expr
->
oper
=
(
Node
*
)
funcnode
;
expr
->
args
=
args
;
return
inType
;
return
(
Node
*
)
expr
;
}
}
src/backend/parser/parse_expr.c
View file @
337b22cb
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.1
09 2002/03/19 02:18:20 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.1
10 2002/03/20 19:44:25 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -1027,8 +1027,7 @@ parser_typecast_expression(ParseState *pstate,
...
@@ -1027,8 +1027,7 @@ parser_typecast_expression(ParseState *pstate,
if
(
inputType
!=
targetType
)
if
(
inputType
!=
targetType
)
{
{
expr
=
CoerceTargetExpr
(
pstate
,
expr
,
inputType
,
expr
=
CoerceTargetExpr
(
pstate
,
expr
,
inputType
,
getBaseType
(
targetType
),
targetType
,
typename
->
typmod
);
typename
->
typmod
);
if
(
expr
==
NULL
)
if
(
expr
==
NULL
)
elog
(
ERROR
,
"Cannot cast type '%s' to '%s'"
,
elog
(
ERROR
,
"Cannot cast type '%s' to '%s'"
,
format_type_be
(
inputType
),
format_type_be
(
inputType
),
...
@@ -1040,7 +1039,7 @@ parser_typecast_expression(ParseState *pstate,
...
@@ -1040,7 +1039,7 @@ parser_typecast_expression(ParseState *pstate,
* as well as a type coercion.
* as well as a type coercion.
*/
*/
expr
=
coerce_type_typmod
(
pstate
,
expr
,
expr
=
coerce_type_typmod
(
pstate
,
expr
,
getBaseType
(
targetType
)
,
typename
->
typmod
);
targetType
,
typename
->
typmod
);
return
expr
;
return
expr
;
}
}
...
...
src/backend/parser/parse_func.c
View file @
337b22cb
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.11
7 2002/03/12 00:51:55
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.11
8 2002/03/20 19:44:29
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -575,8 +575,7 @@ agg_select_candidate(Oid typeid, CandidateList candidates)
...
@@ -575,8 +575,7 @@ agg_select_candidate(Oid typeid, CandidateList candidates)
{
{
current_typeid
=
current_candidate
->
args
[
0
];
current_typeid
=
current_candidate
->
args
[
0
];
if
(
current_typeid
==
typeid
if
(
IsBinaryCompatible
(
current_typeid
,
typeid
))
||
IS_BINARY_COMPATIBLE
(
current_typeid
,
typeid
))
{
{
last_candidate
=
current_candidate
;
last_candidate
=
current_candidate
;
ncandidates
++
;
ncandidates
++
;
...
@@ -815,9 +814,7 @@ func_select_candidate(int nargs,
...
@@ -815,9 +814,7 @@ func_select_candidate(int nargs,
{
{
if
(
input_typeids
[
i
]
!=
UNKNOWNOID
)
if
(
input_typeids
[
i
]
!=
UNKNOWNOID
)
{
{
if
(
current_typeids
[
i
]
==
input_typeids
[
i
]
||
if
(
IsBinaryCompatible
(
current_typeids
[
i
],
input_typeids
[
i
]))
IS_BINARY_COMPATIBLE
(
current_typeids
[
i
],
input_typeids
[
i
]))
nmatch
++
;
nmatch
++
;
}
}
}
}
...
@@ -1115,8 +1112,7 @@ func_get_detail(char *funcname,
...
@@ -1115,8 +1112,7 @@ func_get_detail(char *funcname,
Node
*
arg1
=
lfirst
(
fargs
);
Node
*
arg1
=
lfirst
(
fargs
);
if
((
sourceType
==
UNKNOWNOID
&&
IsA
(
arg1
,
Const
))
||
if
((
sourceType
==
UNKNOWNOID
&&
IsA
(
arg1
,
Const
))
||
sourceType
==
targetType
||
IsBinaryCompatible
(
sourceType
,
targetType
))
IS_BINARY_COMPATIBLE
(
sourceType
,
targetType
))
{
{
/* Yup, it's a type coercion */
/* Yup, it's a type coercion */
*
funcid
=
InvalidOid
;
*
funcid
=
InvalidOid
;
...
...
src/backend/parser/parse_oper.c
View file @
337b22cb
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.5
2 2002/02/19 20:11:15
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.5
3 2002/03/20 19:44:31
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -354,9 +354,7 @@ oper_select_candidate(int nargs,
...
@@ -354,9 +354,7 @@ oper_select_candidate(int nargs,
{
{
if
(
input_typeids
[
i
]
!=
UNKNOWNOID
)
if
(
input_typeids
[
i
]
!=
UNKNOWNOID
)
{
{
if
(
current_typeids
[
i
]
==
input_typeids
[
i
]
||
if
(
IsBinaryCompatible
(
current_typeids
[
i
],
input_typeids
[
i
]))
IS_BINARY_COMPATIBLE
(
current_typeids
[
i
],
input_typeids
[
i
]))
nmatch
++
;
nmatch
++
;
}
}
}
}
...
@@ -736,10 +734,8 @@ compatible_oper(char *op, Oid arg1, Oid arg2, bool noError)
...
@@ -736,10 +734,8 @@ compatible_oper(char *op, Oid arg1, Oid arg2, bool noError)
/* but is it good enough? */
/* but is it good enough? */
opform
=
(
Form_pg_operator
)
GETSTRUCT
(
optup
);
opform
=
(
Form_pg_operator
)
GETSTRUCT
(
optup
);
if
((
opform
->
oprleft
==
arg1
||
if
(
IsBinaryCompatible
(
opform
->
oprleft
,
arg1
)
&&
IS_BINARY_COMPATIBLE
(
opform
->
oprleft
,
arg1
))
&&
IsBinaryCompatible
(
opform
->
oprright
,
arg2
))
(
opform
->
oprright
==
arg2
||
IS_BINARY_COMPATIBLE
(
opform
->
oprright
,
arg2
)))
return
optup
;
return
optup
;
/* nope... */
/* nope... */
...
...
src/backend/tcop/utility.c
View file @
337b22cb
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.13
4 2002/03/19 02:58:19 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.13
5 2002/03/20 19:44:35 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -276,12 +276,12 @@ ProcessUtility(Node *parsetree,
...
@@ -276,12 +276,12 @@ ProcessUtility(Node *parsetree,
}
}
break
;
break
;
case
DROP_TYPE
_P
:
case
DROP_TYPE
:
/* RemoveType does its own permissions checks */
/* RemoveType does its own permissions checks */
RemoveType
(
relname
);
RemoveType
(
relname
);
break
;
break
;
case
DROP_DOMAIN
_P
:
case
DROP_DOMAIN
:
/* RemoveDomain does its own permissions checks */
/* RemoveDomain does its own permissions checks */
RemoveDomain
(
relname
,
stmt
->
behavior
);
RemoveDomain
(
relname
,
stmt
->
behavior
);
break
;
break
;
...
...
src/backend/utils/adt/format_type.c
View file @
337b22cb
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.2
7 2002/03/19 02:18:21 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.2
8 2002/03/20 19:44:40 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -123,10 +123,10 @@ format_type_internal(Oid type_oid, int32 typemod,
...
@@ -123,10 +123,10 @@ format_type_internal(Oid type_oid, int32 typemod,
HeapTuple
tuple
;
HeapTuple
tuple
;
Oid
array_base_type
;
Oid
array_base_type
;
int16
typlen
;
int16
typlen
;
char
typtype
;
bool
is_array
;
bool
is_array
;
char
*
name
;
char
*
name
;
char
*
buf
;
char
*
buf
;
char
typtype
;
if
(
type_oid
==
InvalidOid
&&
allow_invalid
)
if
(
type_oid
==
InvalidOid
&&
allow_invalid
)
return
pstrdup
(
"-"
);
return
pstrdup
(
"-"
);
...
@@ -143,34 +143,16 @@ format_type_internal(Oid type_oid, int32 typemod,
...
@@ -143,34 +143,16 @@ format_type_internal(Oid type_oid, int32 typemod,
type_oid
);
type_oid
);
}
}
/*
* Check if it's an array (and not a domain --- we don't want to show
* the substructure of a domain type). Fixed-length array types such
* as "name" shouldn't get deconstructed either.
*/
array_base_type
=
((
Form_pg_type
)
GETSTRUCT
(
tuple
))
->
typelem
;
array_base_type
=
((
Form_pg_type
)
GETSTRUCT
(
tuple
))
->
typelem
;
typlen
=
((
Form_pg_type
)
GETSTRUCT
(
tuple
))
->
typlen
;
typlen
=
((
Form_pg_type
)
GETSTRUCT
(
tuple
))
->
typlen
;
typtype
=
((
Form_pg_type
)
GETSTRUCT
(
tuple
))
->
typtype
;
typtype
=
((
Form_pg_type
)
GETSTRUCT
(
tuple
))
->
typtype
;
/*
if
(
array_base_type
!=
InvalidOid
&&
typlen
<
0
&&
typtype
!=
'd'
)
* Domains look alot like arrays, so lets process them first, and return
* back to avoid the array and 'standard' formatting procedures that are
* use for base types.
*/
if
(
typtype
==
'd'
)
{
name
=
NameStr
(((
Form_pg_type
)
GETSTRUCT
(
tuple
))
->
typname
);
/*
* Double-quote the name if it's not a standard identifier.
* Note this is *necessary* for ruleutils.c's use.
*/
if
(
strspn
(
name
,
"abcdefghijklmnopqrstuvwxyz0123456789_"
)
!=
strlen
(
name
)
||
isdigit
((
unsigned
char
)
name
[
0
]))
buf
=
psnprintf
(
strlen
(
name
)
+
3
,
"
\"
%s
\"
"
,
name
);
else
buf
=
pstrdup
(
name
);
ReleaseSysCache
(
tuple
);
return
buf
;
}
if
(
array_base_type
!=
InvalidOid
&&
typlen
<
0
)
{
{
/* Switch our attention to the array element type */
/* Switch our attention to the array element type */
ReleaseSysCache
(
tuple
);
ReleaseSysCache
(
tuple
);
...
...
src/backend/utils/cache/lsyscache.c
View file @
337b22cb
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.6
3 2002/03/19 02:18:21 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.6
4 2002/03/20 19:44:42 tgl
Exp $
*
*
* NOTES
* NOTES
* Eventually, the index information should go through here, too.
* Eventually, the index information should go through here, too.
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
#include "catalog/pg_shadow.h"
#include "catalog/pg_shadow.h"
#include "catalog/pg_statistic.h"
#include "catalog/pg_statistic.h"
#include "catalog/pg_type.h"
#include "catalog/pg_type.h"
#include "
parser/parse_coerce
.h"
#include "
nodes/makefuncs
.h"
#include "utils/array.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/lsyscache.h"
...
@@ -818,19 +818,19 @@ get_typstorage(Oid typid)
...
@@ -818,19 +818,19 @@ get_typstorage(Oid typid)
/*
/*
* get_typdefault
* get_typdefault
*
* Given a type OID, return the type's default value, if any.
* Given a type OID, return the type's default value, if any.
* Returns FALSE if there is no default (effectively, default is NULL).
*
* The result points to palloc'd storage for pass-by-reference types.
* The result is a palloc'd expression node tree, or NULL if there
* is no defined default for the datatype.
*
* NB: caller should be prepared to coerce result to correct datatype;
* the returned expression tree might produce something of the wrong type.
*/
*/
Node
*
Node
*
get_typdefault
(
Oid
typid
,
int32
atttypmod
)
get_typdefault
(
Oid
typid
)
{
{
HeapTuple
typeTuple
;
HeapTuple
typeTuple
;
Form_pg_type
type
;
Form_pg_type
type
;
Oid
typinput
;
Oid
typbasetype
;
char
typtype
;
Datum
datum
;
Datum
datum
;
bool
isNull
;
bool
isNull
;
Node
*
expr
;
Node
*
expr
;
...
@@ -838,48 +838,102 @@ get_typdefault(Oid typid, int32 atttypmod)
...
@@ -838,48 +838,102 @@ get_typdefault(Oid typid, int32 atttypmod)
typeTuple
=
SearchSysCache
(
TYPEOID
,
typeTuple
=
SearchSysCache
(
TYPEOID
,
ObjectIdGetDatum
(
typid
),
ObjectIdGetDatum
(
typid
),
0
,
0
,
0
);
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
typeTuple
))
if
(
!
HeapTupleIsValid
(
typeTuple
))
elog
(
ERROR
,
"get_typdefault: failed to lookup type %u"
,
typid
);
elog
(
ERROR
,
"get_typdefault: failed to lookup type %u"
,
typid
);
type
=
(
Form_pg_type
)
GETSTRUCT
(
typeTuple
);
type
=
(
Form_pg_type
)
GETSTRUCT
(
typeTuple
);
typinput
=
type
->
typinput
;
typbasetype
=
type
->
typbasetype
;
typtype
=
type
->
typtype
;
/*
/*
* typdefaultbin is potentially null, so don't try to access it as a
* typdefault and typdefaultbin are potentially null, so don't try to
* struct field. Must do it the hard way with SysCacheGetAttr.
* access 'em as struct fields. Must do it the hard way with
* SysCacheGetAttr.
*/
*/
datum
=
SysCacheGetAttr
(
TYPEOID
,
datum
=
SysCacheGetAttr
(
TYPEOID
,
typeTuple
,
typeTuple
,
Anum_pg_type_typdefaultbin
,
Anum_pg_type_typdefaultbin
,
&
isNull
);
&
isNull
);
ReleaseSysCache
(
typeTuple
);
if
(
!
isNull
)
if
(
isNull
)
{
return
(
Node
*
)
NULL
;
/* We have an expression default */
expr
=
stringToNode
(
DatumGetCString
(
DirectFunctionCall1
(
textout
,
datum
)));
}
else
{
/* Perhaps we have a plain literal default */
datum
=
SysCacheGetAttr
(
TYPEOID
,
typeTuple
,
Anum_pg_type_typdefault
,
&
isNull
);
if
(
!
isNull
)
{
char
*
strDefaultVal
;
/* Convert text datum to C string */
strDefaultVal
=
DatumGetCString
(
DirectFunctionCall1
(
textout
,
datum
));
/* Convert C string to a value of the given type */
datum
=
OidFunctionCall3
(
type
->
typinput
,
CStringGetDatum
(
strDefaultVal
),
ObjectIdGetDatum
(
type
->
typelem
),
Int32GetDatum
(
-
1
));
/* Build a Const node containing the value */
expr
=
(
Node
*
)
makeConst
(
typid
,
type
->
typlen
,
datum
,
false
,
type
->
typbyval
,
false
,
/* not a set */
false
);
pfree
(
strDefaultVal
);
}
else
{
/* No default */
expr
=
NULL
;
}
}
/* Convert Datum to a Node */
ReleaseSysCache
(
typeTuple
);
expr
=
stringToNode
(
DatumGetCString
(
DirectFunctionCall1
(
textout
,
datum
)));
return
expr
;
}
/*
* getBaseType
* If the given type is a domain, return its base type;
* otherwise return the type's own OID.
*/
Oid
getBaseType
(
Oid
typid
)
{
/*
/*
* Ensure we goto the basetype before the domain type.
* We loop to find the bottom base type in a stack of domains.
*
* Prevents scenarios like the below from failing:
* CREATE DOMAIN dom text DEFAULT random();
*
*/
*/
if
(
typbasetype
!=
InvalidOid
)
{
for
(;;)
expr
=
coerce_type
(
NULL
,
expr
,
typid
,
{
typbasetype
,
atttypmod
);
HeapTuple
tup
;
Form_pg_type
typTup
;
tup
=
SearchSysCache
(
TYPEOID
,
ObjectIdGetDatum
(
typid
),
0
,
0
,
0
);
if
(
!
HeapTupleIsValid
(
tup
))
elog
(
ERROR
,
"getBaseType: failed to lookup type %u"
,
typid
);
typTup
=
(
Form_pg_type
)
GETSTRUCT
(
tup
);
if
(
typTup
->
typtype
!=
'd'
)
{
/* Not a domain, so done */
ReleaseSysCache
(
tup
);
break
;
}
}
typid
=
typTup
->
typbasetype
;
ReleaseSysCache
(
tup
);
}
return
expr
;
return
typid
;
}
}
/*
/*
...
...
src/bin/psql/describe.c
View file @
337b22cb
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright 2000 by PostgreSQL Global Development Group
* Copyright 2000 by PostgreSQL Global Development Group
*
*
* $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.4
6 2002/03/19 02:32:21 momjian
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.4
7 2002/03/20 19:44:45 tgl
Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
#include "describe.h"
#include "describe.h"
...
@@ -1053,7 +1053,7 @@ listDomains(const char *name)
...
@@ -1053,7 +1053,7 @@ listDomains(const char *name)
snprintf
(
buf
,
sizeof
(
buf
),
snprintf
(
buf
,
sizeof
(
buf
),
"SELECT t.typname as
\"
%s
\"
,
\n
"
"SELECT t.typname as
\"
%s
\"
,
\n
"
" format_type( t.typbasetype, t.typmod) as
\"
%s
\"
,
\n
"
" format_type( t.typbasetype, t.typ
typ
mod) as
\"
%s
\"
,
\n
"
" CASE WHEN t.typnotnull AND t.typdefault IS NOT NULL THEN 'not null default '||t.typdefault
\n
"
" CASE WHEN t.typnotnull AND t.typdefault IS NOT NULL THEN 'not null default '||t.typdefault
\n
"
" WHEN t.typnotnull AND t.typdefault IS NULL THEN 'not null'
\n
"
" WHEN t.typnotnull AND t.typdefault IS NULL THEN 'not null'
\n
"
" WHEN NOT t.typnotnull AND t.typdefault IS NOT NULL THEN 'default '||t.typdefault
\n
"
" WHEN NOT t.typnotnull AND t.typdefault IS NOT NULL THEN 'default '||t.typdefault
\n
"
...
...
src/include/catalog/catversion.h
View file @
337b22cb
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: catversion.h,v 1.10
6 2002/03/12 00:51:59
tgl Exp $
* $Id: catversion.h,v 1.10
7 2002/03/20 19:44:48
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -53,6 +53,6 @@
...
@@ -53,6 +53,6 @@
*/
*/
/* yyyymmddN */
/* yyyymmddN */
#define CATALOG_VERSION_NO 2002031
1
1
#define CATALOG_VERSION_NO 2002031
9
1
#endif
#endif
src/include/catalog/heap.h
View file @
337b22cb
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: heap.h,v 1.4
5 2002/03/19 02:58:19 momjian
Exp $
* $Id: heap.h,v 1.4
6 2002/03/20 19:44:52 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -47,11 +47,11 @@ extern void AddRelationRawConstraints(Relation rel,
...
@@ -47,11 +47,11 @@ extern void AddRelationRawConstraints(Relation rel,
List
*
rawColDefaults
,
List
*
rawColDefaults
,
List
*
rawConstraints
);
List
*
rawConstraints
);
extern
Node
*
cookDefault
(
ParseState
*
pstate
extern
Node
*
cookDefault
(
ParseState
*
pstate
,
,
Node
*
raw_default
Node
*
raw_default
,
,
Oid
atttypid
Oid
atttypid
,
,
int32
atttypmod
int32
atttypmod
,
,
char
*
attname
);
char
*
attname
);
extern
int
RemoveCheckConstraint
(
Relation
rel
,
const
char
*
constrName
,
bool
inh
);
extern
int
RemoveCheckConstraint
(
Relation
rel
,
const
char
*
constrName
,
bool
inh
);
...
...
src/include/catalog/pg_attribute.h
View file @
337b22cb
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: pg_attribute.h,v 1.8
4 2002/03/19 02:18:22 momjian
Exp $
* $Id: pg_attribute.h,v 1.8
5 2002/03/20 19:44:55 tgl
Exp $
*
*
* NOTES
* NOTES
* the genbki.sh script reads this file and generates .bki
* the genbki.sh script reads this file and generates .bki
...
@@ -241,8 +241,8 @@ typedef FormData_pg_attribute *Form_pg_attribute;
...
@@ -241,8 +241,8 @@ typedef FormData_pg_attribute *Form_pg_attribute;
{ 1247, {"typalign"}, 18, 0, 1, 15, 0, -1, -1, true, 'p', false, 'c', false, false }, \
{ 1247, {"typalign"}, 18, 0, 1, 15, 0, -1, -1, true, 'p', false, 'c', false, false }, \
{ 1247, {"typstorage"}, 18, 0, 1, 16, 0, -1, -1, true, 'p', false, 'c', false, false }, \
{ 1247, {"typstorage"}, 18, 0, 1, 16, 0, -1, -1, true, 'p', false, 'c', false, false }, \
{ 1247, {"typnotnull"}, 16, 0, 1, 17, 0, -1, -1, true, 'p', false, 'c', false, false }, \
{ 1247, {"typnotnull"}, 16, 0, 1, 17, 0, -1, -1, true, 'p', false, 'c', false, false }, \
{ 1247, {"typ
mod"}, 23
, 0, 4, 18, 0, -1, -1, true, 'p', false, 'i', false, false }, \
{ 1247, {"typ
basetype"}, 26
, 0, 4, 18, 0, -1, -1, true, 'p', false, 'i', false, false }, \
{ 1247, {"typ
basetype"}, 26
, 0, 4, 19, 0, -1, -1, true, 'p', false, 'i', false, false }, \
{ 1247, {"typ
typmod"}, 23
, 0, 4, 19, 0, -1, -1, true, 'p', false, 'i', false, false }, \
{ 1247, {"typndims"}, 23, 0, 4, 20, 0, -1, -1, true, 'p', false, 'i', false, false }, \
{ 1247, {"typndims"}, 23, 0, 4, 20, 0, -1, -1, true, 'p', false, 'i', false, false }, \
{ 1247, {"typdefaultbin"}, 25, 0, -1, 21, 0, -1, -1, false, 'x', false, 'i', false, false }, \
{ 1247, {"typdefaultbin"}, 25, 0, -1, 21, 0, -1, -1, false, 'x', false, 'i', false, false }, \
{ 1247, {"typdefault"}, 25, 0, -1, 22, 0, -1, -1, false, 'x', false, 'i', false, false }
{ 1247, {"typdefault"}, 25, 0, -1, 22, 0, -1, -1, false, 'x', false, 'i', false, false }
...
@@ -265,8 +265,8 @@ DATA(insert ( 1247 typsend 24 0 4 14 0 -1 -1 t p f i f f));
...
@@ -265,8 +265,8 @@ DATA(insert ( 1247 typsend 24 0 4 14 0 -1 -1 t p f i f f));
DATA
(
insert
(
1247
typalign
18
0
1
15
0
-
1
-
1
t
p
f
c
f
f
));
DATA
(
insert
(
1247
typalign
18
0
1
15
0
-
1
-
1
t
p
f
c
f
f
));
DATA
(
insert
(
1247
typstorage
18
0
1
16
0
-
1
-
1
t
p
f
c
f
f
));
DATA
(
insert
(
1247
typstorage
18
0
1
16
0
-
1
-
1
t
p
f
c
f
f
));
DATA
(
insert
(
1247
typnotnull
16
0
1
17
0
-
1
-
1
t
p
f
c
f
f
));
DATA
(
insert
(
1247
typnotnull
16
0
1
17
0
-
1
-
1
t
p
f
c
f
f
));
DATA
(
insert
(
1247
typ
mod
23
0
4
18
0
-
1
-
1
t
p
f
i
f
f
));
DATA
(
insert
(
1247
typ
basetype
26
0
4
18
0
-
1
-
1
t
p
f
i
f
f
));
DATA
(
insert
(
1247
typ
basetype
26
0
4
19
0
-
1
-
1
t
p
f
i
f
f
));
DATA
(
insert
(
1247
typ
typmod
23
0
4
19
0
-
1
-
1
t
p
f
i
f
f
));
DATA
(
insert
(
1247
typndims
23
0
4
20
0
-
1
-
1
t
p
f
i
f
f
));
DATA
(
insert
(
1247
typndims
23
0
4
20
0
-
1
-
1
t
p
f
i
f
f
));
DATA
(
insert
(
1247
typdefaultbin
25
0
-
1
21
0
-
1
-
1
f
x
f
i
f
f
));
DATA
(
insert
(
1247
typdefaultbin
25
0
-
1
21
0
-
1
-
1
f
x
f
i
f
f
));
DATA
(
insert
(
1247
typdefault
25
0
-
1
22
0
-
1
-
1
f
x
f
i
f
f
));
DATA
(
insert
(
1247
typdefault
25
0
-
1
22
0
-
1
-
1
f
x
f
i
f
f
));
...
...
src/include/catalog/pg_type.h
View file @
337b22cb
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: pg_type.h,v 1.11
7 2002/03/19 02:18:23 momjian
Exp $
* $Id: pg_type.h,v 1.11
8 2002/03/20 19:44:57 tgl
Exp $
*
*
* NOTES
* NOTES
* the genbki.sh script reads this file and generates .bki
* the genbki.sh script reads this file and generates .bki
...
@@ -151,36 +151,41 @@ CATALOG(pg_type) BOOTSTRAP
...
@@ -151,36 +151,41 @@ CATALOG(pg_type) BOOTSTRAP
bool
typnotnull
;
bool
typnotnull
;
/*
/*
* typmod records type-specific data supplied at domain creation
* Domains use typbasetype to show the base (or complex) type that
* time (for example, the max length of a varchar field). It is
* the domain is based on. Zero if the type is not a domain.
* passed to type-specific input and output functions as the third
* argument. The value will generally be -1 for types that do not need
* typmod. This value is copied to pg_attribute.atttypmod.
*/
*/
int4
typmod
;
Oid
typbasetype
;
/*
/*
* Domains use typbasetype to determine the base (or complex)type that
* typtypmod records type-specific data supplied at domain creation
* the domain is based off. It must be non-zero if the type is a
* time (for example, the max length of a varchar field). It is
* domain.
* passed to type-specific input and output functions as the third
* argument. The value will generally be -1 for types that do not need
* typmod. This value is copied to pg_attribute.atttypmod when
* creating a column of a domain type.
*/
*/
Oid
typbasetype
;
int4
typtypmod
;
/*
/*
* typndims is the declared number of dimensions
, if an array typbasetype,
* typndims is the declared number of dimensions
for a domain type that
*
o
therwise zero.
*
is an array (with element type typbasetype). O
therwise zero.
*/
*/
int4
typndims
;
int4
typndims
;
/*
/*
* typdefaultbin is the binary representation of typdefault
* If typdefaultbin is not NULL, it is the nodeToString representation
* of a default expression for the type. Currently this is only used
* for domains.
*/
*/
text
typdefaultbin
;
/* VARIABLE LENGTH FIELD */
text
typdefaultbin
;
/* VARIABLE LENGTH FIELD */
/*
/*
* typdefault is NULL if the type has no associated default value. If
* typdefault is NULL if the type has no associated default value. If
* it's not NULL, it contains the external representation of the
* typdefaultbin is not NULL, typdefault must contain a human-readable
* type's default value
* version of the default expression represented by typdefaultbin.
* If typdefaultbin is NULL and typdefault is not, then typdefault is
* the external representation of the type's default value, which may
* be fed to the type's input converter to produce a constant.
*/
*/
text
typdefault
;
/* VARIABLE LENGTH FIELD */
text
typdefault
;
/* VARIABLE LENGTH FIELD */
...
@@ -215,8 +220,8 @@ typedef FormData_pg_type *Form_pg_type;
...
@@ -215,8 +220,8 @@ typedef FormData_pg_type *Form_pg_type;
#define Anum_pg_type_typalign 15
#define Anum_pg_type_typalign 15
#define Anum_pg_type_typstorage 16
#define Anum_pg_type_typstorage 16
#define Anum_pg_type_typnotnull 17
#define Anum_pg_type_typnotnull 17
#define Anum_pg_type_typ
mod
18
#define Anum_pg_type_typ
basetype
18
#define Anum_pg_type_typ
basetype
19
#define Anum_pg_type_typ
typmod
19
#define Anum_pg_type_typndims 20
#define Anum_pg_type_typndims 20
#define Anum_pg_type_typdefaultbin 21
#define Anum_pg_type_typdefaultbin 21
#define Anum_pg_type_typdefault 22
#define Anum_pg_type_typdefault 22
...
@@ -235,82 +240,82 @@ typedef FormData_pg_type *Form_pg_type;
...
@@ -235,82 +240,82 @@ typedef FormData_pg_type *Form_pg_type;
*/
*/
/* OIDS 1 - 99 */
/* OIDS 1 - 99 */
DATA
(
insert
OID
=
16
(
bool
PGUID
1
1
t
b
t
\
054
0
0
boolin
boolout
boolin
boolout
c
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
16
(
bool
PGUID
1
1
t
b
t
\
054
0
0
boolin
boolout
boolin
boolout
c
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"boolean, 'true'/'false'"
);
DESCR
(
"boolean, 'true'/'false'"
);
#define BOOLOID 16
#define BOOLOID 16
DATA
(
insert
OID
=
17
(
bytea
PGUID
-
1
-
1
f
b
t
\
054
0
0
byteain
byteaout
byteain
byteaout
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
17
(
bytea
PGUID
-
1
-
1
f
b
t
\
054
0
0
byteain
byteaout
byteain
byteaout
i
x
f
0
-
1
0
_null_
_null_
));
DESCR
(
"variable-length string, binary values escaped"
);
DESCR
(
"variable-length string, binary values escaped"
);
#define BYTEAOID 17
#define BYTEAOID 17
DATA
(
insert
OID
=
18
(
char
PGUID
1
1
t
b
t
\
054
0
0
charin
charout
charin
charout
c
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
18
(
char
PGUID
1
1
t
b
t
\
054
0
0
charin
charout
charin
charout
c
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"single character"
);
DESCR
(
"single character"
);
#define CHAROID 18
#define CHAROID 18
DATA
(
insert
OID
=
19
(
name
PGUID
NAMEDATALEN
NAMEDATALEN
f
b
t
\
054
0
18
namein
nameout
namein
nameout
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
19
(
name
PGUID
NAMEDATALEN
NAMEDATALEN
f
b
t
\
054
0
18
namein
nameout
namein
nameout
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"31-character type for storing system identifiers"
);
DESCR
(
"31-character type for storing system identifiers"
);
#define NAMEOID 19
#define NAMEOID 19
DATA
(
insert
OID
=
20
(
int8
PGUID
8
20
f
b
t
\
054
0
0
int8in
int8out
int8in
int8out
d
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
20
(
int8
PGUID
8
20
f
b
t
\
054
0
0
int8in
int8out
int8in
int8out
d
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"~18 digit integer, 8-byte storage"
);
DESCR
(
"~18 digit integer, 8-byte storage"
);
#define INT8OID 20
#define INT8OID 20
DATA
(
insert
OID
=
21
(
int2
PGUID
2
5
t
b
t
\
054
0
0
int2in
int2out
int2in
int2out
s
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
21
(
int2
PGUID
2
5
t
b
t
\
054
0
0
int2in
int2out
int2in
int2out
s
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"-32 thousand to 32 thousand, 2-byte storage"
);
DESCR
(
"-32 thousand to 32 thousand, 2-byte storage"
);
#define INT2OID 21
#define INT2OID 21
DATA
(
insert
OID
=
22
(
int2vector
PGUID
INDEX_MAX_KEYS
*
2
-
1
f
b
t
\
054
0
21
int2vectorin
int2vectorout
int2vectorin
int2vectorout
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
22
(
int2vector
PGUID
INDEX_MAX_KEYS
*
2
-
1
f
b
t
\
054
0
21
int2vectorin
int2vectorout
int2vectorin
int2vectorout
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"array of INDEX_MAX_KEYS int2 integers, used in system tables"
);
DESCR
(
"array of INDEX_MAX_KEYS int2 integers, used in system tables"
);
#define INT2VECTOROID 22
#define INT2VECTOROID 22
DATA
(
insert
OID
=
23
(
int4
PGUID
4
10
t
b
t
\
054
0
0
int4in
int4out
int4in
int4out
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
23
(
int4
PGUID
4
10
t
b
t
\
054
0
0
int4in
int4out
int4in
int4out
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"-2 billion to 2 billion integer, 4-byte storage"
);
DESCR
(
"-2 billion to 2 billion integer, 4-byte storage"
);
#define INT4OID 23
#define INT4OID 23
DATA
(
insert
OID
=
24
(
regproc
PGUID
4
16
t
b
t
\
054
0
0
regprocin
regprocout
regprocin
regprocout
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
24
(
regproc
PGUID
4
16
t
b
t
\
054
0
0
regprocin
regprocout
regprocin
regprocout
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"registered procedure"
);
DESCR
(
"registered procedure"
);
#define REGPROCOID 24
#define REGPROCOID 24
DATA
(
insert
OID
=
25
(
text
PGUID
-
1
-
1
f
b
t
\
054
0
0
textin
textout
textin
textout
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
25
(
text
PGUID
-
1
-
1
f
b
t
\
054
0
0
textin
textout
textin
textout
i
x
f
0
-
1
0
_null_
_null_
));
DESCR
(
"variable-length string, no limit specified"
);
DESCR
(
"variable-length string, no limit specified"
);
#define TEXTOID 25
#define TEXTOID 25
DATA
(
insert
OID
=
26
(
oid
PGUID
4
10
t
b
t
\
054
0
0
oidin
oidout
oidin
oidout
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
26
(
oid
PGUID
4
10
t
b
t
\
054
0
0
oidin
oidout
oidin
oidout
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"object identifier(oid), maximum 4 billion"
);
DESCR
(
"object identifier(oid), maximum 4 billion"
);
#define OIDOID 26
#define OIDOID 26
DATA
(
insert
OID
=
27
(
tid
PGUID
6
19
f
b
t
\
054
0
0
tidin
tidout
tidin
tidout
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
27
(
tid
PGUID
6
19
f
b
t
\
054
0
0
tidin
tidout
tidin
tidout
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"(Block, offset), physical location of tuple"
);
DESCR
(
"(Block, offset), physical location of tuple"
);
#define TIDOID 27
#define TIDOID 27
DATA
(
insert
OID
=
28
(
xid
PGUID
4
12
t
b
t
\
054
0
0
xidin
xidout
xidin
xidout
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
28
(
xid
PGUID
4
12
t
b
t
\
054
0
0
xidin
xidout
xidin
xidout
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"transaction id"
);
DESCR
(
"transaction id"
);
#define XIDOID 28
#define XIDOID 28
DATA
(
insert
OID
=
29
(
cid
PGUID
4
10
t
b
t
\
054
0
0
cidin
cidout
cidin
cidout
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
29
(
cid
PGUID
4
10
t
b
t
\
054
0
0
cidin
cidout
cidin
cidout
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"command identifier type, sequence in transaction id"
);
DESCR
(
"command identifier type, sequence in transaction id"
);
#define CIDOID 29
#define CIDOID 29
DATA
(
insert
OID
=
30
(
oidvector
PGUID
INDEX_MAX_KEYS
*
4
-
1
f
b
t
\
054
0
26
oidvectorin
oidvectorout
oidvectorin
oidvectorout
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
30
(
oidvector
PGUID
INDEX_MAX_KEYS
*
4
-
1
f
b
t
\
054
0
26
oidvectorin
oidvectorout
oidvectorin
oidvectorout
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"array of INDEX_MAX_KEYS oids, used in system tables"
);
DESCR
(
"array of INDEX_MAX_KEYS oids, used in system tables"
);
#define OIDVECTOROID 30
#define OIDVECTOROID 30
DATA
(
insert
OID
=
32
(
SET
PGUID
-
1
-
1
f
b
t
\
054
0
0
textin
textout
textin
textout
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
32
(
SET
PGUID
-
1
-
1
f
b
t
\
054
0
0
textin
textout
textin
textout
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"set of tuples"
);
DESCR
(
"set of tuples"
);
DATA
(
insert
OID
=
71
(
pg_type
PGUID
4
4
t
c
t
\
054
1247
0
int4in
int4out
int4in
int4out
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
71
(
pg_type
PGUID
4
4
t
c
t
\
054
1247
0
int4in
int4out
int4in
int4out
i
p
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
75
(
pg_attribute
PGUID
4
4
t
c
t
\
054
1249
0
int4in
int4out
int4in
int4out
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
75
(
pg_attribute
PGUID
4
4
t
c
t
\
054
1249
0
int4in
int4out
int4in
int4out
i
p
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
81
(
pg_proc
PGUID
4
4
t
c
t
\
054
1255
0
int4in
int4out
int4in
int4out
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
81
(
pg_proc
PGUID
4
4
t
c
t
\
054
1255
0
int4in
int4out
int4in
int4out
i
p
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
83
(
pg_class
PGUID
4
4
t
c
t
\
054
1259
0
int4in
int4out
int4in
int4out
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
83
(
pg_class
PGUID
4
4
t
c
t
\
054
1259
0
int4in
int4out
int4in
int4out
i
p
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
86
(
pg_shadow
PGUID
4
4
t
c
t
\
054
1260
0
int4in
int4out
int4in
int4out
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
86
(
pg_shadow
PGUID
4
4
t
c
t
\
054
1260
0
int4in
int4out
int4in
int4out
i
p
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
87
(
pg_group
PGUID
4
4
t
c
t
\
054
1261
0
int4in
int4out
int4in
int4out
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
87
(
pg_group
PGUID
4
4
t
c
t
\
054
1261
0
int4in
int4out
int4in
int4out
i
p
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
88
(
pg_database
PGUID
4
4
t
c
t
\
054
1262
0
int4in
int4out
int4in
int4out
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
88
(
pg_database
PGUID
4
4
t
c
t
\
054
1262
0
int4in
int4out
int4in
int4out
i
p
f
0
-
1
0
_null_
_null_
));
/* OIDS 100 - 199 */
/* OIDS 100 - 199 */
/* OIDS 200 - 299 */
/* OIDS 200 - 299 */
DATA
(
insert
OID
=
210
(
smgr
PGUID
2
12
t
b
t
\
054
0
0
smgrin
smgrout
smgrin
smgrout
s
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
210
(
smgr
PGUID
2
12
t
b
t
\
054
0
0
smgrin
smgrout
smgrin
smgrout
s
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"storage manager"
);
DESCR
(
"storage manager"
);
/* OIDS 300 - 399 */
/* OIDS 300 - 399 */
...
@@ -320,167 +325,167 @@ DESCR("storage manager");
...
@@ -320,167 +325,167 @@ DESCR("storage manager");
/* OIDS 500 - 599 */
/* OIDS 500 - 599 */
/* OIDS 600 - 699 */
/* OIDS 600 - 699 */
DATA
(
insert
OID
=
600
(
point
PGUID
16
24
f
b
t
\
054
0
701
point_in
point_out
point_in
point_out
d
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
600
(
point
PGUID
16
24
f
b
t
\
054
0
701
point_in
point_out
point_in
point_out
d
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"geometric point '(x, y)'"
);
DESCR
(
"geometric point '(x, y)'"
);
#define POINTOID 600
#define POINTOID 600
DATA
(
insert
OID
=
601
(
lseg
PGUID
32
48
f
b
t
\
054
0
600
lseg_in
lseg_out
lseg_in
lseg_out
d
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
601
(
lseg
PGUID
32
48
f
b
t
\
054
0
600
lseg_in
lseg_out
lseg_in
lseg_out
d
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"geometric line segment '(pt1,pt2)'"
);
DESCR
(
"geometric line segment '(pt1,pt2)'"
);
#define LSEGOID 601
#define LSEGOID 601
DATA
(
insert
OID
=
602
(
path
PGUID
-
1
-
1
f
b
t
\
054
0
0
path_in
path_out
path_in
path_out
d
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
602
(
path
PGUID
-
1
-
1
f
b
t
\
054
0
0
path_in
path_out
path_in
path_out
d
x
f
0
-
1
0
_null_
_null_
));
DESCR
(
"geometric path '(pt1,...)'"
);
DESCR
(
"geometric path '(pt1,...)'"
);
#define PATHOID 602
#define PATHOID 602
DATA
(
insert
OID
=
603
(
box
PGUID
32
100
f
b
t
\
073
0
600
box_in
box_out
box_in
box_out
d
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
603
(
box
PGUID
32
100
f
b
t
\
073
0
600
box_in
box_out
box_in
box_out
d
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"geometric box '(lower left,upper right)'"
);
DESCR
(
"geometric box '(lower left,upper right)'"
);
#define BOXOID 603
#define BOXOID 603
DATA
(
insert
OID
=
604
(
polygon
PGUID
-
1
-
1
f
b
t
\
054
0
0
poly_in
poly_out
poly_in
poly_out
d
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
604
(
polygon
PGUID
-
1
-
1
f
b
t
\
054
0
0
poly_in
poly_out
poly_in
poly_out
d
x
f
0
-
1
0
_null_
_null_
));
DESCR
(
"geometric polygon '(pt1,...)'"
);
DESCR
(
"geometric polygon '(pt1,...)'"
);
#define POLYGONOID 604
#define POLYGONOID 604
DATA
(
insert
OID
=
628
(
line
PGUID
32
48
f
b
t
\
054
0
701
line_in
line_out
line_in
line_out
d
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
628
(
line
PGUID
32
48
f
b
t
\
054
0
701
line_in
line_out
line_in
line_out
d
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"geometric line '(pt1,pt2)'"
);
DESCR
(
"geometric line '(pt1,pt2)'"
);
#define LINEOID 628
#define LINEOID 628
DATA
(
insert
OID
=
629
(
_line
PGUID
-
1
-
1
f
b
t
\
054
0
628
array_in
array_out
array_in
array_out
d
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
629
(
_line
PGUID
-
1
-
1
f
b
t
\
054
0
628
array_in
array_out
array_in
array_out
d
x
f
0
-
1
0
_null_
_null_
));
DESCR
(
""
);
DESCR
(
""
);
/* OIDS 700 - 799 */
/* OIDS 700 - 799 */
DATA
(
insert
OID
=
700
(
float4
PGUID
4
12
f
b
t
\
054
0
0
float4in
float4out
float4in
float4out
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
700
(
float4
PGUID
4
12
f
b
t
\
054
0
0
float4in
float4out
float4in
float4out
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"single-precision floating point number, 4-byte storage"
);
DESCR
(
"single-precision floating point number, 4-byte storage"
);
#define FLOAT4OID 700
#define FLOAT4OID 700
DATA
(
insert
OID
=
701
(
float8
PGUID
8
24
f
b
t
\
054
0
0
float8in
float8out
float8in
float8out
d
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
701
(
float8
PGUID
8
24
f
b
t
\
054
0
0
float8in
float8out
float8in
float8out
d
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"double-precision floating point number, 8-byte storage"
);
DESCR
(
"double-precision floating point number, 8-byte storage"
);
#define FLOAT8OID 701
#define FLOAT8OID 701
DATA
(
insert
OID
=
702
(
abstime
PGUID
4
20
t
b
t
\
054
0
0
nabstimein
nabstimeout
nabstimein
nabstimeout
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
702
(
abstime
PGUID
4
20
t
b
t
\
054
0
0
nabstimein
nabstimeout
nabstimein
nabstimeout
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"absolute, limited-range date and time (Unix system time)"
);
DESCR
(
"absolute, limited-range date and time (Unix system time)"
);
#define ABSTIMEOID 702
#define ABSTIMEOID 702
DATA
(
insert
OID
=
703
(
reltime
PGUID
4
20
t
b
t
\
054
0
0
reltimein
reltimeout
reltimein
reltimeout
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
703
(
reltime
PGUID
4
20
t
b
t
\
054
0
0
reltimein
reltimeout
reltimein
reltimeout
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"relative, limited-range time interval (Unix delta time)"
);
DESCR
(
"relative, limited-range time interval (Unix delta time)"
);
#define RELTIMEOID 703
#define RELTIMEOID 703
DATA
(
insert
OID
=
704
(
tinterval
PGUID
12
47
f
b
t
\
054
0
0
tintervalin
tintervalout
tintervalin
tintervalout
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
704
(
tinterval
PGUID
12
47
f
b
t
\
054
0
0
tintervalin
tintervalout
tintervalin
tintervalout
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"(abstime,abstime), time interval"
);
DESCR
(
"(abstime,abstime), time interval"
);
#define TINTERVALOID 704
#define TINTERVALOID 704
DATA
(
insert
OID
=
705
(
unknown
PGUID
-
1
-
1
f
b
t
\
054
0
0
textin
textout
textin
textout
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
705
(
unknown
PGUID
-
1
-
1
f
b
t
\
054
0
0
textin
textout
textin
textout
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
""
);
DESCR
(
""
);
#define UNKNOWNOID 705
#define UNKNOWNOID 705
DATA
(
insert
OID
=
718
(
circle
PGUID
24
47
f
b
t
\
054
0
0
circle_in
circle_out
circle_in
circle_out
d
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
718
(
circle
PGUID
24
47
f
b
t
\
054
0
0
circle_in
circle_out
circle_in
circle_out
d
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"geometric circle '(center,radius)'"
);
DESCR
(
"geometric circle '(center,radius)'"
);
#define CIRCLEOID 718
#define CIRCLEOID 718
DATA
(
insert
OID
=
719
(
_circle
PGUID
-
1
-
1
f
b
t
\
054
0
718
array_in
array_out
array_in
array_out
d
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
719
(
_circle
PGUID
-
1
-
1
f
b
t
\
054
0
718
array_in
array_out
array_in
array_out
d
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
790
(
money
PGUID
4
24
f
b
t
\
054
0
0
cash_in
cash_out
cash_in
cash_out
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
790
(
money
PGUID
4
24
f
b
t
\
054
0
0
cash_in
cash_out
cash_in
cash_out
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"$d,ddd.cc, money"
);
DESCR
(
"$d,ddd.cc, money"
);
#define CASHOID 790
#define CASHOID 790
DATA
(
insert
OID
=
791
(
_money
PGUID
-
1
-
1
f
b
t
\
054
0
790
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
791
(
_money
PGUID
-
1
-
1
f
b
t
\
054
0
790
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
/* OIDS 800 - 899 */
/* OIDS 800 - 899 */
DATA
(
insert
OID
=
829
(
macaddr
PGUID
6
-
1
f
b
t
\
054
0
0
macaddr_in
macaddr_out
macaddr_in
macaddr_out
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
829
(
macaddr
PGUID
6
-
1
f
b
t
\
054
0
0
macaddr_in
macaddr_out
macaddr_in
macaddr_out
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"XX:XX:XX:XX:XX:XX, MAC address"
);
DESCR
(
"XX:XX:XX:XX:XX:XX, MAC address"
);
#define MACADDROID 829
#define MACADDROID 829
DATA
(
insert
OID
=
869
(
inet
PGUID
-
1
-
1
f
b
t
\
054
0
0
inet_in
inet_out
inet_in
inet_out
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
869
(
inet
PGUID
-
1
-
1
f
b
t
\
054
0
0
inet_in
inet_out
inet_in
inet_out
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"IP address/netmask, host address, netmask optional"
);
DESCR
(
"IP address/netmask, host address, netmask optional"
);
#define INETOID 869
#define INETOID 869
DATA
(
insert
OID
=
650
(
cidr
PGUID
-
1
-
1
f
b
t
\
054
0
0
cidr_in
cidr_out
cidr_in
cidr_out
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
650
(
cidr
PGUID
-
1
-
1
f
b
t
\
054
0
0
cidr_in
cidr_out
cidr_in
cidr_out
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"network IP address/netmask, network address"
);
DESCR
(
"network IP address/netmask, network address"
);
#define CIDROID 650
#define CIDROID 650
/* OIDS 900 - 999 */
/* OIDS 900 - 999 */
/* OIDS 1000 - 1099 */
/* OIDS 1000 - 1099 */
DATA
(
insert
OID
=
1000
(
_bool
PGUID
-
1
-
1
f
b
t
\
054
0
16
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1000
(
_bool
PGUID
-
1
-
1
f
b
t
\
054
0
16
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1001
(
_bytea
PGUID
-
1
-
1
f
b
t
\
054
0
17
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1001
(
_bytea
PGUID
-
1
-
1
f
b
t
\
054
0
17
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1002
(
_char
PGUID
-
1
-
1
f
b
t
\
054
0
18
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1002
(
_char
PGUID
-
1
-
1
f
b
t
\
054
0
18
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1003
(
_name
PGUID
-
1
-
1
f
b
t
\
054
0
19
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1003
(
_name
PGUID
-
1
-
1
f
b
t
\
054
0
19
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1005
(
_int2
PGUID
-
1
-
1
f
b
t
\
054
0
21
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1005
(
_int2
PGUID
-
1
-
1
f
b
t
\
054
0
21
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1006
(
_int2vector
PGUID
-
1
-
1
f
b
t
\
054
0
22
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1006
(
_int2vector
PGUID
-
1
-
1
f
b
t
\
054
0
22
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1007
(
_int4
PGUID
-
1
-
1
f
b
t
\
054
0
23
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1007
(
_int4
PGUID
-
1
-
1
f
b
t
\
054
0
23
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1008
(
_regproc
PGUID
-
1
-
1
f
b
t
\
054
0
24
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1008
(
_regproc
PGUID
-
1
-
1
f
b
t
\
054
0
24
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1009
(
_text
PGUID
-
1
-
1
f
b
t
\
054
0
25
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1009
(
_text
PGUID
-
1
-
1
f
b
t
\
054
0
25
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1028
(
_oid
PGUID
-
1
-
1
f
b
t
\
054
0
26
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1028
(
_oid
PGUID
-
1
-
1
f
b
t
\
054
0
26
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1010
(
_tid
PGUID
-
1
-
1
f
b
t
\
054
0
27
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1010
(
_tid
PGUID
-
1
-
1
f
b
t
\
054
0
27
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1011
(
_xid
PGUID
-
1
-
1
f
b
t
\
054
0
28
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1011
(
_xid
PGUID
-
1
-
1
f
b
t
\
054
0
28
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1012
(
_cid
PGUID
-
1
-
1
f
b
t
\
054
0
29
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1012
(
_cid
PGUID
-
1
-
1
f
b
t
\
054
0
29
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1013
(
_oidvector
PGUID
-
1
-
1
f
b
t
\
054
0
30
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1013
(
_oidvector
PGUID
-
1
-
1
f
b
t
\
054
0
30
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1014
(
_bpchar
PGUID
-
1
-
1
f
b
t
\
054
0
1042
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1014
(
_bpchar
PGUID
-
1
-
1
f
b
t
\
054
0
1042
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1015
(
_varchar
PGUID
-
1
-
1
f
b
t
\
054
0
1043
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1015
(
_varchar
PGUID
-
1
-
1
f
b
t
\
054
0
1043
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1016
(
_int8
PGUID
-
1
-
1
f
b
t
\
054
0
20
array_in
array_out
array_in
array_out
d
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1016
(
_int8
PGUID
-
1
-
1
f
b
t
\
054
0
20
array_in
array_out
array_in
array_out
d
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1017
(
_point
PGUID
-
1
-
1
f
b
t
\
054
0
600
array_in
array_out
array_in
array_out
d
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1017
(
_point
PGUID
-
1
-
1
f
b
t
\
054
0
600
array_in
array_out
array_in
array_out
d
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1018
(
_lseg
PGUID
-
1
-
1
f
b
t
\
054
0
601
array_in
array_out
array_in
array_out
d
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1018
(
_lseg
PGUID
-
1
-
1
f
b
t
\
054
0
601
array_in
array_out
array_in
array_out
d
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1019
(
_path
PGUID
-
1
-
1
f
b
t
\
054
0
602
array_in
array_out
array_in
array_out
d
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1019
(
_path
PGUID
-
1
-
1
f
b
t
\
054
0
602
array_in
array_out
array_in
array_out
d
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1020
(
_box
PGUID
-
1
-
1
f
b
t
\
073
0
603
array_in
array_out
array_in
array_out
d
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1020
(
_box
PGUID
-
1
-
1
f
b
t
\
073
0
603
array_in
array_out
array_in
array_out
d
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1021
(
_float4
PGUID
-
1
-
1
f
b
t
\
054
0
700
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1021
(
_float4
PGUID
-
1
-
1
f
b
t
\
054
0
700
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1022
(
_float8
PGUID
-
1
-
1
f
b
t
\
054
0
701
array_in
array_out
array_in
array_out
d
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1022
(
_float8
PGUID
-
1
-
1
f
b
t
\
054
0
701
array_in
array_out
array_in
array_out
d
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1023
(
_abstime
PGUID
-
1
-
1
f
b
t
\
054
0
702
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1023
(
_abstime
PGUID
-
1
-
1
f
b
t
\
054
0
702
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1024
(
_reltime
PGUID
-
1
-
1
f
b
t
\
054
0
703
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1024
(
_reltime
PGUID
-
1
-
1
f
b
t
\
054
0
703
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1025
(
_tinterval
PGUID
-
1
-
1
f
b
t
\
054
0
704
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1025
(
_tinterval
PGUID
-
1
-
1
f
b
t
\
054
0
704
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1027
(
_polygon
PGUID
-
1
-
1
f
b
t
\
054
0
604
array_in
array_out
array_in
array_out
d
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1027
(
_polygon
PGUID
-
1
-
1
f
b
t
\
054
0
604
array_in
array_out
array_in
array_out
d
x
f
0
-
1
0
_null_
_null_
));
/*
/*
* Note: the size of aclitem needs to match sizeof(AclItem) in acl.h.
* Note: the size of aclitem needs to match sizeof(AclItem) in acl.h.
* Thanks to some padding, this will be 8 on all platforms.
* Thanks to some padding, this will be 8 on all platforms.
* We also have an Assert to make sure.
* We also have an Assert to make sure.
*/
*/
#define ACLITEMSIZE 8
#define ACLITEMSIZE 8
DATA
(
insert
OID
=
1033
(
aclitem
PGUID
8
-
1
f
b
t
\
054
0
0
aclitemin
aclitemout
aclitemin
aclitemout
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1033
(
aclitem
PGUID
8
-
1
f
b
t
\
054
0
0
aclitemin
aclitemout
aclitemin
aclitemout
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"access control list"
);
DESCR
(
"access control list"
);
DATA
(
insert
OID
=
1034
(
_aclitem
PGUID
-
1
-
1
f
b
t
\
054
0
1033
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1034
(
_aclitem
PGUID
-
1
-
1
f
b
t
\
054
0
1033
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1040
(
_macaddr
PGUID
-
1
-
1
f
b
t
\
054
0
829
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1040
(
_macaddr
PGUID
-
1
-
1
f
b
t
\
054
0
829
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1041
(
_inet
PGUID
-
1
-
1
f
b
t
\
054
0
869
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1041
(
_inet
PGUID
-
1
-
1
f
b
t
\
054
0
869
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
651
(
_cidr
PGUID
-
1
-
1
f
b
t
\
054
0
650
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
651
(
_cidr
PGUID
-
1
-
1
f
b
t
\
054
0
650
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1042
(
bpchar
PGUID
-
1
-
1
f
b
t
\
054
0
0
bpcharin
bpcharout
bpcharin
bpcharout
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1042
(
bpchar
PGUID
-
1
-
1
f
b
t
\
054
0
0
bpcharin
bpcharout
bpcharin
bpcharout
i
x
f
0
-
1
0
_null_
_null_
));
DESCR
(
"char(length), blank-padded string, fixed storage length"
);
DESCR
(
"char(length), blank-padded string, fixed storage length"
);
#define BPCHAROID 1042
#define BPCHAROID 1042
DATA
(
insert
OID
=
1043
(
varchar
PGUID
-
1
-
1
f
b
t
\
054
0
0
varcharin
varcharout
varcharin
varcharout
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1043
(
varchar
PGUID
-
1
-
1
f
b
t
\
054
0
0
varcharin
varcharout
varcharin
varcharout
i
x
f
0
-
1
0
_null_
_null_
));
DESCR
(
"varchar(length), non-blank-padded string, variable storage length"
);
DESCR
(
"varchar(length), non-blank-padded string, variable storage length"
);
#define VARCHAROID 1043
#define VARCHAROID 1043
DATA
(
insert
OID
=
1082
(
date
PGUID
4
10
t
b
t
\
054
0
0
date_in
date_out
date_in
date_out
i
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1082
(
date
PGUID
4
10
t
b
t
\
054
0
0
date_in
date_out
date_in
date_out
i
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"ANSI SQL date"
);
DESCR
(
"ANSI SQL date"
);
#define DATEOID 1082
#define DATEOID 1082
DATA
(
insert
OID
=
1083
(
time
PGUID
8
16
f
b
t
\
054
0
0
time_in
time_out
time_in
time_out
d
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1083
(
time
PGUID
8
16
f
b
t
\
054
0
0
time_in
time_out
time_in
time_out
d
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"hh:mm:ss, ANSI SQL time"
);
DESCR
(
"hh:mm:ss, ANSI SQL time"
);
#define TIMEOID 1083
#define TIMEOID 1083
/* OIDS 1100 - 1199 */
/* OIDS 1100 - 1199 */
DATA
(
insert
OID
=
1114
(
timestamp
PGUID
8
47
f
b
t
\
054
0
0
timestamp_in
timestamp_out
timestamp_in
timestamp_out
d
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1114
(
timestamp
PGUID
8
47
f
b
t
\
054
0
0
timestamp_in
timestamp_out
timestamp_in
timestamp_out
d
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"date and time"
);
DESCR
(
"date and time"
);
#define TIMESTAMPOID 1114
#define TIMESTAMPOID 1114
DATA
(
insert
OID
=
1115
(
_timestamp
PGUID
-
1
-
1
f
b
t
\
054
0
1184
array_in
array_out
array_in
array_out
d
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1115
(
_timestamp
PGUID
-
1
-
1
f
b
t
\
054
0
1184
array_in
array_out
array_in
array_out
d
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1182
(
_date
PGUID
-
1
-
1
f
b
t
\
054
0
1082
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1182
(
_date
PGUID
-
1
-
1
f
b
t
\
054
0
1082
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1183
(
_time
PGUID
-
1
-
1
f
b
t
\
054
0
1083
array_in
array_out
array_in
array_out
d
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1183
(
_time
PGUID
-
1
-
1
f
b
t
\
054
0
1083
array_in
array_out
array_in
array_out
d
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1184
(
timestamptz
PGUID
8
47
f
b
t
\
054
0
0
timestamptz_in
timestamptz_out
timestamptz_in
timestamptz_out
d
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1184
(
timestamptz
PGUID
8
47
f
b
t
\
054
0
0
timestamptz_in
timestamptz_out
timestamptz_in
timestamptz_out
d
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"date and time with time zone"
);
DESCR
(
"date and time with time zone"
);
#define TIMESTAMPTZOID 1184
#define TIMESTAMPTZOID 1184
DATA
(
insert
OID
=
1185
(
_timestamptz
PGUID
-
1
-
1
f
b
t
\
054
0
1184
array_in
array_out
array_in
array_out
d
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1185
(
_timestamptz
PGUID
-
1
-
1
f
b
t
\
054
0
1184
array_in
array_out
array_in
array_out
d
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1186
(
interval
PGUID
12
47
f
b
t
\
054
0
0
interval_in
interval_out
interval_in
interval_out
d
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1186
(
interval
PGUID
12
47
f
b
t
\
054
0
0
interval_in
interval_out
interval_in
interval_out
d
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"@ <number> <units>, time interval"
);
DESCR
(
"@ <number> <units>, time interval"
);
#define INTERVALOID 1186
#define INTERVALOID 1186
DATA
(
insert
OID
=
1187
(
_interval
PGUID
-
1
-
1
f
b
t
\
054
0
1186
array_in
array_out
array_in
array_out
d
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1187
(
_interval
PGUID
-
1
-
1
f
b
t
\
054
0
1186
array_in
array_out
array_in
array_out
d
x
f
0
-
1
0
_null_
_null_
));
/* OIDS 1200 - 1299 */
/* OIDS 1200 - 1299 */
DATA
(
insert
OID
=
1231
(
_numeric
PGUID
-
1
-
1
f
b
t
\
054
0
1700
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1231
(
_numeric
PGUID
-
1
-
1
f
b
t
\
054
0
1700
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1266
(
timetz
PGUID
12
22
f
b
t
\
054
0
0
timetz_in
timetz_out
timetz_in
timetz_out
d
p
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1266
(
timetz
PGUID
12
22
f
b
t
\
054
0
0
timetz_in
timetz_out
timetz_in
timetz_out
d
p
f
0
-
1
0
_null_
_null_
));
DESCR
(
"hh:mm:ss, ANSI SQL time"
);
DESCR
(
"hh:mm:ss, ANSI SQL time"
);
#define TIMETZOID 1266
#define TIMETZOID 1266
DATA
(
insert
OID
=
1270
(
_timetz
PGUID
-
1
-
1
f
b
t
\
054
0
1266
array_in
array_out
array_in
array_out
d
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1270
(
_timetz
PGUID
-
1
-
1
f
b
t
\
054
0
1266
array_in
array_out
array_in
array_out
d
x
f
0
-
1
0
_null_
_null_
));
/* OIDS 1500 - 1599 */
/* OIDS 1500 - 1599 */
DATA
(
insert
OID
=
1560
(
bit
PGUID
-
1
-
1
f
b
t
\
054
0
0
bit_in
bit_out
bit_in
bit_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1560
(
bit
PGUID
-
1
-
1
f
b
t
\
054
0
0
bit_in
bit_out
bit_in
bit_out
i
x
f
0
-
1
0
_null_
_null_
));
DESCR
(
"fixed-length bit string"
);
DESCR
(
"fixed-length bit string"
);
#define BITOID 1560
#define BITOID 1560
DATA
(
insert
OID
=
1561
(
_bit
PGUID
-
1
-
1
f
b
t
\
054
0
1560
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1561
(
_bit
PGUID
-
1
-
1
f
b
t
\
054
0
1560
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
DATA
(
insert
OID
=
1562
(
varbit
PGUID
-
1
-
1
f
b
t
\
054
0
0
varbit_in
varbit_out
varbit_in
varbit_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1562
(
varbit
PGUID
-
1
-
1
f
b
t
\
054
0
0
varbit_in
varbit_out
varbit_in
varbit_out
i
x
f
0
-
1
0
_null_
_null_
));
DESCR
(
"variable-length bit string"
);
DESCR
(
"variable-length bit string"
);
#define VARBITOID 1562
#define VARBITOID 1562
DATA
(
insert
OID
=
1563
(
_varbit
PGUID
-
1
-
1
f
b
t
\
054
0
1562
array_in
array_out
array_in
array_out
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1563
(
_varbit
PGUID
-
1
-
1
f
b
t
\
054
0
1562
array_in
array_out
array_in
array_out
i
x
f
0
-
1
0
_null_
_null_
));
/* OIDS 1600 - 1699 */
/* OIDS 1600 - 1699 */
/* OIDS 1700 - 1799 */
/* OIDS 1700 - 1799 */
DATA
(
insert
OID
=
1700
(
numeric
PGUID
-
1
-
1
f
b
t
\
054
0
0
numeric_in
numeric_out
numeric_in
numeric_out
i
m
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1700
(
numeric
PGUID
-
1
-
1
f
b
t
\
054
0
0
numeric_in
numeric_out
numeric_in
numeric_out
i
m
f
0
-
1
0
_null_
_null_
));
DESCR
(
"numeric(precision, decimal), arbitrary precision number"
);
DESCR
(
"numeric(precision, decimal), arbitrary precision number"
);
#define NUMERICOID 1700
#define NUMERICOID 1700
/* OID 1790 */
/* OID 1790 */
DATA
(
insert
OID
=
1790
(
refcursor
PGUID
-
1
-
1
f
b
t
\
054
0
0
textin
textout
textin
textout
i
x
f
-
1
0
0
_null_
_null_
));
DATA
(
insert
OID
=
1790
(
refcursor
PGUID
-
1
-
1
f
b
t
\
054
0
0
textin
textout
textin
textout
i
x
f
0
-
1
0
_null_
_null_
));
DESCR
(
"reference cursor (portal name)"
);
DESCR
(
"reference cursor (portal name)"
);
#define REFCURSOROID 1790
#define REFCURSOROID 1790
...
...
src/include/nodes/makefuncs.h
View file @
337b22cb
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: makefuncs.h,v 1.3
0 2001/11/05 17:46:34 momjian
Exp $
* $Id: makefuncs.h,v 1.3
1 2002/03/20 19:45:01 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -46,4 +46,6 @@ extern Const *makeNullConst(Oid consttype);
...
@@ -46,4 +46,6 @@ extern Const *makeNullConst(Oid consttype);
extern
Attr
*
makeAttr
(
char
*
relname
,
char
*
attname
);
extern
Attr
*
makeAttr
(
char
*
relname
,
char
*
attname
);
extern
RelabelType
*
makeRelabelType
(
Node
*
arg
,
Oid
rtype
,
int32
rtypmod
);
#endif
/* MAKEFUNC_H */
#endif
/* MAKEFUNC_H */
src/include/nodes/parsenodes.h
View file @
337b22cb
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: parsenodes.h,v 1.16
1 2002/03/19 02:18:24 momjian
Exp $
* $Id: parsenodes.h,v 1.16
2 2002/03/20 19:45:02 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -407,23 +407,6 @@ typedef struct DefElem
...
@@ -407,23 +407,6 @@ typedef struct DefElem
}
DefElem
;
}
DefElem
;
/****************************************************************************
* Nodes for a Domain Creation tree
****************************************************************************/
/* ----------------------
* CreateDomain Statement
* ----------------------
* Down here as it required TypeName to be defined first.
*/
typedef
struct
CreateDomainStmt
{
NodeTag
type
;
char
*
domainname
;
/* name of domain to create */
TypeName
*
typename
;
/* the typecast */
List
*
constraints
;
/* constraints (list of Constraint nodes) */
}
CreateDomainStmt
;
/****************************************************************************
/****************************************************************************
* Nodes for a Query tree
* Nodes for a Query tree
****************************************************************************/
****************************************************************************/
...
@@ -1056,11 +1039,23 @@ typedef struct VersionStmt
...
@@ -1056,11 +1039,23 @@ typedef struct VersionStmt
typedef
struct
DefineStmt
typedef
struct
DefineStmt
{
{
NodeTag
type
;
NodeTag
type
;
int
defType
;
/* OPERATOR|
P_TYPE
|AGGREGATE */
int
defType
;
/* OPERATOR|
TYPE_P
|AGGREGATE */
char
*
defname
;
char
*
defname
;
List
*
definition
;
/* a list of DefElem */
List
*
definition
;
/* a list of DefElem */
}
DefineStmt
;
}
DefineStmt
;
/* ----------------------
* Create Domain Statement
* ----------------------
*/
typedef
struct
CreateDomainStmt
{
NodeTag
type
;
char
*
domainname
;
/* name of domain to create */
TypeName
*
typename
;
/* the base type */
List
*
constraints
;
/* constraints (list of Constraint nodes) */
}
CreateDomainStmt
;
/* ----------------------
/* ----------------------
* Drop Table|Sequence|View|Index|Rule|Type Statement
* Drop Table|Sequence|View|Index|Rule|Type Statement
* ----------------------
* ----------------------
...
@@ -1071,8 +1066,8 @@ typedef struct DefineStmt
...
@@ -1071,8 +1066,8 @@ typedef struct DefineStmt
#define DROP_VIEW 3
#define DROP_VIEW 3
#define DROP_INDEX 4
#define DROP_INDEX 4
#define DROP_RULE 5
#define DROP_RULE 5
#define DROP_TYPE
_P
6
#define DROP_TYPE
6
#define DROP_DOMAIN
_P
7
#define DROP_DOMAIN
7
typedef
struct
DropStmt
typedef
struct
DropStmt
{
{
...
...
src/include/parser/parse_coerce.h
View file @
337b22cb
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: parse_coerce.h,v 1.4
0 2002/03/19 02:18:24 momjian
Exp $
* $Id: parse_coerce.h,v 1.4
1 2002/03/20 19:45:07 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -34,38 +34,7 @@ typedef enum CATEGORY
...
@@ -34,38 +34,7 @@ typedef enum CATEGORY
}
CATEGORY
;
}
CATEGORY
;
/* IS_BINARY_COMPATIBLE()
extern
bool
IsBinaryCompatible
(
Oid
type1
,
Oid
type2
);
* Check for types with the same underlying binary representation.
* This allows us to cheat and directly exchange values without
* going through the trouble of calling a conversion function.
*
* Remove equivalencing of FLOAT8 and TIMESTAMP. They really are not
* close enough in behavior, with the TIMESTAMP reserved values
* and special formatting. - thomas 1999-01-24
*/
#define IS_BINARY_COMPATIBLE(a,b) \
(((a) == BPCHAROID && (b) == TEXTOID) \
|| ((a) == BPCHAROID && (b) == VARCHAROID) \
|| ((a) == VARCHAROID && (b) == TEXTOID) \
|| ((a) == VARCHAROID && (b) == BPCHAROID) \
|| ((a) == TEXTOID && (b) == BPCHAROID) \
|| ((a) == TEXTOID && (b) == VARCHAROID) \
|| ((a) == OIDOID && (b) == INT4OID) \
|| ((a) == OIDOID && (b) == REGPROCOID) \
|| ((a) == INT4OID && (b) == OIDOID) \
|| ((a) == INT4OID && (b) == REGPROCOID) \
|| ((a) == REGPROCOID && (b) == OIDOID) \
|| ((a) == REGPROCOID && (b) == INT4OID) \
|| ((a) == ABSTIMEOID && (b) == INT4OID) \
|| ((a) == INT4OID && (b) == ABSTIMEOID) \
|| ((a) == RELTIMEOID && (b) == INT4OID) \
|| ((a) == INT4OID && (b) == RELTIMEOID) \
|| ((a) == INETOID && (b) == CIDROID) \
|| ((a) == CIDROID && (b) == INETOID) \
|| ((a) == BITOID && (b) == VARBITOID) \
|| ((a) == VARBITOID && (b) == BITOID))
extern
bool
IsPreferredType
(
CATEGORY
category
,
Oid
type
);
extern
bool
IsPreferredType
(
CATEGORY
category
,
Oid
type
);
extern
CATEGORY
TypeCategory
(
Oid
type
);
extern
CATEGORY
TypeCategory
(
Oid
type
);
...
@@ -81,6 +50,5 @@ extern Oid select_common_type(List *typeids, const char *context);
...
@@ -81,6 +50,5 @@ extern Oid select_common_type(List *typeids, const char *context);
extern
Node
*
coerce_to_common_type
(
ParseState
*
pstate
,
Node
*
node
,
extern
Node
*
coerce_to_common_type
(
ParseState
*
pstate
,
Node
*
node
,
Oid
targetTypeId
,
Oid
targetTypeId
,
const
char
*
context
);
const
char
*
context
);
extern
Oid
getBaseType
(
Oid
inType
);
#endif
/* PARSE_COERCE_H */
#endif
/* PARSE_COERCE_H */
src/include/utils/lsyscache.h
View file @
337b22cb
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: lsyscache.h,v 1.4
3 2002/03/19 02:18:24 momjian
Exp $
* $Id: lsyscache.h,v 1.4
4 2002/03/20 19:45:09 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -44,7 +44,8 @@ extern int16 get_typlen(Oid typid);
...
@@ -44,7 +44,8 @@ extern int16 get_typlen(Oid typid);
extern
bool
get_typbyval
(
Oid
typid
);
extern
bool
get_typbyval
(
Oid
typid
);
extern
void
get_typlenbyval
(
Oid
typid
,
int16
*
typlen
,
bool
*
typbyval
);
extern
void
get_typlenbyval
(
Oid
typid
,
int16
*
typlen
,
bool
*
typbyval
);
extern
char
get_typstorage
(
Oid
typid
);
extern
char
get_typstorage
(
Oid
typid
);
extern
Node
*
get_typdefault
(
Oid
typid
,
int32
atttypmod
);
extern
Node
*
get_typdefault
(
Oid
typid
);
extern
Oid
getBaseType
(
Oid
typid
);
extern
int32
get_typavgwidth
(
Oid
typid
,
int32
typmod
);
extern
int32
get_typavgwidth
(
Oid
typid
,
int32
typmod
);
extern
int32
get_attavgwidth
(
Oid
relid
,
AttrNumber
attnum
);
extern
int32
get_attavgwidth
(
Oid
relid
,
AttrNumber
attnum
);
extern
bool
get_attstatsslot
(
HeapTuple
statstuple
,
extern
bool
get_attstatsslot
(
HeapTuple
statstuple
,
...
...
src/test/regress/expected/domain.out
View file @
337b22cb
...
@@ -3,9 +3,9 @@ create domain domaindroptest int4;
...
@@ -3,9 +3,9 @@ create domain domaindroptest int4;
comment on domain domaindroptest is 'About to drop this..';
comment on domain domaindroptest is 'About to drop this..';
create domain basetypetest domaindroptest;
create domain basetypetest domaindroptest;
ERROR: DefineDomain: domaindroptest is not a basetype
ERROR: DefineDomain: domaindroptest is not a basetype
drop domain domaindroptest cascade;
ERROR: DROP DOMAIN does not support the CASCADE keyword
drop domain domaindroptest;
drop domain domaindroptest;
ERROR: parser: parse error at or near ";"
drop domain domaindroptest restrict;
-- TEST Domains.
-- TEST Domains.
create domain domainvarchar varchar(5);
create domain domainvarchar varchar(5);
create domain domainnumeric numeric(8,2);
create domain domainnumeric numeric(8,2);
...
@@ -29,11 +29,21 @@ select * from basictest;
...
@@ -29,11 +29,21 @@ select * from basictest;
88 | haha | short | 123.12
88 | haha | short | 123.12
(2 rows)
(2 rows)
-- check that domains inherit operations from base types
-- XXX shouldn't have to quote the constant here
select testtext || testvarchar as concat, testnumeric + '42' as sum
from basictest;
concat | sum
-----------+--------
hahashort | 165.12
hahashort | 165.12
(2 rows)
drop table basictest;
drop table basictest;
drop domain domainvarchar restrict;
drop domain domainvarchar restrict;
drop domain domainnumeric restrict;
drop domain domainnumeric restrict;
drop domain domainint4 restrict;
drop domain domainint4 restrict;
drop domain domaintext
restrict
;
drop domain domaintext;
-- Array Test
-- Array Test
create domain domainint4arr int4[1];
create domain domainint4arr int4[1];
create domain domaintextarr text[2][3];
create domain domaintextarr text[2][3];
...
@@ -46,6 +56,26 @@ INSERT INTO domarrtest values ('{{2,2}{2,2}}', '{{"a","b"}}');
...
@@ -46,6 +56,26 @@ INSERT INTO domarrtest values ('{{2,2}{2,2}}', '{{"a","b"}}');
INSERT INTO domarrtest values ('{2,2}', '{{"a","b"}{"c","d"}{"e"}}');
INSERT INTO domarrtest values ('{2,2}', '{{"a","b"}{"c","d"}{"e"}}');
INSERT INTO domarrtest values ('{2,2}', '{{"a"}{"c"}}');
INSERT INTO domarrtest values ('{2,2}', '{{"a"}{"c"}}');
INSERT INTO domarrtest values (NULL, '{{"a","b"}{"c","d","e"}}');
INSERT INTO domarrtest values (NULL, '{{"a","b"}{"c","d","e"}}');
select * from domarrtest;
testint4arr | testtextarr
---------------+---------------------
{2,2} | {{a,c},{"",d}}
{{2,2},{0,2}} | {{a,b}}
{2,2} | {{a},{c},{e}}
{2,2} | {{c},{""}}
| {{a,c,""},{"",d,e}}
(5 rows)
select testint4arr[1], testtextarr[2:2] from domarrtest;
testint4arr | testtextarr
-------------+-------------
2 | {{"",d}}
|
2 | {{c}}
2 | {{""}}
| {{"",d,e}}
(5 rows)
drop table domarrtest;
drop table domarrtest;
drop domain domainint4arr restrict;
drop domain domainint4arr restrict;
drop domain domaintextarr restrict;
drop domain domaintextarr restrict;
...
...
src/test/regress/sql/domain.sql
View file @
337b22cb
...
@@ -6,8 +6,8 @@ comment on domain domaindroptest is 'About to drop this..';
...
@@ -6,8 +6,8 @@ comment on domain domaindroptest is 'About to drop this..';
create
domain
basetypetest
domaindroptest
;
create
domain
basetypetest
domaindroptest
;
drop
domain
domaindroptest
cascade
;
drop
domain
domaindroptest
;
drop
domain
domaindroptest
;
drop
domain
domaindroptest
restrict
;
-- TEST Domains.
-- TEST Domains.
...
@@ -31,11 +31,16 @@ INSERT INTO basictest values ('88', 'haha', 'short text', '123.12'); -- Bad varc
...
@@ -31,11 +31,16 @@ INSERT INTO basictest values ('88', 'haha', 'short text', '123.12'); -- Bad varc
INSERT
INTO
basictest
values
(
'88'
,
'haha'
,
'short'
,
'123.1212'
);
-- Truncate numeric
INSERT
INTO
basictest
values
(
'88'
,
'haha'
,
'short'
,
'123.1212'
);
-- Truncate numeric
select
*
from
basictest
;
select
*
from
basictest
;
-- check that domains inherit operations from base types
-- XXX shouldn't have to quote the constant here
select
testtext
||
testvarchar
as
concat
,
testnumeric
+
'42'
as
sum
from
basictest
;
drop
table
basictest
;
drop
table
basictest
;
drop
domain
domainvarchar
restrict
;
drop
domain
domainvarchar
restrict
;
drop
domain
domainnumeric
restrict
;
drop
domain
domainnumeric
restrict
;
drop
domain
domainint4
restrict
;
drop
domain
domainint4
restrict
;
drop
domain
domaintext
restrict
;
drop
domain
domaintext
;
-- Array Test
-- Array Test
...
@@ -51,6 +56,8 @@ INSERT INTO domarrtest values ('{{2,2}{2,2}}', '{{"a","b"}}');
...
@@ -51,6 +56,8 @@ INSERT INTO domarrtest values ('{{2,2}{2,2}}', '{{"a","b"}}');
INSERT
INTO
domarrtest
values
(
'{2,2}'
,
'{{"a","b"}{"c","d"}{"e"}}'
);
INSERT
INTO
domarrtest
values
(
'{2,2}'
,
'{{"a","b"}{"c","d"}{"e"}}'
);
INSERT
INTO
domarrtest
values
(
'{2,2}'
,
'{{"a"}{"c"}}'
);
INSERT
INTO
domarrtest
values
(
'{2,2}'
,
'{{"a"}{"c"}}'
);
INSERT
INTO
domarrtest
values
(
NULL
,
'{{"a","b"}{"c","d","e"}}'
);
INSERT
INTO
domarrtest
values
(
NULL
,
'{{"a","b"}{"c","d","e"}}'
);
select
*
from
domarrtest
;
select
testint4arr
[
1
],
testtextarr
[
2
:
2
]
from
domarrtest
;
drop
table
domarrtest
;
drop
table
domarrtest
;
drop
domain
domainint4arr
restrict
;
drop
domain
domainint4arr
restrict
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment