Re: Unexpected behaviour of a RAISE statement in an IMMUTABLE function - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: Unexpected behaviour of a RAISE statement in an IMMUTABLE function
Date
Msg-id CAKFQuwY=t2HXng-0pAZtxk89zpTGAF-i_QVB-naazhFUmRVt3A@mail.gmail.com
Whole thread Raw
In response to Unexpected behaviour of a RAISE statement in an IMMUTABLE function  (Joel Mukuthu <jom@upright.co>)
List pgsql-bugs
On Wed, Nov 23, 2022 at 9:01 AM Joel Mukuthu <jom@upright.co> wrote:

Given the following two functions, where the only difference between them is that one is VOLATILE while the other is IMMUTABLE:


That is a huge difference


Is this behaviour expected?


Yes.

RAISE is a side-effect inducing statement, which disqualifies the function from being IMMUTABLE.

The immutable marker gives the system permission to execute the function, given constant arguments, once to find out what the value of that function is during the execution of the query and make decisions based upon that result.

David J.

pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #17693: Slow performance: Much slower queries on pg_stat_all_tables since 13.4
Next
From: Tom Lane
Date:
Subject: Re: Unexpected behaviour of a RAISE statement in an IMMUTABLE function