pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Alexey Bashtanov <bashtanov@imap.cc>
Cc: Andres Freund <andres@anarazel.de>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Cc: david@pgmasters.net
Subject: Re: log bind parameter values on error
Date: Fri, 5 Apr 2019 13:23:35 +0200
Message-ID: <b1b68453-9756-bd92-306e-a29fc5ad7cd7@2ndquadrant.com> (raw)
In-Reply-To: <0da3d152-be04-7cfb-56b3-866f24223e69@imap.cc>
References: <0146a67b-a22a-0519-9082-bc29756b93a2@imap.cc>
	<c4891f99-8385-5c31-1aac-e226356ec964@2ndquadrant.com>
	<ad08f6a3-e38c-f851-a5a2-0bf68d1d7f72@imap.cc>
	<896ac2ed-7735-1f24-d877-3249b38bb6fe@2ndquadrant.com>
	<8efd95fe-3886-61f0-0faa-6c661cd2f874@imap.cc>
	<084a044f-9d77-b931-0658-5d871df8a2f8@imap.cc>
	<96007f6e-1e42-e454-9db4-e7842e137508@2ndquadrant.com>
	<ce9cd06a-ebb4-7978-ef2e-52a4d94d4fc4@imap.cc>
	<20190214202842.nyx4khxsd43z4xxh@alap3.anarazel.de>
	<baf340fb-baac-832a-a5e0-a82babb07c60@imap.cc>
	<b88e8929-1eaf-67d6-2b33-76e462624d12@2ndquadrant.com>
	<0da3d152-be04-7cfb-56b3-866f24223e69@imap.cc>

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





view thread (70+ messages)  latest in thread

Message-ID: <b1b68453-9756-bd92-306e-a29fc5ad7cd7@2ndquadrant.com>
Permalink:  ../b1b68453-9756-bd92-306e-a29fc5ad7cd7@2ndquadrant.com/
Also on:    postgresql.org/message-id/b1b68453-9756-bd92-306e-a29fc5ad7cd7@2ndquadrant.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: peter.eisentraut@2ndquadrant.com, bashtanov@imap.cc, andres@anarazel.de, david@pgmasters.net
  Subject: Re: log bind parameter values on error
  In-Reply-To: <b1b68453-9756-bd92-306e-a29fc5ad7cd7@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox