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 1iSlaG-0000Sl-VM for pgsql-docs@arkaria.postgresql.org; Thu, 07 Nov 2019 17:28:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iSlaF-0008Kx-8O for pgsql-docs@arkaria.postgresql.org; Thu, 07 Nov 2019 17:28:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iSlaE-000837-RH for pgsql-docs@lists.postgresql.org; Thu, 07 Nov 2019 17:28:34 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iSlaB-0005sR-HG for pgsql-docs@lists.postgresql.org; Thu, 07 Nov 2019 17:28:33 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1iSlaA-0005GV-F1; Thu, 07 Nov 2019 12:28:30 -0500 Date: Thu, 7 Nov 2019 12:28:30 -0500 From: Bruce Momjian To: brian.williams@mayalane.com, pgsql-docs@lists.postgresql.org Subject: Re: Nit: "Immutable" should be "pure" Message-ID: <20191107172830.GD12478@momjian.us> References: <157313627814.14272.6307248648194149757@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <157313627814.14272.6307248648194149757@wrigleys.postgresql.org> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Nov 7, 2019 at 02:17:58PM +0000, PG Doc comments form wrote: > The following documentation comment has been logged on the website: > > Page: https://www.postgresql.org/docs/12/sql-createindex.html > Description: > > The adjective "immutable" describing the functions and operators used in an > index (see two occurrences in doc snippet below) is incorrect and should be > replaced with "pure". Both "pure" and "immutable" are in popular lexicon now > because of the interest in functional programming, so conflating the two can > happen, but the word immutable applies to data and pure applies to > functions. See https://en.wikipedia.org/wiki/Pure_function. > > From the CREATE INDEX doc: > All functions and operators used in an index definition must be “immutable”, > that is, their results must depend only on their arguments and never on any > outside influence (such as the contents of another table or the current > time). This restriction ensures that the behavior of the index is > well-defined. To use a user-defined function in an index expression or WHERE > clause, remember to mark the function immutable when you create it. Well, we use IMMUTABLE as an option to CREATE FUNCTION so I don't see how we can realign to the new word meanings without a lot of confusion: CREATE [ OR REPLACE ] FUNCTION name ( [ [ argmode ] [ argname ] argtype [ { DEFAULT | = } default_expr ] [, ...] ] ) [ RETURNS rettype | RETURNS TABLE ( column_name column_type [, ...] ) ] { LANGUAGE lang_name | TRANSFORM { FOR TYPE type_name } [, ... ] | WINDOW | IMMUTABLE | STABLE | VOLATILE | [ NOT ] LEAKPROOF ^^^^^^^^^ I think the best we can do is to mention that IMMUTABLE functions mean pure, but I am not sure there is even enough demand for that, vs. confusing people. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Ancient Roman grave inscription +