From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Johnston <david.g.johnston@gmail.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #12273: CASE Expression BUG
Date: Thu, 18 Dec 2014 15:33:44 -0500
Message-ID: <2652.1418934824@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwZSe+Fs1HGdJe0JMd9Qsx7PvT1rWgO+rAjfv+f59UGjog@mail.gmail.com>
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>
<CAKFQuwbPwB92rKdqaXO8qyp2KV_oDKNX3Hzae4XSCYeHZLctag@mail.gmail.com>
<2065.1418933405@sss.pgh.pa.us>
<CAKFQuwZSe+Fs1HGdJe0JMd9Qsx7PvT1rWgO+rAjfv+f59UGjog@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
David Johnston <david.g.johnston@gmail.com> writes:
> "so that the principle that <quote><token>CASE</token>
> does not evaluate any subexpressions that are not needed to determine
> the result</quote> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com
Subject: Re: BUG #12273: CASE Expression BUG
In-Reply-To: <2652.1418934824@sss.pgh.pa.us>
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> <CAKFQuwbPwB92rKdqaXO8qyp2KV_oDKNX3Hzae4XSCYeHZLctag@mail.gmail.com> <2065.1418933405@sss.pgh.pa.us> <CAKFQuwZSe+Fs1HGdJe0JMd9Qsx7PvT1rWgO+rAjfv+f59UGjog@mail.gmail.com> <2652.1418934824@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox