Re: log bind parameter values on error

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Alexey Bashtanov <bashtanov(at)imap(dot)cc>
Cc: Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, david(at)pgmasters(dot)net
Subject: Re: log bind parameter values on error
Date: 2019-04-05 11:23:35
Message-ID: b1b68453-9756-bd92-306e-a29fc5ad7cd7@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2019-03-29 15:55, Alexey Bashtanov wrote:
>> ERROR: value "62812" is out of range for type smallint
>> STATEMENT: SELECT abalance FROM pgbench_accounts WHERE aid = $1;
>>
>> (In this case the error message contains the parameter value, so it's
>> not a very practical case, but it should work, it seems.)
> I guess this error occurred /while/ binding, so the parameters probably
> weren't yet all bound by the time of error reporting.
> That's why the error message came without parameters.

I see. But I think that could be fixed. Change exec_bind_message() to
loop over the parameters twice: once to save them away, once to actually
process them. I think the case of a faulty input value is probably very
common, so it would be confusing if that didn't work.

I think this patch needs some tests. Manually testing it is cumbersome,
and as we are seeing now, it is not quite clear which cases it is
supposed to cover. There are also additional cases for binary
parameters, and there are additions to the CSV output format. We need
tests for all that so the behavior explains itself and doesn't have to
be rediscovered every time someone wants to look at this again.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Khandekar 2019-04-05 11:38:39 Re: Minimal logical decoding on standbys
Previous Message Michael Paquier 2019-04-05 11:05:29 Re: pg_rewind vs superuser