Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q9ngX-000740-4j for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jun 2023 14:10:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q9ngW-0004dl-1y for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jun 2023 14:10:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q9ngV-0004dc-P4 for pgsql-hackers@lists.postgresql.org; Thu, 15 Jun 2023 14:10:47 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q9ngS-002XqM-Qt for pgsql-hackers@lists.postgresql.org; Thu, 15 Jun 2023 14:10:47 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 35FEA3Wf2126662; Thu, 15 Jun 2023 10:10:03 -0400 From: Tom Lane To: chap@anastigmatix.net cc: Yura Sokolov , pgsql-hackers@lists.postgresql.org Subject: Re: When IMMUTABLE is not. In-reply-to: <69234e25e34e68425f49630f79ef9991@anastigmatix.net> References: <389c986d-fbb4-c644-9280-db7836af7ca9@postgrespro.ru> <2111925.1686835298@sss.pgh.pa.us> <69234e25e34e68425f49630f79ef9991@anastigmatix.net> Comments: In-reply-to chap@anastigmatix.net message dated "Thu, 15 Jun 2023 09:58:39 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2126660.1686838203.1@sss.pgh.pa.us> Date: Thu, 15 Jun 2023 10:10:03 -0400 Message-ID: <2126661.1686838203@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk chap@anastigmatix.net writes: > And also, isn't it the case that IMMUTABLE should mark a function, > not merely that "doesn't manipulate data", but whose return value > doesn't depend in any way on data (outside its own arguments)? Right. We can't realistically enforce that either, so it's up to the user. > The practice among PLs of choosing an SPI readonly flag based on > the IMMUTABLE/STABLE/VOLATILE declaration seems to be a sort of > peculiar heuristic, not something inherent in what that declaration > means to the optimizer. (And also influences what snapshot the > function is looking at, and therefore what it can see, which has > also struck me more as a tacked-on effect than something inherent > in the declaration's meaning.) Well, it is a bit odd at first sight, but these properties play together well. See https://www.postgresql.org/docs/current/xfunc-volatility.html regards, tom lane