Re: 回复:[Internet]Re: [PATCH] Prevent replacement of a function if it's used in an index expression and is not IMMUTABLE - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: 回复:[Internet]Re: [PATCH] Prevent replacement of a function if it's used in an index expression and is not IMMUTABLE
Date
Msg-id CAKFQuwZgNKvb4Oref9n6aUywqne-BrH+RHDFW9ZN0c+t2uuDtA@mail.gmail.com
Whole thread Raw
In response to Re: 回复:[Internet]Re: [PATCH] Prevent replacement of a function if it's used in an index expression and is not IMMUTABLE  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Wed, Jul 9, 2025 at 12:11 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Wed, Jul 9, 2025 at 9:15 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> TBH, I find this proposal to be useless nannyism.

> Isn't preventing a dump-restore hazard sufficient reason to do this?

No, I don't think so.  If you're not being very careful about revising
functions used in indexes, you are going to have problems a lot sooner
than some future dump/restore cycle.


Then probably this patch can just update the create index documentation to say "create or replace it" instead of just "create it".  The fact that during 'update' (replace) existing non-implied settings can be replaced with implied ones is a beginner/inattentive foot-gun.  We do make the point clearly in create function but it seems worthwhile to reinforce it here too.

"To use a user-defined function in an index expression or WHERE clause, remember to mark the function immutable when you create [or replace] it."

David J.

pgsql-hackers by date:

Previous
From: Jacob Champion
Date:
Subject: Re: [PoC] Federated Authn/z with OAUTHBEARER
Next
From: Andres Freund
Date:
Subject: Re: Adding basic NUMA awareness