Re: BUG #18965: Issue with Short-Circuit Evaluation in Boolean Expressions - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #18965: Issue with Short-Circuit Evaluation in Boolean Expressions
Date
Msg-id 2145178.1750444630@sss.pgh.pa.us
Whole thread Raw
In response to BUG #18965: Issue with Short-Circuit Evaluation in Boolean Expressions  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> CREATE OR REPLACE FUNCTION raise(
>     IN          i_msg           text
> )
> RETURNS text AS $$
> BEGIN
>     RAISE EXCEPTION '%', i_msg;
>     RETURN ''::text;
> END;$$
> LANGUAGE PLPGSQL
> IMMUTABLE STRICT;

I think the fundamental problem you're having is that you marked
this function IMMUTABLE, which gives the planner license to
pre-evaluate it.  It had better be VOLATILE to discourage advance
evaluation.

https://www.postgresql.org/docs/current/xfunc-volatility.html

            regards, tom lane



pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #18965: Issue with Short-Circuit Evaluation in Boolean Expressions
Next
From: Nathan Bossart
Date:
Subject: Re: BUG #18964: `ALTER DATABASE ... RESET ...` fails to reset extension parameters that no longer exist