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
216e63bb
Commit
216e63bb
authored
Jan 23, 2008
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid mathematical inconsistency in example about avoiding division by
zero with a CASE expression. Per gripe from Russell Smith.
parent
8984c8bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
doc/src/sgml/syntax.sgml
doc/src/sgml/syntax.sgml
+4
-4
No files found.
doc/src/sgml/syntax.sgml
View file @
216e63bb
<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.12
0 2007/12/11 18:30:20 mha
Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.12
1 2008/01/23 19:51:29 tgl
Exp $ -->
<chapter id="sql-syntax">
<chapter id="sql-syntax">
<title>SQL Syntax</title>
<title>SQL Syntax</title>
...
@@ -1740,15 +1740,15 @@ SELECT somefunc() OR true;
...
@@ -1740,15 +1740,15 @@ SELECT somefunc() OR true;
used. For example, this is an untrustworthy way of trying to
used. For example, this is an untrustworthy way of trying to
avoid division by zero in a <literal>WHERE</> clause:
avoid division by zero in a <literal>WHERE</> clause:
<programlisting>
<programlisting>
SELECT ... WHERE x &
lt;&
gt; 0 AND y/x > 1.5;
SELECT ... WHERE x > 0 AND y/x > 1.5;
</programlisting>
</programlisting>
But this is safe:
But this is safe:
<programlisting>
<programlisting>
SELECT ... WHERE CASE WHEN x &
lt;&
gt; 0 THEN y/x > 1.5 ELSE false END;
SELECT ... WHERE CASE WHEN x > 0 THEN y/x > 1.5 ELSE false END;
</programlisting>
</programlisting>
A <literal>CASE</> construct used in this fashion will defeat optimization
A <literal>CASE</> construct used in this fashion will defeat optimization
attempts, so it should only be done when necessary. (In this particular
attempts, so it should only be done when necessary. (In this particular
example, it would be be
st
to sidestep the problem by writing
example, it would be be
tter
to sidestep the problem by writing
<literal>y > 1.5*x</> instead.)
<literal>y > 1.5*x</> instead.)
</para>
</para>
</sect2>
</sect2>
...
...
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