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 1oso9K-0001VI-0a for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Nov 2022 16:42: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 1oso9I-0003j7-JX for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Nov 2022 16:42:00 +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 1osnsj-0003GR-29 for pgsql-hackers@lists.postgresql.org; Wed, 09 Nov 2022 16:24:53 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1osnsg-0006h3-1m for pgsql-hackers@postgresql.org; Wed, 09 Nov 2022 16:24:52 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 3B0C85C0231; Wed, 9 Nov 2022 11:24:46 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 09 Nov 2022 11:24:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1668011086; x= 1668097486; bh=SD0QcBd12TcoK3OHHRwHezhSenlAIyOokViwhcllho0=; b=S PZCVlfH3ARthrxUNOKW6zXNmX3G+6tSkh9g5jxU8TRhgKrQg/JzNPBuI/XxM63Mh Ymh1OdtNABr+E7iYAY8JNg/GVDVEPCgvVCemGU/ULcZZvF0KIqIxOqF30ljMzxIR ZTbyEj34cSy81OsLNpkNma9/DMCzrf5e+s4ohwnbApzpO3rlsbWivY35RbYIYhzH O0TKq7SEUzdqAiYNT6jSuIT/mM6aeVYdfyHg8ituhC+SXWbyZ4iR14WDsfhk97Ek JCpfZHY7vQ+vVW6zupkM1FJtj0rbnvnlg4HRgjuNJYXxhr3dO9WaW23QJBJikznb 0E8db+obLsmSa+eTNNv9A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrfedvgdekjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthejredttdefjeenucfhrhhomheprfgvthgv rhcugfhishgvnhhtrhgruhhtuceophgvthgvrhdrvghishgvnhhtrhgruhhtsegvnhhtvg hrphhrihhsvggusgdrtghomheqnecuggftrfgrthhtvghrnhepheelffeggedujeetiefh leetuddvieffhfffvdejvdffgeejkeduleduheduieefnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepphgvthgvrhdrvghishgvnhhtrhgruhht segvnhhtvghrphhrihhsvggusgdrtghomh X-ME-Proxy: Feedback-ID: i131946ab:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 9 Nov 2022 11:24:44 -0500 (EST) Message-ID: <65a899dd-aebc-f667-1d0a-abb89ff3abf8@enterprisedb.com> Date: Wed, 9 Nov 2022 17:24:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: BUG #17434: CREATE/DROP DATABASE can be executed in the same transaction with other commands Content-Language: en-US To: Yugo NAGATA , Tom Lane , pgsql-hackers@postgresql.org Cc: "David G. Johnston" , Bruce Momjian , PostgreSQL mailing lists 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> <3214515.1658976655@sss.pgh.pa.us> <20220809002102.b815cd4dad20fdc91dff5ce8@sraoss.co.jp> From: Peter Eisentraut In-Reply-To: <20220809002102.b815cd4dad20fdc91dff5ce8@sraoss.co.jp> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 08.08.22 17:21, Yugo NAGATA wrote: >>> 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. > I am not sure if we can think CREATE DATABASE case and ANLALYZE case > similarly. First, CREATE DATABASE is one of the commands that cannot be > executed inside a transaction block, but ANALYZE can be. So, users would > not be able to know ANALYZE in a pipeline causes a commit from the > documentation. Second, ANALYZE issues a commit internally in an early > stage not only after it finished successfully. For example, even if > ANALYZE is failing because a not-existing column name is specified, it > issues a commit before checking the column name. This makes more hard > to know which statements will be committed and which statements not > committed in a pipeline. Also, as you know, there are other commands > that issue internal commits. This has broken the following use: parse: create temporary table t1 (a int) on commit drop bind execute parse: analyze t1 bind execute parse: select * from t1 bind execute sync I think the behavior of IsInTransactionBlock() needs to be further refined to support this. If we are worried about external callers, maybe we need to provide a separate version. AFAICT, all the callers of IsInTransactionBlock() over time have been in vacuum/analyze-related code, so perhaps in master we should just move it there.