Re: BUG #18965: Issue with Short-Circuit Evaluation in Boolean Expressions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: brandystodd(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18965: Issue with Short-Circuit Evaluation in Boolean Expressions
Date: 2025-06-20 18:37:10
Message-ID: 2145178.1750444630@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Nathan Bossart 2025-06-20 19:53:43 Re: BUG #18964: `ALTER DATABASE ... RESET ...` fails to reset extension parameters that no longer exist
Previous Message David G. Johnston 2025-06-20 18:14:22 Re: BUG #18965: Issue with Short-Circuit Evaluation in Boolean Expressions