From 0b34e7d307e6a142ee94800e6d5f3e73449eeffd Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 2 Apr 2020 15:04:51 -0400 Subject: Improve user control over truncation of logged bind-parameter values. This patch replaces the boolean GUC log_parameters_on_error introduced by commit ba79cb5dc with an integer log_parameter_max_length_on_error, adding the ability to specify how many bytes to trim each logged parameter value to. (The previous coding hard-wired that choice at 64 bytes.) In addition, add a new parameter log_parameter_max_length that provides similar control over truncation of query parameters that are logged in response to statement-logging options, as opposed to errors. Previous releases always logged such parameters in full, possibly causing log bloat. For backwards compatibility with prior releases, log_parameter_max_length defaults to -1 (log in full), while log_parameter_max_length_on_error defaults to 0 (no logging). Per discussion, log_parameter_max_length is SUSET since the DBA should control routine logging behavior, but log_parameter_max_length_on_error is USERSET because it also affects errcontext data sent back to the client. Alexey Bashtanov, editorialized a little by me Discussion: https://postgr.es/m/b10493cc-a399-a03a-67c7-068f2791ee50@imap.cc --- src/backend/utils/mb/stringinfo_mb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/backend/utils/mb/stringinfo_mb.c') diff --git a/src/backend/utils/mb/stringinfo_mb.c b/src/backend/utils/mb/stringinfo_mb.c index d7cf3751aa3..5f51f538c18 100644 --- a/src/backend/utils/mb/stringinfo_mb.c +++ b/src/backend/utils/mb/stringinfo_mb.c @@ -27,7 +27,7 @@ * appendStringInfoStringQuoted * * Append up to maxlen bytes from s to str, or the whole input string if - * maxlen <= 0, adding single quotes around it and doubling all single quotes. + * maxlen < 0, adding single quotes around it and doubling all single quotes. * Add an ellipsis if the copy is incomplete. */ void @@ -43,9 +43,9 @@ appendStringInfoStringQuoted(StringInfo str, const char *s, int maxlen) Assert(str != NULL); slen = strlen(s); - if (maxlen > 0 && maxlen < slen) + if (maxlen >= 0 && maxlen < slen) { - int finallen = pg_mbcliplen(s, slen, maxlen); + int finallen = pg_mbcliplen(s, slen, maxlen); copy = pnstrdup(s, finallen); chunk_search_start = copy; -- cgit v1.2.3