pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Shane Plesner <gebnar@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Bug / Unintentional Feature: non-immutable functions can be used for generated columns.
Date: Sat, 01 Oct 2022 19:04:40 -0400
Message-ID: <1028095.1664665480@sss.pgh.pa.us> (raw)
In-Reply-To: <CAFBci=oVThkEVGZN9FezkMqYO+fTNb08mHCZTqQQydHZ72xs0Q@mail.gmail.com>
References: <CAFBci=qAOea1SCwkJgLdR6OwLOBVTuHqmqDGz8jKMFUzZd1b5g@mail.gmail.com>
	<CAKFQuwbg6OF0RntkAmK9SND+i5fYDV9XQEShJQ_eP0TeCqAcWw@mail.gmail.com>
	<CAFBci=oVThkEVGZN9FezkMqYO+fTNb08mHCZTqQQydHZ72xs0Q@mail.gmail.com>

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





view thread (4+ messages)

Message-ID: <1028095.1664665480@sss.pgh.pa.us>
Permalink:  ../1028095.1664665480@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1028095.1664665480@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, gebnar@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: Bug / Unintentional Feature: non-immutable functions can be used for generated columns.
  In-Reply-To: <1028095.1664665480@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox