1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

Prevent remote notices from repeating local query details in logs

Since 112faf1378, 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@gmail.com>
Author: Vignesh C <vignesh21@gmail.com
Reviewed-by: Merlin Moncure <mmoncure@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAHyXU0yDwOYkWpRi=gtpDwjBxVqeaezgkgZLRWm2p1_FgaiPFQ@mail.gmail.com
Backpatch-though: 19
This commit is contained in:
Fujii Masao
2026-09-28 18:52:33 +09:00
parent bb356f869f
commit 23da62e98a

View File

@@ -498,8 +498,15 @@ libpqsrv_notice_receiver(void *arg, const PGresult *res)
if (len > 0 && message[len - 1] == '\n')
len--;
/*
* Omit the local statement and context from each remote message. They can
* help identify the caller, but repeating them for every message could
* greatly increase log volume.
*/
ereport(LOG,
errmsg_internal("%s: %.*s", prefix, len, message));
errmsg_internal("%s: %.*s", prefix, len, message),
errhidestmt(true),
errhidecontext(true));
}
#define PGresult libpqsrv_PGresult