Re: BUG #13973: Constants resolved in then/else clauses

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: harry(dot)townsend(at)eflowglobal(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13973: Constants resolved in then/else clauses
Date: 2016-02-18 16:50:52
Message-ID: 20160218165052.GA952091@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

harry(dot)townsend(at)eflowglobal(dot)com wrote:
> The following bug has been logged on the website:
>
> Bug reference: 13973
> Logged by: Harry Townsend
> Email address: harry(dot)townsend(at)eflowglobal(dot)com
> PostgreSQL version: 9.1.20
> Operating system: Windows Server 2008
> Description:
>
> I attempted to create a safety check in a query using a "case when"
> statement such that if the condition evaluated to false, it would return (1
> / 0) in order to nullify the entire transaction. With small conditions, this
> works fine. With larger ones, it seems that the constants in the "else"
> clause (didn't test for "then" clause) are evaluated before the condition,
> causing it to fail every time. If the "else" part requires a column value,
> it seems to force the condition to evaluate first though.

Can you show a complete example?

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2016-02-18 16:52:03 Re: BUG #13972: jsonb_to_record cant map camelcase keys
Previous Message David G. Johnston 2016-02-18 16:48:51 Re: BUG #13973: Constants resolved in then/else clauses