Re: Indexes on expressions that include user-defined functions are not reindexed when the function definition is changed - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Indexes on expressions that include user-defined functions are not reindexed when the function definition is changed
Date
Msg-id 2991.1559150715@sss.pgh.pa.us
Whole thread Raw
In response to Indexes on expressions that include user-defined functions are notreindexed when the function definition is changed  (Dmytry Strikha <dm.strikha@gmail.com>)
Responses Re: Indexes on expressions that include user-defined functions arenot reindexed when the function definition is changed  (Dmytry Strikha <dm.strikha@gmail.com>)
List pgsql-bugs
Dmytry Strikha <dm.strikha@gmail.com> writes:
> If the index on expression is defined so, that the indexed value
> depends on a user-defined function, it doesn't get reindexed when the
> function's definition changes, therefore completely wrong values can
> be displayed when the query is executed using that index.

If you declare the function immutable, as you must to use it in an
index, then redefining the function in a way that changes its results
means *you* broke the contract.  I don't think it's unreasonable of
us to insist that it's on your head to issue any necessary reindexing.
Certainly, neither of the plausible alternatives are acceptable:

* Reindex any time the function is changed at all.  This is putting
an undue burden on people who did follow the contract.

* Detecting whether the redefinition changed the results.
See halting problem.

            regards, tom lane



pgsql-bugs by date:

Previous
From: Dmytry Strikha
Date:
Subject: Indexes on expressions that include user-defined functions are notreindexed when the function definition is changed
Next
From: Dmytry Strikha
Date:
Subject: Re: Indexes on expressions that include user-defined functions arenot reindexed when the function definition is changed