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
da1534d9
Commit
da1534d9
authored
Mar 20, 2003
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-add type conversion examples.
parent
2e6f9756
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
1 deletion
+52
-1
doc/src/sgml/typeconv.sgml
doc/src/sgml/typeconv.sgml
+52
-1
No files found.
doc/src/sgml/typeconv.sgml
View file @
da1534d9
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/typeconv.sgml,v 1.2
8 2003/03/19 21:20:5
2 momjian Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/typeconv.sgml,v 1.2
9 2003/03/20 16:17:3
2 momjian Exp $
-->
<chapter Id="typeconv">
...
...
@@ -403,6 +403,57 @@ type to resolve the unknown literals to.
</para>
</example>
<example>
<title>Absolute-Value and Factorial Operator Type Resolution</title>
<para>
The <productname>PostgreSQL</productname> operator catalog has several
entries for the prefix operator <literal>@</>, all of which implement
absolute-value operations for various numeric data types. One of these
entries is for type <type>float8</type>, which is the preferred type in
the numeric category. Therefore, <productname>PostgreSQL</productname>
will use that entry when faced with a non-numeric input:
<screen>
SELECT @ '-4.5' AS "abs";
abs
-----
4.5
(1 row)
</screen>
Here the system has performed an implicit conversion from <type>text</type> to <type>float8</type>
before applying the chosen operator. We can verify that <type>float8</type> and
not some other type was used:
<screen>
SELECT @ '-4.5e500' AS "abs";
ERROR: Input '-4.5e500' is out of range for float8
</screen>
</para>
<para>
On the other hand, the postfix operator <literal>!</> (factorial)
is defined only for integer data types, not for <type>float8</type>. So, if we
try a similar case with <literal>!</>, we get:
<screen>
SELECT '20' ! AS "factorial";
ERROR: Unable to identify a postfix operator '!' for type 'text'
You may need to add parentheses or an explicit cast
</screen>
This happens because the system can't decide which of the several
possible <literal>!</> operators should be preferred. We can help
it out with an explicit cast:
<screen>
SELECT CAST('20' AS int8) ! AS "factorial";
factorial
---------------------
2432902008176640000
(1 row)
</screen>
</para>
</example>
</sect1>
<sect1 id="typeconv-func">
...
...
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