Re: log bind parameter values on error
Alvaro Herrera <alvherre@2ndquadrant.com>
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andres Freund <andres@anarazel.de>, Alexey Bashtanov <bashtanov@imap.cc>, Peter Eisentraut <peter.eisentraut@2ndquadrant.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2019-12-10T19:33:39Z
Lists: pgsql-hackers
Attachments
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 https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Commits
-
Emit parameter values during query bind/execute errors
- ba79cb5dc841 13.0 landed
-
Add backend-only appendStringInfoStringQuoted
- 6cafde1bd43f 13.0 landed