pgsql: Prevent remote notices from repeating local query details in log

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Prevent remote notices from repeating local query details in log
Date: 2026-09-28 09:54:52
Message-ID: E1xB84S-00000001aPH-33Qc@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Prevent remote notices from repeating local query details in logs

Since 112faf1378ee, NOTICE, WARNING, and similar messages received through
dblink, postgres_fdw, and replication connections have been logged with
ereport(LOG). With the default log_min_error_statement setting, each
such log entry can also include the current local SQL statement. An active
error-context callback can add local CONTEXT information as well. Repeating
these fields for every remote message increases log volume and processing
overhead.

Use errhidestmt() and errhidecontext() when logging these messages to
prevent the local STATEMENT and CONTEXT fields, when present, from being
repeated for each remote message in the server log.

Reported-by: Merlin Moncure <mmoncure(at)gmail(dot)com>
Author: Vignesh C <vignesh21(at)gmail(dot)com
Reviewed-by: Merlin Moncure <mmoncure(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAHyXU0yDwOYkWpRi=gtpDwjBxVqeaezgkgZLRWm2p1_FgaiPFQ@mail.gmail.com
Backpatch-though: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/23da62e98a7c33977134e8d0318d109fca3a8954

Modified Files
--------------
src/include/libpq/libpq-be-fe-helpers.h | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Amit Kapila 2026-09-28 11:24:01 pgsql: Fix tuple search during apply after concurrent index DDL.
Previous Message Fujii Masao 2026-09-28 09:54:39 pgsql: Prevent remote notices from repeating local query details in log