Re: BUG #12273: CASE Expression BUG - Mailing list pgsql-bugs

From David Johnston
Subject Re: BUG #12273: CASE Expression BUG
Date
Msg-id CAKFQuwa6BJDf_qu3VJahLXt8NFdXmdaQHS39LiDCbZiifeSzDg@mail.gmail.com
Whole thread Raw
In response to Re: BUG #12273: CASE Expression BUG  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #12273: CASE Expression BUG
List pgsql-bugs
On Thu, Dec 18, 2014 at 1:33 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> 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.
>

=E2=80=8BIs the example with the "WITH" CTE too involved to use instead?=E2=
=80=8B


>
> > While it is a great word I don't really believe "panacea" is good for o=
ur
> > documentation given the diverse English language experiences of its
> readers.
>
> Hm.  "cure-all" maybe?
>

Maybe "miracle cure" - =E2=80=8Bthough "cure-all" isn't bad.  Maybe solicit=
 the
opinion of a couple of non-English speakers.


> > "the values of function parameters" =3D=3D "function arguments" ... tho=
ugh
> not
> > everyone is fully aware (or remembers) the difference between arguments
> and
> > parameters.
>
> OK.
>
> > "Thus for example in [...] functions..." -> Therefore, in [...] functio=
ns
> > 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.
>

=E2=80=8BYour's just didn't read that well to me...though the overall conte=
nt was
good.  Maybe drop "Thus" and just lead with "Within PL/pgSQL functions, for
example, using an IF [...]"

=E2=80=8BDavid J.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #12273: CASE Expression BUG
Next
From: Tom Lane
Date:
Subject: Re: BUG #12273: CASE Expression BUG