Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit216e63b

Browse files
committed
Avoid mathematical inconsistency in example about avoiding division by
zero with a CASE expression. Per gripe from Russell Smith.
1 parent8984c8b commit216e63b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎doc/src/sgml/syntax.sgml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.120 2007/12/11 18:30:20 mha Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.121 2008/01/23 19:51:29 tgl Exp $ -->
22

33
<chapter id="sql-syntax">
44
<title>SQL Syntax</title>
@@ -1740,15 +1740,15 @@ SELECT somefunc() OR true;
17401740
used. For example, this is an untrustworthy way of trying to
17411741
avoid division by zero in a <literal>WHERE</> clause:
17421742
<programlisting>
1743-
SELECT ... WHERE x &lt;&gt; 0 AND y/x &gt; 1.5;
1743+
SELECT ... WHERE x &gt; 0 AND y/x &gt; 1.5;
17441744
</programlisting>
17451745
But this is safe:
17461746
<programlisting>
1747-
SELECT ... WHERE CASE WHEN x &lt;&gt; 0 THEN y/x &gt; 1.5 ELSE false END;
1747+
SELECT ... WHERE CASE WHEN x &gt; 0 THEN y/x &gt; 1.5 ELSE false END;
17481748
</programlisting>
17491749
A <literal>CASE</> construct used in this fashion will defeat optimization
17501750
attempts, so it should only be done when necessary. (In this particular
1751-
example, it would bebest to sidestep the problem by writing
1751+
example, it would bebetter to sidestep the problem by writing
17521752
<literal>y &gt; 1.5*x</> instead.)
17531753
</para>
17541754
</sect2>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp