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 1lSSpl-0004Ve-7z for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Apr 2021 23:04:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lSSpk-0006tP-4v for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Apr 2021 23:04:08 +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 1lSSpj-0006tI-6H for pgsql-hackers@lists.postgresql.org; Fri, 02 Apr 2021 23:04:07 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lSSpf-00067Z-M8 for pgsql-hackers@lists.postgresql.org; Fri, 02 Apr 2021 23:04:06 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id ACD561689; Fri, 2 Apr 2021 19:03:59 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 02 Apr 2021 19:04:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=GjC1YOIvQq7NtVAkOKxsiQ9bTdRCCvVxBgQubgUXIEk=; b=P62IYU8D A+9/eAfoUGbzugCGpaLTXwyCg23P3iI6J1nHecgrWmM/tcKIBZcVjkpdrecFN+HT 3eBTtYajl0mo4netYMG9ApGUYCGuATzxKM2/Jzz5IwBNVjoDRVexJdr1vMSdMEEK 8zs3XrRGuBIqEIdPXxFoe+0rve2cFKJ2eAxcA2NHGNYx3ASebxB3u5PY3bKt97za JnzuvmE6132IkFcom2WJgEqNz0vOnw0jHdrpqKW4o+ag/NCxzWlc7ADLQr3rehQg RLHhk+rOjLCQahmobHCs/nomCwjoPdd6byenHn5IoPSafB9OQSx67gor4aMuyhLb ACf6Sqpht4xW+g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudeijedgudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkgggtugfgjggfsehmke erredtredunecuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhr vgesrghlvhhhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpefhfeegleekgf ejueehgfefveelfeetvdehffdtueetgffhkefhudehffekudetkeenucfkphepudeltddr leehrdduledrleehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.95]) by mail.messagingengine.com (Postfix) with ESMTPA id 95662108005F; Fri, 2 Apr 2021 19:03:58 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 50BC12A0850; Fri, 2 Apr 2021 20:03:55 -0300 (-03) Date: Fri, 2 Apr 2021 20:03:55 -0300 From: Alvaro Herrera To: Tom Lane Cc: Kyotaro Horiguchi , iwata.aya@fujitsu.com, tsunakawa.takay@fujitsu.com, k.jamison@fujitsu.com, pgsql-hackers@lists.postgresql.org Subject: Re: libpq debug log Message-ID: <20210402230355.GA18263@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="a8Wt8u1KmwUX3Y2C" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3650140.1617372290@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --a8Wt8u1KmwUX3Y2C Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2021-Apr-02, Tom Lane wrote: > Alvaro Herrera writes: > > As in the attached patch. > > +1, but the comment could be more specific. Maybe like "In regress mode, > suppress the length of ErrorResponse and NoticeResponse messages --- the F > (file name) field, in particular, can vary in length depending on compiler > used." With your commit this is no longer true, so how about the attached? -- Álvaro Herrera Valdivia, Chile --a8Wt8u1KmwUX3Y2C Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0001-Suppress-length-of-Notice-Error-in-PQtrace-regres.patch" From 80af8f687ea3665a045d9005e0ec1fc53e1a393a Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Fri, 2 Apr 2021 10:51:42 -0300 Subject: [PATCH v2] Suppress length of Notice/Error in PQtrace regress mode A (relatively minor) annoyance of ErrorResponse/NoticeResponse messages as printed by PQtrace() is that their length might vary when we move error messages from one file to another, one function to another, or even when their location line number changes number of digits. To avoid having to adjust expected files for some tests, make the regress mode of PQtrace() suppress the length word of those messages. Discussion: https://postgr.es/m/20210402023010.GA13563@alvherre.pgsql Reviewed-by: Tom Lane --- src/interfaces/libpq/fe-trace.c | 11 ++++++++++- .../libpq_pipeline/traces/pipeline_abort.trace | 8 ++++---- .../modules/libpq_pipeline/traces/transaction.trace | 6 +++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/interfaces/libpq/fe-trace.c b/src/interfaces/libpq/fe-trace.c index 9a4595f5c8..ca24869e91 100644 --- a/src/interfaces/libpq/fe-trace.c +++ b/src/interfaces/libpq/fe-trace.c @@ -540,7 +540,16 @@ pqTraceOutputMessage(PGconn *conn, const char *message, bool toServer) length = (int) pg_ntoh32(length); logCursor += 4; - fprintf(conn->Pfdebug, "%s\t%d\t", prefix, length); + /* + * In regress mode, suppress the length of ErrorResponse and + * NoticeResponse. The F (file name), L (line number) and R (routine + * name) fields can change as server code is modified, and if their + * lengths differ from the originals, that would break tests. + */ + if (regress && !toServer && (id == 'E' || id == 'N')) + fprintf(conn->Pfdebug, "%s\tNN\t", prefix); + else + fprintf(conn->Pfdebug, "%s\t%d\t", prefix, length); switch (id) { diff --git a/src/test/modules/libpq_pipeline/traces/pipeline_abort.trace b/src/test/modules/libpq_pipeline/traces/pipeline_abort.trace index b061435785..254e485997 100644 --- a/src/test/modules/libpq_pipeline/traces/pipeline_abort.trace +++ b/src/test/modules/libpq_pipeline/traces/pipeline_abort.trace @@ -1,5 +1,5 @@ F 42 Query "DROP TABLE IF EXISTS pq_pipeline_demo" -B 123 NoticeResponse S "NOTICE" V "NOTICE" C "00000" M "table "pq_pipeline_demo" does not exist, skipping" F "SSSS" L "SSSS" R "SSSS" \x00 +B NN NoticeResponse S "NOTICE" V "NOTICE" C "00000" M "table "pq_pipeline_demo" does not exist, skipping" F "SSSS" L "SSSS" R "SSSS" \x00 B 15 CommandComplete "DROP TABLE" B 5 ReadyForQuery I F 99 Query "CREATE UNLOGGED TABLE pq_pipeline_demo(id serial primary key, itemno integer,int8filler int8);" @@ -27,7 +27,7 @@ B 4 ParseComplete B 4 BindComplete B 4 NoData B 15 CommandComplete "INSERT 0 1" -B 217 ErrorResponse S "ERROR" V "ERROR" C "42883" M "function no_such_function(integer) does not exist" H "No function matches the given name and argument types. You might need to add explicit type casts." P "8" F "SSSS" L "SSSS" R "SSSS" \x00 +B NN ErrorResponse S "ERROR" V "ERROR" C "42883" M "function no_such_function(integer) does not exist" H "No function matches the given name and argument types. You might need to add explicit type casts." P "8" F "SSSS" L "SSSS" R "SSSS" \x00 B 5 ReadyForQuery I B 4 ParseComplete B 4 BindComplete @@ -39,7 +39,7 @@ F 12 Bind "" "" 0 0 0 F 6 Describe P "" F 9 Execute "" 0 F 4 Sync -B 123 ErrorResponse S "ERROR" V "ERROR" C "42601" M "cannot insert multiple commands into a prepared statement" F "SSSS" L "SSSS" R "SSSS" \x00 +B NN ErrorResponse S "ERROR" V "ERROR" C "42601" M "cannot insert multiple commands into a prepared statement" F "SSSS" L "SSSS" R "SSSS" \x00 B 5 ReadyForQuery I F 54 Parse "" "SELECT 1.0/g FROM generate_series(3, -1, -1) g" 0 F 12 Bind "" "" 0 0 0 @@ -52,7 +52,7 @@ B 33 RowDescription 1 "?column?" NNNN 0 NNNN 65535 -1 0 B 32 DataRow 1 22 '0.33333333333333333333' B 32 DataRow 1 22 '0.50000000000000000000' B 32 DataRow 1 22 '1.00000000000000000000' -B 70 ErrorResponse S "ERROR" V "ERROR" C "22012" M "division by zero" F "SSSS" L "SSSS" R "SSSS" \x00 +B NN ErrorResponse S "ERROR" V "ERROR" C "22012" M "division by zero" F "SSSS" L "SSSS" R "SSSS" \x00 B 5 ReadyForQuery I F 40 Query "SELECT itemno FROM pq_pipeline_demo" B 31 RowDescription 1 "itemno" NNNN 2 NNNN 4 -1 0 diff --git a/src/test/modules/libpq_pipeline/traces/transaction.trace b/src/test/modules/libpq_pipeline/traces/transaction.trace index 0267a534fa..1dcc2373c0 100644 --- a/src/test/modules/libpq_pipeline/traces/transaction.trace +++ b/src/test/modules/libpq_pipeline/traces/transaction.trace @@ -1,5 +1,5 @@ F 79 Query "DROP TABLE IF EXISTS pq_pipeline_tst;CREATE TABLE pq_pipeline_tst (id int)" -B 122 NoticeResponse S "NOTICE" V "NOTICE" C "00000" M "table "pq_pipeline_tst" does not exist, skipping" F "SSSS" L "SSSS" R "SSSS" \x00 +B NN NoticeResponse S "NOTICE" V "NOTICE" C "00000" M "table "pq_pipeline_tst" does not exist, skipping" F "SSSS" L "SSSS" R "SSSS" \x00 B 15 CommandComplete "DROP TABLE" B 17 CommandComplete "CREATE TABLE" B 5 ReadyForQuery I @@ -40,9 +40,9 @@ B 4 BindComplete B 4 NoData B 10 CommandComplete "BEGIN" B 4 ParseComplete -B 65 ErrorResponse S "ERROR" V "ERROR" C "22012" M "division by zero" F "SSSS" L "SSSS" R "SSSS" \x00 +B NN ErrorResponse S "ERROR" V "ERROR" C "22012" M "division by zero" F "SSSS" L "SSSS" R "SSSS" \x00 B 5 ReadyForQuery E -B 145 ErrorResponse S "ERROR" V "ERROR" C "25P02" M "current transaction is aborted, commands ignored until end of transaction block" F "SSSS" L "SSSS" R "SSSS" \x00 +B NN ErrorResponse S "ERROR" V "ERROR" C "25P02" M "current transaction is aborted, commands ignored until end of transaction block" F "SSSS" L "SSSS" R "SSSS" \x00 B 5 ReadyForQuery E B 4 BindComplete B 4 NoData -- 2.20.1 --a8Wt8u1KmwUX3Y2C--