asset.bib_source_default is marked immutable but is really stable

Bug #1828301 reported by Jeff Davis
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Evergreen
Undecided
Unassigned

Bug Description

The asset.bib_source_default() database function is marked as immutable. This is technically incorrect, since the function's output can change if the contents of config.bib_source change. This situation is explicitly addressed in the Postgres docs:

"It is generally unwise to select from database tables within an IMMUTABLE function at all, since the immutability will be broken if the table contents ever change."
https://www.postgresql.org/docs/current/xfunc-volatility.html

asset.bib_source_default() is only ever called by asset.patron_default_visibility_mask(). Perhaps it was intentionally marked as immutable to make the visibility mask stuff as fast as possible, on the understanding that config.bib_source rarely changes. But bib sources do sometimes change, so you can end up with cached plans that are incorrect because the function is immutable (I ran into this when investigating bug 1826946).

If it hasn't been done before, we should probably do some benchmarking of various queries that use asset.patron_default_visibility_mask() to see if there is a significant performance impact when asset.bib_source_default() is stable vs immutable.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers