Re: BUG #12273: CASE Expression BUG

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

David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> Tom Lane-2 wrote
>> We're unlikely to change this, because it would cripple optimization
>> attempts. The fact that const-simplification doesn't happen in the other
>> way you wrote the function is not more-correct behavior, it's just an
>> implementation artifact that you shouldn't rely on. What you need to do
>> is code this as an if-then-else sequence, not CASE, so that you don't
>> attempt to evaluate any expressions with undefined constant
>> subexpressions.

> Note that this is documented here:
> http://www.postgresql.org/docs/9.4/interactive/functions-conditional.html#FUNCTIONS-CASE
> Specifically, the "Note" at the end of 9.17.1

Hmm ... I'd just been looking at 4.2.14:
http://www.postgresql.org/docs/9.4/static/sql-expressions.html#SYNTAX-EXPRESS-EVAL
and thinking that maybe it should mention this. Perhaps we ought to
relocate the text about constant subexpressions into 4.2.14 (and add an
example), and then link there from 9.17.1.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Johnston 2014-12-18 19:40:26 Re: BUG #12273: CASE Expression BUG
Previous Message David G Johnston 2014-12-18 16:53:47 Re: BUG #12273: CASE Expression BUG