Re: log bind parameter values on error

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Alexey Bashtanov <bashtanov(at)imap(dot)cc>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: log bind parameter values on error
Date: 2019-12-10 19:33:39
Message-ID: 20191210193339.GA12216@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2019-Dec-07, Tom Lane wrote:

> 0002:

Here's a version of this part with fixes for these comments. It applies
on top of the stringinfo_mb.c patch sent elsewhere in the thread.

(If we were to add a "log_parameters_on_error_max_length" GUC to decide
the length to log, we would get rid of the remaining magical numbers in
this code).

> Seems like BuildParamLogString's "valueLen" parameter ought to be called
> "maxlen", for consistency with 0001 and because "valueLen" is at best
> misleading about what the parameter means.
> I'd toss the enlargeStringInfo call here too, as it seems overly
> complicated and underly correct or useful.
> Probably doing MemoryContextReset after each parameter (even the last one!)
> is a net loss compared to just letting it go till the end. Although
> I'd be inclined to use ALLOCSET_DEFAULT_SIZES not SMALL_SIZES if you
> do it like that.
> Please do not throw away the existing comment "/* Free result of encoding
> conversion, if any */" in exec_bind_message.
> As above, this risks generating partial multibyte characters. You might
> be able to get away with letting appendStringInfoStringQuoted do the
> multibyte-aware truncation, but you probably have to copy more than just
> one more extra byte first.
> I have zero faith in this:
> + params_errcxt.arg = (void *) &((ParamsErrorCbData)
> + { portal->name, params });
> How do you know where the compiler is putting that value, ie what
> its lifespan is going to be? Better to use an explicit variable.
> I concur with dropping testlibpq5.
> regards, tom lane

Álvaro Herrera
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
v21-0002-Emit-parameter-values-during-query-bind-execute-.patch text/x-diff 17.5 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2019-12-10 19:39:47 Re: backup manifests
Previous Message Alvaro Herrera 2019-12-10 18:59:13 Re: log bind parameter values on error