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 1q9nVD-0006VW-Jl for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jun 2023 13:59:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q9nVC-0005tY-17 for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jun 2023 13:59:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q9nVB-0005qV-CT for pgsql-hackers@lists.postgresql.org; Thu, 15 Jun 2023 13:59:05 +0000 Received: from anastigmatix.net ([68.171.219.55]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q9nUr-002MGA-6R for pgsql-hackers@lists.postgresql.org; Thu, 15 Jun 2023 13:58:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=anastigmatix.net; s=default; h=Content-Transfer-Encoding:Content-Type: Message-ID:References:In-Reply-To:Subject:Cc:To:From:Date:MIME-Version:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=lkHhYsLv8/qWtUUoFvJdNN5/wIQBKWrl8KI/VcAep60=; b=AZmukpHcxPdnOpCZaiTW+F0zZP VoHrFnQUBcuqM3vaJQv1eiCYpgRK2YTLclYqpRnna8IYdaUoN7u8DDj7KTq/zloXG+M3/Q+Fwm4XC iaicOzGE/xSDrzX+zTEgnAHXxcRuFD+uf70wJfR0faAOZfciQI91W6YZeSsw5Zp3UWo9Ln45jYHnz P78xZm5pGLqwslHuA0/R2n28DQHdU39LFVwuvIS4t+hHijeVQxUhqVJy0tp7vHMK90rQL02a6EjXP GOPB621lW8/4diIviIZIb9hyo0WjIzgACyFSLC2v9YermPHbeoad096r1fwbnvSYKXdNNAlCnGK4G VwZvyg5w==; Received: from [::1] (port=36038 helo=bay.acenet.us) by bay.acenet.us with esmtpa (Exim 4.96) (envelope-from ) id 1q9nUm-008gG9-39; Thu, 15 Jun 2023 09:58:41 -0400 MIME-Version: 1.0 Date: Thu, 15 Jun 2023 09:58:39 -0400 From: chap@anastigmatix.net To: Tom Lane Cc: Yura Sokolov , pgsql-hackers@lists.postgresql.org Subject: Re: When IMMUTABLE is not. In-Reply-To: <2111925.1686835298@sss.pgh.pa.us> References: <389c986d-fbb4-c644-9280-db7836af7ca9@postgrespro.ru> <2111925.1686835298@sss.pgh.pa.us> User-Agent: Roundcube Webmail/1.6.0 Message-ID: <69234e25e34e68425f49630f79ef9991@anastigmatix.net> X-Sender: chap@anastigmatix.net Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bay.acenet.us X-AntiAbuse: Original Domain - lists.postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - anastigmatix.net X-Get-Message-Sender-Via: bay.acenet.us: authenticated_id: chap@anastigmatix.net X-Authenticated-Sender: bay.acenet.us: chap@anastigmatix.net X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-06-15 09:21, Tom Lane wrote: > Yura Sokolov writes: >> not enough to be sure function doesn't manipulate data. > > Of course not. It is the user's responsibility to mark functions > properly. 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)? 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.) Regards, -Chap