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 1oGtc6-0001GJ-A7 for pgsql-bugs@arkaria.postgresql.org; Thu, 28 Jul 2022 02:51:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oGtc5-0000Uw-8C for pgsql-bugs@arkaria.postgresql.org; Thu, 28 Jul 2022 02:51:01 +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 1oGtc5-0000Un-0S for pgsql-bugs@lists.postgresql.org; Thu, 28 Jul 2022 02:51:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oGtc2-0007Ei-Rm for pgsql-bugs@lists.postgresql.org; Thu, 28 Jul 2022 02:51:00 +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 26S2ot0v3214516; Wed, 27 Jul 2022 22:50:56 -0400 From: Tom Lane To: Yugo NAGATA cc: "David G. Johnston" , Bruce Momjian , PostgreSQL mailing lists Subject: Re: BUG #17434: CREATE/DROP DATABASE can be executed in the same transaction with other commands In-reply-to: <20220728105134.d5ce51dd756b3149e9b9c52c@sraoss.co.jp> References: <17434-d9f7a064ce2a88a3@postgresql.org> <3190751.1657845414@sss.pgh.pa.us> <3498921.1657919211@sss.pgh.pa.us> <805866.1658175624@sss.pgh.pa.us> <2350990.1658848101@sss.pgh.pa.us> <2356216.1658849834@sss.pgh.pa.us> <2361330.1658851386@sss.pgh.pa.us> <2363212.1658852059@sss.pgh.pa.us> <20220728105134.d5ce51dd756b3149e9b9c52c@sraoss.co.jp> Comments: In-reply-to Yugo NAGATA message dated "Thu, 28 Jul 2022 10:51:34 +0900" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3214514.1658976655.1@sss.pgh.pa.us> Date: Wed, 27 Jul 2022 22:50:55 -0400 Message-ID: <3214515.1658976655@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Yugo NAGATA writes: > I've looked at the commited fix. What I wonder is whether a change in > IsInTransactionBlock() is necessary or not. I've not examined ANALYZE's dependencies on this closely, but it doesn't matter really, because I'm not willing to assume that ANALYZE is the only caller. There could be external modules with stronger assumptions that IsInTransactionBlock() yielding false provides guarantees equivalent to PreventInTransactionBlock(). It did before this patch, so I think it needs to still do so after. > In fact, the result of IsInTransactionBlock does not make senses at > all in pipe-line mode regardless to the fix. ANALYZE could commit all > previous commands in pipelining, and this may not be user expected > behaviour. This seems pretty much isomorphic to the fact that CREATE DATABASE will commit preceding steps in the pipeline. That's not great, I admit; we'd not have designed it like that if we'd had complete understanding of the behavior at the beginning. But it's acted like that for a couple of decades now, so changing it seems far more likely to make people unhappy than happy. The same for ANALYZE in a pipeline. > If the first command in a pipeline is DDL commands such as CREATE > DATABASE, this is allowed and immediately committed after success, as > same as the current behavior. Executing such commands in the middle of > pipeline is not allowed because the pipeline is regarded as "an implicit > transaction block" at that time. Similarly, ANALYZE in the middle of > pipeline can not close and open transaction. I'm not going there. If you can persuade some other committer that this is worth breaking backward compatibility for, fine; the user complaints will be their problem. regards, tom lane