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 1kDibz-0006xP-PN for pgsql-general@arkaria.postgresql.org; Thu, 03 Sep 2020 06:20:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kDibx-0004fj-9w for pgsql-general@arkaria.postgresql.org; Thu, 03 Sep 2020 06:20:41 +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 1kDibx-0004fb-1r for pgsql-general@lists.postgresql.org; Thu, 03 Sep 2020 06:20:41 +0000 Received: from mout.kundenserver.de ([212.227.126.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kDibq-0004CG-2l for pgsql-general@lists.postgresql.org; Thu, 03 Sep 2020 06:20:39 +0000 Received: from walter ([217.245.128.90]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MNtGq-1jtztt2Yiu-00OF2s for ; Thu, 03 Sep 2020 08:20:29 +0200 Date: Thu, 3 Sep 2020 08:20:27 +0200 From: Dirk Lattermann To: pgsql-general@lists.postgresql.org Subject: Re: Trigger transaction isolation Message-ID: <20200903082027.50efd235@walter> In-Reply-To: <54137.1598972521@sss.pgh.pa.us> References: <20200825111235.2c7193f0@walter> <20200901160706.169adf76@walter> <54137.1598972521@sss.pgh.pa.us> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:PKwPPaT9sUHI1W7FuLJlEaVLjqzuuKsbEYtq37N0Mo0pclk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On4IjO0LPc9shiVBTLa8Le2jZ5W8ep8Ug1ygaJ01tzUP4eS1zD6bYK26kc List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thank you, Tom, for this valuable information. On Tue, 01 Sep 2020 11:02:01 -0400 1Tom Lane wrote: > visibility rules are the same as for any other function. So the > answer to the OP's question depends on the transaction's isolation > level and (for typical PLs) on whether the function is VOLATILE or > not. > > serializable -> the transaction's initial snapshot is used throughout I suppose by writing serializable, you include repeatable read here, too? > > non serializable, volatile function -> each statement in the function > takes a fresh snapshot This is the needed behaviour for the validations I intend to do, then. > > non serializable, non-volatile function -> the function uses a single > snapshot. For a non-deferred trigger, I think it shares the snapshot > used by the triggering query. Not sure about exactly when the > snapshot is taken for a deferred trigger. So this case seems to be trickier than it looks at a first glance. It depends heavily on the use case, of course, in how far the snapshot time influences the correctness of a trigger written in this mode. I suggest adding this to the documentation and will try to use the commenting function there for it. Thanks! Dirk