From: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
Cc: | Alexey Bashtanov <bashtanov(at)imap(dot)cc>, Franck Verrot <franck(at)verrot(dot)fr>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCH]: Allow errors in parameter values to be reported during the BIND phase itself.. |
Date: | 2021-02-23 16:03:18 |
Message-ID: | 20210223160318.GE14772@telsasoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Feb 22, 2021 at 11:15:25AM -0600, Justin Pryzby wrote:
> On Sun, Feb 21, 2021 at 11:05:26PM -0600, Justin Pryzby wrote:
> > On Mon, Jan 04, 2021 at 11:09:39AM -0600, Justin Pryzby wrote:
> > > For example:
> > >
> > > $ python3.5 -c "import pg; db=pg.DB(); q = db.query(\"SET log_parameter_max_length_on_error=-1;\"); db.prepare('p', 'SELECT \$1::smallint'); db.query_prepared('p',66666);"
> > > 2021-01-03 02:21:04.547 CST [20157] ERROR: value "66666" is out of range for type smallint
> > > 2021-01-03 02:21:04.547 CST [20157] CONTEXT: unnamed portal with parameters: $1 = '66666'
> > > 2021-01-03 02:21:04.547 CST [20157] STATEMENT: SELECT $1::smallint
> > >
> > > When there are many bind params, this can be useful to determine which is out
> > > of range. Think 900 int/smallint columns, or less-wide tables being inserted
> > > multiple rows at a time with VALUES(),(),()...
> >
> > This fixes a crash when there are zero bind params, and the error context was
> > popped after not being pushed.
>
> The previous patch was dysfynctional due to params_data.params = NULL.
> This also fixes an issue with string termination.
> And added a new test case.
I noticed that this would crash with binary mode parameter input from
PQexecParams, if typinput failed.
So this patch allows reporting of bind params on errors in typinput if all the
params are sent in text mode (which is typical).
But if they're sent in binary mode, we can't provide error output before
they're processed by the typinput function.
I added ecpg tests to exercize the binary mode cases.
--
Justin
Attachment | Content-Type | Size |
---|---|---|
0001-Report-text-parameters-during-errors-in-typinput.patch | text/x-diff | 10.0 KB |
0002-Exercize-parameter-output-on-error-with-binary-param.patch | text/x-diff | 81.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Gustafsson | 2021-02-23 16:14:28 | Re: pg_upgrade version checking questions |
Previous Message | Álvaro Herrera | 2021-02-23 15:26:23 | Re: {CREATE INDEX, REINDEX} CONCURRENTLY improvements |