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 1j5dNo-00078u-U3 for pgsql-general@arkaria.postgresql.org; Sat, 22 Feb 2020 22:36:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j5dNm-0001Vq-V7 for pgsql-general@arkaria.postgresql.org; Sat, 22 Feb 2020 22:36:22 +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 1j5dNm-0001Vi-Hu for pgsql-general@lists.postgresql.org; Sat, 22 Feb 2020 22:36:22 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j5dNg-0007Nl-60 for pgsql-general@lists.postgresql.org; Sat, 22 Feb 2020 22:36:21 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 01MMaE1G008813; Sat, 22 Feb 2020 17:36:14 -0500 From: Tom Lane To: Christophe Pettus cc: stan , pgsql-general@lists.postgresql.org Subject: Re: Can I trigger an action from a coalesce ? In-reply-to: <1B2A9F19-0477-473F-B6E6-7CBE393C8D38@thebuild.com> References: <20200222210206.GA17445@panix.com> <35c60adc-3f02-13ad-a4a6-48642a1185d8@aklaver.com> <20200222213325.GA22785@panix.com> <982511F6-2957-43EE-8A28-3A5541B56ADF@thebuild.com> <7426.1582408953@sss.pgh.pa.us> <1B2A9F19-0477-473F-B6E6-7CBE393C8D38@thebuild.com> Comments: In-reply-to Christophe Pettus message dated "Sat, 22 Feb 2020 14:07:41 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <8811.1582410974.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 22 Feb 2020 17:36:14 -0500 Message-ID: <8812.1582410974@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Christophe Pettus writes: >> On Feb 22, 2020, at 14:02, Tom Lane wrote: >> It's a really bad idea to mark a function that has side-effects >> (i.e., emitting a NOTICE) as immutable, especially if the occurrence >> of the side-effect at well-defined times is exactly what you're >> desirous of. > True, and it doesn't actually need to be immutable here; just cut and pa= sted from the wrong example. > (That being said, I'm not coming up with a specific bad thing that a RAI= SE NOTICE in an immutable function will cause. Is there one?) The problem that I'm worried about is premature evaluation of the "immutable" function, causing the NOTICE to come out once during query planning, independently of whether/how many times it should come out during execution. regards, tom lane