Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ubXf0-0026UY-5G for pgsql-bugs@arkaria.postgresql.org; Tue, 15 Jul 2025 04:52:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ubXex-00H15g-CG for pgsql-bugs@arkaria.postgresql.org; Tue, 15 Jul 2025 04:52:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ubXew-00H15Y-Cf for pgsql-bugs@lists.postgresql.org; Tue, 15 Jul 2025 04:52:55 +0000 Received: from fhigh-a6-smtp.messagingengine.com ([103.168.172.157]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1ubXev-007Lg6-0N for pgsql-bugs@lists.postgresql.org; Tue, 15 Jul 2025 04:52:54 +0000 Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfhigh.phl.internal (Postfix) with ESMTP id EEE0D140031D; Tue, 15 Jul 2025 00:52:51 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Tue, 15 Jul 2025 00:52:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1752555171; x=1752641571; bh=WigWRWoAiN ZOKkl/liEHJUCJtOjpVtPlgZB+u0ZFlD8=; b=SBmte1HW2/NM82Su1+9nGVj5zq /43/lYw6rLyNt36/1ugw01vKlcmgswnUuloDbAvnO53rBmdzdOXqNCtx4ReK4UCj V+IpAqAA9GrbH8GIJsQ0X3Gff6KfXEyHsQmDm0qbm0O3CD4lHPHnjeD8W6UAxuie RbED1b7+/hYkzwJGV0zNwGiWRlTS5QawEtwfxbkFMRMBty+f7tanGpPGQSOiIPlC 2IAjpkCBCtrAdm7COa5d0skIaAJkiwC9alVEcTT7STdFCt6GNcXbpKCRhZAJKaoA dmOtX8jh+2+Iz/uu1qKx/rrgflgb9Aeq9D6nQMB4+WrH+9Q+9oBCJhiTGJ4A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1752555171; x=1752641571; bh=WigWRWoAiNZOKkl/liEHJUCJtOjpVtPlgZB +u0ZFlD8=; b=E2fEkUVYe4EZPJ0VN47Akc1IUx8zYnrOt7YSFkAiKYTBMRnY1c6 Svj4Etgt/uZ0gnMkeyIuCCKvn9kGx7fKI7zLc3KUsA6nXh6h68RE0WJAJKP1ACZ8 FUUi7+2C7IyAw85hlBFJm1/auNRVwiQp5QF3H17aDBgiW22IDArrKwi9ufJG37kd 0TeYJ4NfwSqHqXxxO1iVRDGuzbRvOHs3GSBhvT0nmkEZxhzKAgexzr97BgiZDh1j /G/jlhb0NL+cgst0u67adZAJ4ilEdNufJ1dzPtQymZ/GS2THBfSrLMJtlPFpQI8y bz7lkukSYFACNzMC/P5+/Vt7nllPPALIppQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdehfeelvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecufghrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuf fkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgv rhcuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpe etleeifedufffhhfdtteelgeeggeffhfekueevteeigfduudevudetgfegiedvjeenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvg hlsehprghquhhivghrrdighiiipdhnsggprhgtphhtthhopeefpdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehtghhlsehsshhsrdhpghhhrdhprgdruhhspdhrtghpthhtoh epvgigtghluhhsihhonhesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdgs uhhgsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 15 Jul 2025 00:52:49 -0400 (EDT) Date: Tue, 15 Jul 2025 13:52:37 +0900 From: Michael Paquier To: Tom Lane Cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18984: Empty prepared statement from psql \parse triggers assert in PortalRunMulti Message-ID: References: <18984-0f4778a6599ac3ae@postgresql.org> <715434.1752521761@sss.pgh.pa.us> <799185.1752535067@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Fmfx0ptvtSUNe1cl" Content-Disposition: inline In-Reply-To: <799185.1752535067@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Fmfx0ptvtSUNe1cl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 14, 2025 at 07:17:47PM -0400, Tom Lane wrote: > I think I fat-fingered something, because now I can only reproduce back > to v13. Bisecting says the crash started at the v13-era commit >=20 > which is unsurprising because that's what introduced the > Assert we're hitting. Yep. > which is another reason not to start throwing an error. > (I did not look into how come that works... the correct > command tag must be getting filled in later, but where?) With some extra logs: WARNING: 01000: BOOBOO exec_simple_query commandTag =3D EXECUTE LOCATION: exec_simple_query, postgres.c:1120 WARNING: 01000: BOOBOO PortalDefineQuery commandTag =3D EXECUTE LOCATION: PortalDefineQuery, portalmem.c:301 WARNING: 01000: BOOBOO PortalDefineQuery commandTag =3D ??? LOCATION: PortalDefineQuery, portalmem.c:301 The first pass in PortalDefineQuery() is done in exec_simple_query(). The second pass of PortalDefineQuery() is the relevant one, I guess: #0 PortalDefineQuery (portal=3D0x564cf7cc9240, prepStmtName=3D0x0, sourceText=3D0x564cf7c74d80 "", commandTag=3DCMDTAG_UNKNOWN, stmts=3D0x0, cplan=3D0x564cf7c817a8) at portalmem.c:289 #1 0x0000564cd98d4328 in ExecuteQuery (pstate=3D0x564cf7c7b740, stmt=3D0x564cf7c48d38, intoClause=3D0x0, params=3D0x0, dest=3D0x564cf7c48de= 0, qc=3D0x7fffb8e7b4a0) at prepare.c:203 #2 0x0000564cda3f6427 in standard_ProcessUtility (pstmt=3D0x564cf7c48550, queryString=3D0x564cf7c47590 "execute s;", readOnlyTree=3Dfalse, context=3DPROCESS_UTILITY_TOPLEVEL, params=3D0x0, queryEnv=3D0x0, dest=3D0x564cf7c48de0, qc=3D0x7fffb8e7b4a0) at utility.c:759 #3 0x0000564cda3f541f in ProcessUtility (pstmt=3D0x564cf7c48550, queryString=3D0x564cf7c47590 "execute s;", readOnlyTree=3Dfalse, context=3DPROCESS_UTILITY_TOPLEVEL, params=3D0x0, queryEnv=3D0x0, dest=3D0x564cf7c48de0, qc=3D0x7fffb8e7b4a0) at utility.c:523 #4 0x0000564cda3f2214 in PortalRunUtility (portal=3D0x564cf7cc9130, pstmt=3D0x564cf7c48550, isTopLevel=3Dtrue, setHoldSnapshot=3Dfalse, dest=3D0x564cf7c48de0, qc=3D0x7fffb8e7b4a0) at pquery.c:1153 #5 0x0000564cda3f2a40 in PortalRunMulti (portal=3D0x564cf7cc9130, isTopLevel=3Dtrue, setHoldSnapshot=3Dfalse, dest=3D0x564cf7c48de0, altdest=3D0x564cf7c48de0, qc=3D0x7fffb8e7b4a0) at pquery.c:1310 #6 0x0000564cda3f09a4 in PortalRun (portal=3D0x564cf7cc9130, count=3D9223372036854775807, isTopLevel=3Dtrue, dest=3D0x564cf7c48de0, altdest=3D0x564cf7c48de0, qc=3D0x7fffb8e7b4a0) at pquery.c:788 #7 0x0000564cda3e240a in exec_simple_query (query_string=3D0x564cf7c47590 "execute s;") at postgres.c:1274 #8 0x0000564cda3eb78f in PostgresMain (dbname=3D0x564cf7c84730 "ioltas", username=3D0x564cf7c84718 "ioltas") at postgres.c:4767 So the QueryCompletion given to PortalRunMulti() is initialized at the beginning of PortalRun with an unknown tag, and we miss to fill it when running the individual queries because CopyQueryCompletion() happens at the end of PortalRunMulti(). We can be more proactive when updating the tag by doing one in ExecuteQuery() as you are suggesting, but I am wondering if we should not just nuke the assertion at the end of PortalRunMulti() instead, relying on the same check done at the beginning of ProcessUtility(). -- Michael --Fmfx0ptvtSUNe1cl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmh13pUACgkQnvQgOdby QH2mkhAAkgwrNUwCw+yp/f6ZHWWc2GrlGffVmcYmPrBaipSyrSyM7gs5lD60q6sQ eXG8oYBb4f1yPEe5RAB27FRfmgl8PV/a2qzBOAL8nxntGi5ASgbkkS+aWtbRrpvP CSGUFLgMOjAGBOGNTMTkBmbxYX6h7CQSNqIh1i5fnKdVin22Isamm4GVcazjxbAQ +ompoCdvkag2JKp09zYG4oJmyj4Y6NsQTWD1UdKH4mXJDESMNT2LCq7GjfP4WVxl JL0iixTqCTYbIkv4vsnEFD+/nlz0EqSJQ2T5PjCUQ098Urcs52guNr3MTl6IVWVm pgs3BWhBthsPvt9ms7xNaQndeOZpLkhQiCl8aM3xgfDe1RQ6NmjJ5uAA+yyrhVp4 yjbk7Gc/faZCBix/3ezPX2/pFtB16OW0PK+Ue7X55JqSoZhtGdFuAjTS8eShoiWf s5BEsLqJMKAnwH3/FrcU6/Gqskv98/LyqJGOxmOwqUIYijjw3bz50DKEj8QlNmtc 44iIjH70dDvaVCebMshXzCu7EEHvLshfKrYUh6soQio7ix1lSFdGsGaAZbdYAllZ /CdsCt5c4BcAZ/W7ms9lreuz9WRz7GsHlcVMKwgEQv6SSsnaufmjLAT65hZM24eg QaG1jOm0LDP3k9/7/tTu/nfCOc/EGrSGwoIueEZOokAINGNE69E= =xqCK -----END PGP SIGNATURE----- --Fmfx0ptvtSUNe1cl--