| From: | Fujii Masao <fujii(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Improve log_statement_max_length truncation reporting |
| Date: | 2026-07-09 23:38:54 |
| Message-ID: | E1whyKU-000MpW-0s@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Improve log_statement_max_length truncation reporting
log_statement_max_length limits the statement text logged by
log_statement and duration logging. However, the prepared statement
shown in the DETAIL message for EXECUTE was still logged in full,
allowing very large prepared queries to bypass the limit.
Apply the same truncation to the prepared statement text in
errdetail_execute(), making the setting behave consistently across the
main log message and its associated DETAIL output.
Also append an ellipsis to truncated statement text so users can easily
tell when truncation has occurred. With this change, a limit of zero
logs only the ellipsis, indicating that the entire statement text was
truncated.
Finally, avoid scanning the entire query string just to determine
whether truncation is needed. Use strnlen() with sufficient lookahead
for multibyte character handling, then use pg_mbcliplen() to ensure
truncation never splits a multibyte character.
Author: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAHGQGwFOV+7nOdfoO=kfVH=-fRA9aQE1YcHHLYty3nfQ9rQ4RA@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/999a8412bbabec4811195fee7e315c282c97f694
Modified Files
--------------
doc/src/sgml/config.sgml | 6 ++-
src/backend/tcop/postgres.c | 25 +++++++++---
src/backend/utils/misc/guc_parameters.dat | 4 +-
src/backend/utils/misc/postgresql.conf.sample | 4 +-
.../test_misc/t/014_log_statement_max_length.pl | 45 ++++++++++++++++------
5 files changed, 60 insertions(+), 24 deletions(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Etsuro Fujita | 2026-07-10 04:22:04 | pgsql: postgres_fdw: Remove SPI from postgresImportForeignStatistics. |
| Previous Message | Alexander Korotkov | 2026-07-09 19:25:31 | pgsql: Bump catversion for JSON_TABLE PLAN clause |