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 1sUbFb-004NBU-Q7 for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jul 2024 00:13:32 +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 1sUbFZ-006FGs-Ic for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jul 2024 00:13:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sUbFX-006FGk-Tv for pgsql-hackers@lists.postgresql.org; Fri, 19 Jul 2024 00:13:29 +0000 Received: from fout5-smtp.messagingengine.com ([103.168.172.148]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sUbFU-000Hyp-SJ for pgsql-hackers@postgresql.org; Fri, 19 Jul 2024 00:13:27 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id 6188713801BF; Thu, 18 Jul 2024 20:13:22 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 18 Jul 2024 20:13:22 -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=1721348002; x=1721434402; bh=k7f2+d+cGN 1Vognoi3XnyrKVAZmaWC/weY/BS/Y90P8=; b=xOJ6gWULgVbiRLcuB1FfFcV+1d 0/LAlDrmtJH28/PH0bHCvZBi7OYH2+tI4UIp2GLExvSTr90WKoFbt91wA2SDJAyH pkEwnr4mpQMFu71vLobczAuXMvaXvpaHxmC2M6PKVSQPp77NYI0ecZ7PbdqVDTZW cVzJenN74RpH35OQrTKefqpXfwjj0UKJCKwNw0o9aWegq4R9cN45Olmx3ficcKoX 2r9IQ4Ga0cr/E62Ckte04lX57pq2GgRCAVCW3yT0JyyCQq8Cvciom0yfgFC/cNMw IkKIwdYlORUXo3XioimQBlWKhLZjV4zZJ+ojNffcYZA7/npxRBLtHhYvXevw== 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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1721348002; x=1721434402; bh=k7f2+d+cGN1Vognoi3XnyrKVAZma WC/weY/BS/Y90P8=; b=eD3PPAG/0Bhdl33axfNrpQuL6X0SdxnSN3grEfZCOanS ZMPiVkmcTz0Z4DD1dd4fOC5qntA7Emo6C4vaZWlvxtthHCg9A03qRgxdt/D334yV LX/Yy2obDpTdmc2j6ShFjtPHiGLw3jyr+yRgG8hhHb68s8k8InF+hkBqeZeydZMv mMSaiKVtXRusrkdk5Q7vrHDPQcDnqCDjF3fFkDoXf7KEVvHQ8rOtxwd2/PXYMzOs oMaNahfXHeXrULEaEXohWQNaFJuxBfgWCfyp41FDpXAdJC3SN0BiU92zhBM5f+wr 60m843rJlx3WN/qmFFLNb8/RnIxwcGM1ArGVMpqDnA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrhedtgdefvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeekffdvvdegvddtffeutdetgfev leeuvdejffdvgeeigeeggfekledthfeigfdvveenucffohhmrghinhepthhrrggtkhdrih htnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhi tghhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 18 Jul 2024 20:13:19 -0400 (EDT) Date: Fri, 19 Jul 2024 09:13:11 +0900 From: Michael Paquier To: Anthonin Bonnefoy Cc: PostgreSQL Hackers Subject: Re: Correctly propagate queryId for utility stmt in function Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="MEpckU5oQPd8i7jP" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --MEpckU5oQPd8i7jP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jul 18, 2024 at 01:37:40PM +0200, Anthonin Bonnefoy wrote: > For utility statements defined within a function, the queryTree is > copied to a plannedStmt as utility commands don't require planning. > However, the queryId is not propagated to the plannedStmt. This leads > to plugins relying on queryId like pg_stat_statements to not be able > to track utility statements within function calls. You are right, good catch. This leads to only partial information being reported depending on the setting of pg_stat_statements.track. It is a point of detail, but I'd rather expand a bit more the tests on top of what you are proposing: - Upper and down-casing for non-top utility commands, to check that they are counted consistently. - Check with pg_stat_statements.track = 'top' - Not cross-checking pg_stat_statements.track_utility = false is OK. While this qualifies as something that could go down to all the stable branches, it is much easier to think about utility statements in 16~ now that we compile the query IDs depending on their parsed tree, so will apply down to that. pg_stat_statements tests have also been refactored in 16~, but that's a nit here.. -- Michael --MEpckU5oQPd8i7jP Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmaZr5cACgkQnvQgOdby QH2mqg/9FFRXKz0Epr8/QgDlWkWyMNsOnYy49SX6r+vWuSc2X+LE3uA1FBf5s/nl fB+BbABwyv40NqpjI7M09RJwLfHqWzpDyml2eyPB3wqrV9kvj06Pdx4l2VUVJmN6 wAI60o09LUPFa0EsO/nXPGJ8Y3F2L8RCFAw+op+5k5sArrbRt7UNVfdg3ImdmIVF jyXYRdaYgUPplQaSgWXutax3Bf/ufk+3b2eYDCUMrwUny03GRh66IylH9KSGf6HQ JYW+dzXwFkob7XG3iYE49JV++JjHXrra4YFqFPWtn6JXEHO/7qja9XRTQgIhf0/W uhCnV34daOWZpJTLTdz2K14GirZVVP8LUa3gxwxf7pKUdHCyumYs/MJ4IG7U8KM+ VeAdcrERMB5lh9SNuaD1ce6P+ecLmIvhnOVuxQvlC13uC1oGN5BvLQMAy3xd4s0e NDN88+10ubfYOsIdLBNjQqFcsLLcFTOZhfkVVYotGsQ4p3KKC+2NutIpq/4smES7 2/NV2vuphI9LoEkirPi7TXjpE2Gay0xUvgpAUKcBpQr/+rwtVS3/EOsXfK6WhkIN OMw9QicG4w59nUCXs8BmPvT/zl7zX8RbsaEsmkt6DC2sBjbG2qyGf0smuaaPwMTw 800QD3lrtpSwg1u6h5GXUTQ7SaNORQRUulZH8uLHjnyeQoyM790= =JfUW -----END PGP SIGNATURE----- --MEpckU5oQPd8i7jP--