Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y1hlf-0004Y2-Ik for pgsql-bugs@arkaria.postgresql.org; Thu, 18 Dec 2014 20:33:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y1hle-0001Jk-L2 for pgsql-bugs@arkaria.postgresql.org; Thu, 18 Dec 2014 20:33:50 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y1hld-0001JP-He for pgsql-bugs@postgresql.org; Thu, 18 Dec 2014 20:33:49 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y1hla-00055P-G2 for pgsql-bugs@postgresql.org; Thu, 18 Dec 2014 20:33:47 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id sBIKXiLo002653; Thu, 18 Dec 2014 15:33:44 -0500 From: Tom Lane To: David Johnston cc: "pgsql-bugs@postgresql.org" Subject: Re: BUG #12273: CASE Expression BUG In-reply-to: References: <20141218144436.1237.96696@wrigleys.postgresql.org> <16630.1418918898@sss.pgh.pa.us> <1418921627518-5831325.post@n5.nabble.com> <17992.1418922882@sss.pgh.pa.us> <2065.1418933405@sss.pgh.pa.us> Comments: In-reply-to David Johnston message dated "Thu, 18 Dec 2014 13:26:53 -0700" Date: Thu, 18 Dec 2014 15:33:44 -0500 Message-ID: <2652.1418934824@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org David Johnston writes: > "so that the principle that CASE > does not evaluate any subexpressions that are not needed to determine > the result is not ironclad." > so the principle that [...] only evaluates necessary subexpressions is not > ironclad. OK, done that way. > The problem with your example is that the following does not error: > SELECT CASE WHEN false THEN 1/0 ELSE 1 END; That's why that isn't the example ;-). In this case, since the WHEN is a constant, the constant-expression simplifier itself figures out that it can throw away the THEN expression and replace the whole CASE with the ELSE expression. So it doesn't bother const-simplifying the THEN, hence no error. > While it is a great word I don't really believe "panacea" is good for our > documentation given the diverse English language experiences of its readers. Hm. "cure-all" maybe? > "the values of function parameters" == "function arguments" ... though not > everyone is fully aware (or remembers) the difference between arguments and > parameters. OK. > "Thus for example in [...] functions..." -> Therefore, in [...] functions > it is more reliable to use an [...] statement to protect a risky [...] > statement compared to using a nested CASE expression. Meh. The same principle applies in other languages too, so I don't think your wording is an improvement. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs