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 1q2HRh-0001pz-8x for pgsql-hackers@arkaria.postgresql.org; Thu, 25 May 2023 20:20:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q2HRf-0005Dn-MG for pgsql-hackers@arkaria.postgresql.org; Thu, 25 May 2023 20:20:23 +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 1q2HRe-0005DW-5s for pgsql-hackers@lists.postgresql.org; Thu, 25 May 2023 20:20:23 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q2HRY-00294B-Gr for pgsql-hackers@postgresql.org; Thu, 25 May 2023 20:20:21 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 8C9B05C02D0; Thu, 25 May 2023 16:20:14 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 25 May 2023 16:20:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1685046014; x=1685132414; bh=aD zBSR0/W6lQXHM0rAcAjX0ihJP0M5HYGzT67b+C4Gg=; b=aU1Oz2kUCF4VcgBvuG iQKocL2bWRBoJP/YvTGQeqfwY0uzU6dU3RdSOgOYx2GqNb6WnKfa4kChTAZRP9ZN JlenoEhKh+kH2dDB8R2N7sl7I01oumGU18OV7PsRlwT2YjP+FNouFoNDtVefISE3 Qfkql7LTDsHqSM8zMzmjwCkk+T1Hm1AQeOZ0cJpAUmvNGMJlCJTMvaiwzlNdO+05 90oPmmsCovf/SIGAR3A5Di+FjKhazlKZbTKTOsHpyMBNG0eYGtYsBoCuMlhypEqA VzeMsO51sQHY3OT/23xlCzbt6o1VPDBe8KkHSMUD/FUgdDM0h1yGkiwUdgT7nlIJ mNzw== 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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1685046014; x=1685132414; bh=aDzBSR0/W6lQX HM0rAcAjX0ihJP0M5HYGzT67b+C4Gg=; b=zhNCkphcX+BlVgDoFWlhLu6HPQ6TB ujN5h9krn8PKck/D5wBHVnxKN1LsJxJxoCBt2Hf6bzBtgWMB0CmnWMLK+eecTSUT NO9+cDY37ucMeXsrWThSRJo7bX8L4i/PH8Ovpo6U+IoNpX9u/9+cUKurADND827L ZnoPWoZwB3rQOiJ63xQtKiGfkf5Lm3mvFEAv9k54LC6c8aeMz70M828pxgzZcSZi N1sQ3MUYOn9EPtj9L6zhCOzvZTfAMa+zc9zvRgChZJRwriVcclxK46vZC5CEOPb8 rsZVeHoJ8x9zK48Qp5luVEHxRvwWXvmwdIRbupKxujWHPrGh2pur6irnw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeejjedgudegiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufhfffgjkfgfgggtsehmtderredtreejnecuhfhrohhmpeffrghg fhhinhhnucfklhhmrghrihcuofgrnhhnshonkhgvrhcuoehilhhmrghrihesihhlmhgrrh hirdhorhhgqeenucggtffrrghtthgvrhhnpeeufeetveetteeiueejueduudfgffeftdet udejveevueffteekgeeuffefteffveenucffohhmrghinhepmhhomhhjihgrnhdruhhsne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhlmhgr rhhisehilhhmrghrihdrohhrgh X-ME-Proxy: Feedback-ID: i1ff147bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 25 May 2023 16:20:13 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: Bruce Momjian Cc: PostgreSQL-development Subject: Re: PG 16 draft release notes ready References: Date: Thu, 25 May 2023 21:20:11 +0100 In-Reply-To: (Bruce Momjian's message of "Thu, 18 May 2023 16:49:47 -0400") Message-ID: <878rdctb7o.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Bruce Momjian writes: > I have completed the first draft of the PG 16 release notes. You can > see the output here: > > https://momjian.us/pgsql_docs/release-16.html > > I will adjust it to the feedback I receive; that URL will quickly show > all updates. The bit about auto_explain and query parameters says: > Allow auto_explain to log query parameters used in executing prepared > statements (Dagfinn Ilmari Mannsåker) > > This is controlled by auto_explain.log_parameter_max_length, and by > default query parameters will be logged with no length > restriction. SHOULD THIS BE MORE CLEARLY IDENTIFIED AS CONTROLLING THE > EXECUTION OF PREPARED STATEMENTS? This is wrong, the logging applies to all query parameters, not just for prepared statements (and has nothing to do with controlling the execution thereof). That was just the only way to test it when it was written, because psql's \bind command exist yet then. Should we perhaps add some tests for that, like the attached? - ilmari --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Test-auto_explain-parameter-logging-with-protocol-le.patch From d3630f299fc2d2d9f9eb3addd426f98e5196100d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Thu, 25 May 2023 21:13:11 +0100 Subject: [PATCH] Test auto_explain parameter logging with protocol-level bind parameters When auto_explain.log_parameter_max_length was added, psql didn't have the \bind command for extended query protocol yet, so the test could only use prepared statements. --- contrib/auto_explain/t/001_auto_explain.pl | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/contrib/auto_explain/t/001_auto_explain.pl b/contrib/auto_explain/t/001_auto_explain.pl index abb422f8de..d2a0078546 100644 --- a/contrib/auto_explain/t/001_auto_explain.pl +++ b/contrib/auto_explain/t/001_auto_explain.pl @@ -106,6 +106,21 @@ sub query_log qr/Query Parameters:/, "query parameters not logged when disabled, text mode"); +# bind parameters +$log_contents = query_log($node, + q{SELECT * FROM pg_proc WHERE proname = $1 AND prokind = $2 \bind ascii f \g} +); + +like( + $log_contents, + qr/Query Text: SELECT \* FROM pg_proc WHERE proname = \$1 AND prokind = \$2/, + "query text with parameters logged, text mode"); + +like( + $log_contents, + qr/Query Parameters: \$1 = 'ascii', \$2 = 'f'/, + "query parameters logged, text mode"); + # Query Identifier. # Logging enabled. $log_contents = query_log( @@ -172,6 +187,22 @@ sub query_log qr/"Node Type": "Index Scan"[^}]*"Index Name": "pg_class_relname_nsp_index"/s, "index scan logged, json mode"); +# query with bind parameters in JSON format. +$log_contents = query_log( + $node, + q{SELECT * FROM pg_class WHERE relname = $1 AND relkind = $2 \bind pg_proc r \x}, + { "auto_explain.log_format" => "json" }); + +like( + $log_contents, + qr/"Query Text": "SELECT \* FROM pg_class WHERE relname = \$1 AND relkind = \$2 "/, + "query text with parameters logged, json mode"); + +like( + $log_contents, + qr/"Query Parameters": "\$1 = 'pg_proc', \$2 = 'r'"/, + "query parameters logged, json mode"); + # Check that PGC_SUSET parameters can be set by non-superuser if granted, # otherwise not -- 2.39.2 --=-=-=--