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 1kb340-0003jw-VK for pgsql-bugs@arkaria.postgresql.org; Fri, 06 Nov 2020 14:50:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kb33z-000646-Re for pgsql-bugs@arkaria.postgresql.org; Fri, 06 Nov 2020 14:50:03 +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 1kb33z-00063z-LS for pgsql-bugs@lists.postgresql.org; Fri, 06 Nov 2020 14:50:03 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kb33x-0001xO-D9 for pgsql-bugs@lists.postgresql.org; Fri, 06 Nov 2020 14:50:03 +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 0A6EnwUO1570377; Fri, 6 Nov 2020 09:49:58 -0500 From: Tom Lane To: rbiro@interfacefinancial.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16705: Triggers deferred during commit callback are not executed In-reply-to: <16705-f34c72116d9b2174@postgresql.org> References: <16705-f34c72116d9b2174@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Fri, 06 Nov 2020 03:17:02 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1570375.1604674198.1@sss.pgh.pa.us> Date: Fri, 06 Nov 2020 09:49:58 -0500 Message-ID: <1570376.1604674198@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > If you register a function with RegisterXactCallback that causes a trigger > to be deferred, that trigger is never executed. I'd say that's in the category of "conceptually ridiculous". The PRE_COMMIT events are supposed to fire after all user-level actions in the transaction are finished. Running a trigger that could do arbitrary things would certainly break the assumptions of whatever processing people might be doing in PRE_COMMIT callbacks. Perhaps there's a use case for an even earlier callback that runs in or before the fire-deferred-triggers loop. But you haven't made any argument for it, so I'm loath to add more complexity and cycles to transaction commit for this. The whole area is quite tricky --- for instance, the interaction with cursor closing is not something that would leap to mind. So it's not obvious that such a callback could do anything useful and bulletproof. regards, tom lane