Re: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE" - Mailing list pgsql-general

From Kyotaro Horiguchi
Subject Re: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"
Date
Msg-id 20230711.101429.1932905481648331125.horikyota.ntt@gmail.com
Whole thread Raw
In response to Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"  (Avi Weinberg <AviW@gilat.com>)
Responses Re: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
List pgsql-general
At Sun, 9 Jul 2023 14:22:37 +0000, Avi Weinberg <AviW@gilat.com> wrote in 
> Hi,
> 
> If you attempt to create an index based on function that is not IMMUTABLE you will get an exception "ERROR:
functionsin index predicate must be marked IMMUTABLE".  However, if you created the index when the function was
IMMUTABLE,but later on you updated the function and mistakenly removed the IMMUTABLE key, you will not get any error to
alertyou that there is an index based on this function and it should remain IMMUTABLE.
 
> 
> I suggest triggering error message also when updating a function that is used by index if it is no longer IMMUTABLE

There's no way to truly verify a function is really immutable or
not. So, as mentioned in the documentation, the function volatility
categories are essentially a promise to the optimizer regarding the
function's behavior.

Even given this, premising users keeping the volatility marks in line
with the actual behavior of their corresponding functions, it might be
benetifical to prohibit changes to the volatility category while it's
being used for indices. In the first place, that protecting indices
from entering an inconsistent state, at least on the surface.

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



pgsql-general by date:

Previous
From: Johnathan Tiamoh
Date:
Subject: Re: Need Help On Upgrade
Next
From: Ian Lawrence Barwick
Date:
Subject: Re: Is anyone using db_user_namespace?