Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hW2KM-0008Bj-6d for pgsql-bugs@arkaria.postgresql.org; Wed, 29 May 2019 17:25:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hW2KK-0002dU-MA for pgsql-bugs@arkaria.postgresql.org; Wed, 29 May 2019 17:25:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hW2KK-0002Zf-CN for pgsql-bugs@lists.postgresql.org; Wed, 29 May 2019 17:25:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hW2KH-0000fk-FJ for pgsql-bugs@lists.postgresql.org; Wed, 29 May 2019 17:25:23 +0000 Received: from pro.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x4THPFwb008422; Wed, 29 May 2019 13:25:15 -0400 From: Tom Lane To: Dmytry Strikha 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 In-reply-to: References: Comments: In-reply-to Dmytry Strikha message dated "Wed, 29 May 2019 19:00:36 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2990.1559150715.1@sss.pgh.pa.us> Date: Wed, 29 May 2019 13:25:15 -0400 Message-ID: <2991.1559150715@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Dmytry Strikha 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