Re: BUG #12273: CASE Expression BUG

From: David Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #12273: CASE Expression BUG
Date: 2014-12-18 21:12:05
Message-ID: CAKFQuwa6BJDf_qu3VJahLXt8NFdXmdaQHS39LiDCbZiifeSzDg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Dec 18, 2014 at 1:33 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> David Johnston <david(dot)g(dot)johnston(at)gmail(dot)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.
>

​Is the example with the "WITH" CTE too involved to use instead?​

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

Maybe "miracle cure" - ​though "cure-all" isn't bad. Maybe solicit the
opinion of a couple of non-English speakers.

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

​Your's just didn't read that well to me...though the overall content was
good. Maybe drop "Thus" and just lead with "Within PL/pgSQL functions, for
example, using an IF [...]"

​David J.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2014-12-18 21:14:26 Re: BUG #12273: CASE Expression BUG
Previous Message Tom Lane 2014-12-18 20:33:44 Re: BUG #12273: CASE Expression BUG