I want to draw attention to this thread on -general:
CAMQ5dGq4SuJPbhT2-9XLAPAsvKNUL2-bb0cPyci2Fp+pfSfc3g@mail.gmail.com
Would you concur that this is a bug?
The fine manual says about CASE:
If the condition's result is true, the value of the CASE expression is the result that follows the condition, and the
remainderof the CASE expression is not processed.
But:
test=> CREATE FUNCTION zero() RETURNS integer IMMUTABLE LANGUAGE SQL AS 'SELECT 0';
CREATE FUNCTION
test=> SELECT CASE WHEN (SELECT zero()) = 0 THEN -1 ELSE 1/zero() END;
ERROR: division by zero
Yours,
Laurenz Albe