From c704a6abcdf1b584d01623775baa46110e0214a8 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 23 Jan 2008 19:51:29 +0000 Subject: [PATCH] Avoid mathematical inconsistency in example about avoiding division by zero with a CASE expression. Per gripe from Russell Smith. --- doc/src/sgml/syntax.sgml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgml index 7ec0e859b5..70fe502854 100644 --- a/doc/src/sgml/syntax.sgml +++ b/doc/src/sgml/syntax.sgml @@ -1740,15 +1740,15 @@ SELECT somefunc() OR true; used. For example, this is an untrustworthy way of trying to avoid division by zero in a WHERE clause: -SELECT ... WHERE x <> 0 AND y/x > 1.5; +SELECT ... WHERE x > 0 AND y/x > 1.5; But this is safe: -SELECT ... WHERE CASE WHEN x <> 0 THEN y/x > 1.5 ELSE false END; +SELECT ... WHERE CASE WHEN x > 0 THEN y/x > 1.5 ELSE false END; A CASE construct used in this fashion will defeat optimization attempts, so it should only be done when necessary. (In this particular - example, it would be best to sidestep the problem by writing + example, it would be better to sidestep the problem by writing y > 1.5*x instead.) -- 2.39.5