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

From Tom Lane
Subject Re: BUG #12273: CASE Expression BUG
Date
Msg-id 17992.1418922882@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #12273: CASE Expression BUG  (David G Johnston <david.g.johnston@gmail.com>)
Responses Re: BUG #12273: CASE Expression BUG
List pgsql-bugs
David G Johnston <david.g.johnston@gmail.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

pgsql-bugs by date:

Previous
From: David G Johnston
Date:
Subject: Re: BUG #12273: CASE Expression BUG
Next
From: David Johnston
Date:
Subject: Re: BUG #12273: CASE Expression BUG