Re: Bug / Unintentional Feature: non-immutable functions can be used for generated columns. - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Bug / Unintentional Feature: non-immutable functions can be used for generated columns.
Date
Msg-id 1028095.1664665480@sss.pgh.pa.us
Whole thread Raw
In response to Re: Bug / Unintentional Feature: non-immutable functions can be used for generated columns.  (Shane Plesner <gebnar@gmail.com>)
List pgsql-bugs
Shane Plesner <gebnar@gmail.com> writes:
> It seems to me that any time a function is replaced, there could be a check
> to see if it was changed from immutable to mutable. If it was, check the
> schema for any references to that function that require immutable function
> calls, and raise an exception.
> Is there something I'm missing that makes this unfeasible?

Cost, added maintenance burden, race conditions.

Also, just complaining about dropping the immutability flag seems
rather pointless.  If you redefine the function in a way that changes its
results, but continue to mark it immutable, you've still broken a lot
of situations (e.g., expression indexes that depend on the function's
results).  If memory serves, we've actually discussed refusing any
alterations at all of an "immutable" function once it's defined.
But that's still not much help, because we can't usefully verify that
an "immutable" function's behavior actually is immutable.  In the end
it's on the user to preserve its behavior, or do appropriate cleanup
(such as reindexing) after a change.

            regards, tom lane



pgsql-bugs by date:

Previous
From: Jeff Janes
Date:
Subject: Re: pg ignores wal files in pg_wal, and instead tries to load them from archive/primary
Next
From: Michael Paquier
Date:
Subject: Re: v15rc1 shadowbuild fails when using src from symlink