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
19032215
Commit
19032215
authored
Sep 01, 2002
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor copy-editing.
parent
681ed4e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
doc/src/sgml/ref/create_cast.sgml
doc/src/sgml/ref/create_cast.sgml
+9
-8
No files found.
doc/src/sgml/ref/create_cast.sgml
View file @
19032215
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_cast.sgml,v 1.
2 2002/08/11 17:44:12 petere
Exp $ -->
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_cast.sgml,v 1.
3 2002/09/01 02:37:02 tgl
Exp $ -->
<refentry id="SQL-CREATECAST">
<refentry id="SQL-CREATECAST">
<refmeta>
<refmeta>
...
@@ -28,8 +28,8 @@ CREATE CAST (<replaceable>sourcetype</replaceable> AS <replaceable>targettype</r
...
@@ -28,8 +28,8 @@ CREATE CAST (<replaceable>sourcetype</replaceable> AS <replaceable>targettype</r
<para>
<para>
<command>CREATE CAST</command> defines a new cast. A cast
<command>CREATE CAST</command> defines a new cast. A cast
specifies
which function can be invoked when
a conversion between
specifies
how to perform
a conversion between
two data types
is requested
. For example,
two data types. For example,
<programlisting>
<programlisting>
SELECT CAST(42 AS text);
SELECT CAST(42 AS text);
</programlisting>
</programlisting>
...
@@ -49,7 +49,7 @@ SELECT CAST(42 AS text);
...
@@ -49,7 +49,7 @@ SELECT CAST(42 AS text);
</para>
</para>
<para>
<para>
A cast can marked <literal>AS ASSIGNMENT</>, which means that it
A cast can
be
marked <literal>AS ASSIGNMENT</>, which means that it
can be invoked implicitly in any context where the conversion it
can be invoked implicitly in any context where the conversion it
defines is required. Cast functions not so marked can be invoked
defines is required. Cast functions not so marked can be invoked
only by explicit <literal>CAST</>,
only by explicit <literal>CAST</>,
...
@@ -72,7 +72,7 @@ INSERT INTO foo(f1) VALUES(42);
...
@@ -72,7 +72,7 @@ INSERT INTO foo(f1) VALUES(42);
<productname>PostgreSQL</productname> to choose surprising
<productname>PostgreSQL</productname> to choose surprising
interpretations of commands, or to be unable to resolve commands at
interpretations of commands, or to be unable to resolve commands at
all because there are multiple possible interpretations. A good
all because there are multiple possible interpretations. A good
rule of thumb is to make cast implicitly invokable only for
rule of thumb is to make
a
cast implicitly invokable only for
information-preserving transformations between types in the same
information-preserving transformations between types in the same
general type category. For example, <type>int2</type> to
general type category. For example, <type>int2</type> to
<type>int4</type> casts can reasonably be implicit, but be wary of
<type>int4</type> casts can reasonably be implicit, but be wary of
...
@@ -161,9 +161,10 @@ INSERT INTO foo(f1) VALUES(42);
...
@@ -161,9 +161,10 @@ INSERT INTO foo(f1) VALUES(42);
<para>
<para>
Prior to PostgreSQL 7.3, every function that had the same name as a
Prior to PostgreSQL 7.3, every function that had the same name as a
data type, returned that data type, and took one argument of a
data type, returned that data type, and took one argument of a
different type was automatically a cast function. This
system
has
different type was automatically a cast function. This
convention
has
been abandoned in face of the introduction of schemas and to be
been abandoned in face of the introduction of schemas and to be
able to store binary compatible casts. The built-in cast functions
able to represent binary compatible casts in the catalogs. The built-in
cast functions
still follow this naming scheme, but they have to be declared as
still follow this naming scheme, but they have to be declared as
casts explicitly now.
casts explicitly now.
</para>
</para>
...
@@ -175,7 +176,7 @@ INSERT INTO foo(f1) VALUES(42);
...
@@ -175,7 +176,7 @@ INSERT INTO foo(f1) VALUES(42);
<para>
<para>
To create a cast from type <type>text</type> to type
To create a cast from type <type>text</type> to type
<type>int</type> using the function <literal>int4(text)</literal>:
<type>int
4
</type> using the function <literal>int4(text)</literal>:
<programlisting>
<programlisting>
CREATE CAST (text AS int4) WITH FUNCTION int4(text);
CREATE CAST (text AS int4) WITH FUNCTION int4(text);
</programlisting>
</programlisting>
...
...
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