pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: brandystodd@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18965: Issue with Short-Circuit Evaluation in Boolean Expressions
Date: Fri, 20 Jun 2025 14:37:10 -0400
Message-ID: <2145178.1750444630@sss.pgh.pa.us> (raw)
In-Reply-To: <18965-89456ea7e640a053@postgresql.org>
References: <18965-89456ea7e640a053@postgresql.org>

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





view thread (5+ messages)  latest in thread

Message-ID: <2145178.1750444630@sss.pgh.pa.us>
Permalink:  ../2145178.1750444630@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2145178.1750444630@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, brandystodd@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18965: Issue with Short-Circuit Evaluation in Boolean Expressions
  In-Reply-To: <2145178.1750444630@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox