Re: Unexpected behaviour of a RAISE statement in an IMMUTABLE function

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Joel Mukuthu <jom(at)upright(dot)co>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Unexpected behaviour of a RAISE statement in an IMMUTABLE function
Date: 2022-11-23 16:14:48
Message-ID: CAKFQuwY=t2HXng-0pAZtxk89zpTGAF-i_QVB-naazhFUmRVt3A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Nov 23, 2022 at 9:01 AM Joel Mukuthu <jom(at)upright(dot)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.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2022-11-23 16:20:26 Re: Unexpected behaviour of a RAISE statement in an IMMUTABLE function
Previous Message PG Bug reporting form 2022-11-23 14:46:47 BUG #17693: Slow performance: Much slower queries on pg_stat_all_tables since 13.4