pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dmytry Strikha <dm.strikha@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Indexes on expressions that include user-defined functions are not reindexed when the function definition is changed
Date: Wed, 29 May 2019 13:25:15 -0400
Message-ID: <2991.1559150715@sss.pgh.pa.us> (raw)
In-Reply-To: <CAJqEY-ER3P46yewawoRVXbW_p20EnRf8pVyvgmA2-dJQ9qKHKg@mail.gmail.com>
References: <CAJqEY-ER3P46yewawoRVXbW_p20EnRf8pVyvgmA2-dJQ9qKHKg@mail.gmail.com>

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





view thread (4+ messages)  latest in thread

Message-ID: <2991.1559150715@sss.pgh.pa.us>
Permalink:  ../2991.1559150715@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2991.1559150715@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dm.strikha@gmail.com
  Subject: Re: Indexes on expressions that include user-defined functions are not reindexed when the function definition is changed
  In-Reply-To: <2991.1559150715@sss.pgh.pa.us>
  References: <CAJqEY-ER3P46yewawoRVXbW_p20EnRf8pVyvgmA2-dJQ9qKHKg@mail.gmail.com> <2991.1559150715@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