Re: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
Cc: AviW(at)gilat(dot)com, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"
Date: 2023-07-11 01:28:12
Message-ID: 2417125.1689038892@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kyotaro Horiguchi 2023-07-11 01:29:22 Re: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"
Previous Message Ian Lawrence Barwick 2023-07-11 01:24:55 Re: Is anyone using db_user_namespace?