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

From Tom Lane
Subject Re: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"
Date
Msg-id 2417125.1689038892@sss.pgh.pa.us
Whole thread Raw
In response to Re: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Responses Re: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"
Re: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"
List pgsql-general
Kyotaro Horiguchi <horikyota.ntt@gmail.com> writes:
> 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.

Are you going to prohibit changes to the function's behavior, which is
what actually matters?  And if so, how will you enforce that?  Even if
we had an understanding of the function body --- which we generally
don't for PL functions --- determining that would be equivalent to
solving the halting problem.  "Refuse *all* updates to the pg_proc
entry" might sound like a solution; but it is not, because the
function might call another one whose behavior could get changed.

Even granting that we had a useful way to enforce such a restriction,
figuring out whether to apply it would be subject to race conditions;
maybe somebody else is in process of creating an index using the
function that's being altered.

In the end, adding such restrictions would just give a false sense
of security, because there would always be gaps in whatever we did.
As you quote from the documentation, volatility markings are a promise
by the user to the system, not vice versa.  If you break your promise,
you get to keep both pieces of whatever trouble ensues.

            regards, tom lane



pgsql-general by date:

Previous
From: Ian Lawrence Barwick
Date:
Subject: Re: Is anyone using db_user_namespace?
Next
From: Kyotaro Horiguchi
Date:
Subject: Re: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"