From 761e99312f6ec5db2f4539f6f455664e8aa1815d Mon Sep 17 00:00:00 2001 From: Vignesh C Date: Thu, 24 Sep 2026 13:47:35 +0530 Subject: [PATCH v1] Don't log local statement and context with remote messages. Since 112faf1378ee, NOTICE, WARNING, and similar messages received over replication, postgres_fdw, and dblink connections are reported with ereport(LOG). LOG passes the default log_min_error_statement = error, so every such message was logged with a STATEMENT line carrying the full text of whatever local query was running, and, when received inside PL/pgSQL, with a CONTEXT line saying only where libpq happened to be reading input. Neither describes the remote message, and both are repeated for each one, so a query receiving many notices wrote several times the log volume of earlier releases and ran correspondingly slower. Suppress both with errhidestmt() and errhidecontext(), so each remote message is again a single log line. --- src/include/libpq/libpq-be-fe-helpers.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/include/libpq/libpq-be-fe-helpers.h b/src/include/libpq/libpq-be-fe-helpers.h index cff68cd1c37..dd38dea2e25 100644 --- a/src/include/libpq/libpq-be-fe-helpers.h +++ b/src/include/libpq/libpq-be-fe-helpers.h @@ -498,8 +498,18 @@ libpqsrv_notice_receiver(void *arg, const PGresult *res) if (len > 0 && message[len - 1] == '\n') len--; + /* + * Don't log the local statement or context. This runs once for every + * message the remote server sends, and LOG passes the default + * log_min_error_statement, so each message would otherwise repeat the + * whole text of whatever local query is running. The local context only + * says where libpq happened to be reading input, not what caused the + * message. + */ ereport(LOG, - errmsg_internal("%s: %.*s", prefix, len, message)); + errmsg_internal("%s: %.*s", prefix, len, message), + errhidestmt(true), + errhidecontext(true)); } #define PGresult libpqsrv_PGresult -- 2.55.0