Re: Attaching error cursor position to invalid constant values

Lists: pgsql-hackers
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Attaching error cursor position to invalid constant values
Date: 2008-08-30 20:18:57
Message-ID: 11413.1220127537@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I'm fooling around with getting the parser to report an error cursor
location if input conversion fails for a constant in a SQL command.
For instance:

regression=# select 42 = 'foo';
ERROR: invalid input syntax for integer: "foo"
LINE 1: select 42 = 'foo';
^
regression=# select '2000-jax-01'::date;
ERROR: invalid input syntax for type date: "2000-jax-01"
LINE 1: select '2000-jax-01'::date;
^
regression=#

This seems like it'd be a pretty useful thing to have in long queries,
but in short queries it looks a bit like overkill. And it affects
the expected output of a whole lot of the regression tests.

Does anyone think this might be "too chatty"?

regards, tom lane


From: "Stephen R(dot) van den Berg" <srb(at)cuci(dot)nl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Attaching error cursor position to invalid constant values
Date: 2008-08-30 23:29:59
Message-ID: 20080830232959.GA17682@cuci.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
>I'm fooling around with getting the parser to report an error cursor
>location if input conversion fails for a constant in a SQL command.

>This seems like it'd be a pretty useful thing to have in long queries,
>but in short queries it looks a bit like overkill. And it affects

I wanted to have this many times, actually I considered it a bug that
it didn't report the position.
--
Sincerely,
Stephen R. van den Berg.
Several ways to kill a programmer: kill -15, fair trial; kill -1, death by
hanging; kill -2, suicide; kill -3, euthanasia; kill -9, execution.


From: "Brendan Jurd" <direvus(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Attaching error cursor position to invalid constant values
Date: 2008-08-31 00:50:16
Message-ID: 37ed240d0808301750s5c1e98a8gb968d70446a9dd22@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Aug 31, 2008 at 6:18 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I'm fooling around with getting the parser to report an error cursor
> location if input conversion fails for a constant in a SQL command.
...
>
> This seems like it'd be a pretty useful thing to have in long queries,
> but in short queries it looks a bit like overkill. And it affects
> the expected output of a whole lot of the regression tests.
>

This is a cool idea, but as you say it's pretty pointless for one-liner queries.

What about implementing some kind of cutoff point for query length.
As in, "Display the cursor if the query is < $whatever characters
long"? I'm thinking most regression test queries would fall well
below a reasonable value of $whatever.

Cheers,
BJ


From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Brendan Jurd" <direvus(at)gmail(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Attaching error cursor position to invalid constant values
Date: 2008-08-31 04:02:04
Message-ID: 87zlmt4ytf.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


"Brendan Jurd" <direvus(at)gmail(dot)com> writes:

> On Sun, Aug 31, 2008 at 6:18 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> I'm fooling around with getting the parser to report an error cursor
>> location if input conversion fails for a constant in a SQL command.
> ...
>>
>> This seems like it'd be a pretty useful thing to have in long queries,
>> but in short queries it looks a bit like overkill. And it affects
>> the expected output of a whole lot of the regression tests.
>
> This is a cool idea, but as you say it's pretty pointless for one-liner queries.
>
> What about implementing some kind of cutoff point for query length.
> As in, "Display the cursor if the query is < $whatever characters
> long"? I'm thinking most regression test queries would fall well
> below a reasonable value of $whatever.

I don't think it's pointless at all from the server's point of view. The
server doesn't know what kind of tool is being used to view the results. If
it's a gooey tool then the tool will want to know where the error was so it
can highlight it or position the cursor.

Perhaps there could be a psql option to control whether to show the error
position and perhaps that setting could be based on the length of the query or
how many lines are in it but that seems unnecessarily baroque.

It doesn't seem outrageously chatty to me. Better to err on the side of being
too helpful to the user than not helpful enough.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's PostGIS support!


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: "Brendan Jurd" <direvus(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Attaching error cursor position to invalid constant values
Date: 2008-08-31 05:13:05
Message-ID: 29336.1220159585@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> "Brendan Jurd" <direvus(at)gmail(dot)com> writes:
>> What about implementing some kind of cutoff point for query length.

> Perhaps there could be a psql option to control whether to show the error
> position and perhaps that setting could be based on the length of the query or
> how many lines are in it but that seems unnecessarily baroque.

Yeah, if we were to do something like that it should clearly be a
client-side decision.

> It doesn't seem outrageously chatty to me. Better to err on the side of being
> too helpful to the user than not helpful enough.

Currently, for the things we show an error cursor for, there's no lower
limit on query length, eg

regression=# select nosuchcol from int4_tbl;
ERROR: column "nosuchcol" does not exist
LINE 1: select nosuchcol from int4_tbl;
^
regression=#

and I don't recall having heard any complaints about that. I was just a
bit shell-shocked by the number of regression test diffs my patch
generated. But on looking closer, the reason is the intentional testing
of bad values in a lot of the datatype-specific tests. So that's
probably not a good indicator of how chatty it'll seem to regular users.

regards, tom lane


From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Brendan Jurd" <direvus(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Attaching error cursor position to invalid constant values
Date: 2008-08-31 05:27:27
Message-ID: 87vdxh4uv4.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> and I don't recall having heard any complaints about that. I was just a
> bit shell-shocked by the number of regression test diffs my patch
> generated. But on looking closer, the reason is the intentional testing
> of bad values in a lot of the datatype-specific tests. So that's
> probably not a good indicator of how chatty it'll seem to regular users.

The only logical argument I see here for why this case is any different is
that since the constant is present in the original query and it's repeated in
the error the user has enough information to immediately identify the source
of the error. That's not true for other types of errors where the site of the
error isn't obvious from the error message.

But even for constants it's not entirely true either. You could have something
like:

select 'foo'+0, 'foo'+0.0;

and when you get the error the you would have to deduce which constant is in
error based on the type it describes. That could be quite a bit more complex
than this example.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Get trained by Bruce Momjian - ask me about EnterpriseDB's PostgreSQL training!


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Attaching error cursor position to invalid constant values
Date: 2008-09-01 10:59:49
Message-ID: 48BBCB25.6070001@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Does anyone think this might be "too chatty"?

No.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com


From: "Asko Oja" <ascoja(at)gmail(dot)com>
To: "Heikki Linnakangas" <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Attaching error cursor position to invalid constant values
Date: 2008-09-01 11:13:58
Message-ID: ecd779860809010413n2ad26333xb7ceabbb05d72382@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Sep 1, 2008 at 12:59 PM, Heikki Linnakangas <
heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:

> Tom Lane wrote:
>
>> Does anyone think this might be "too chatty"?
>>
>
> No.
>
+1

>
> --
> Heikki Linnakangas
> EnterpriseDB http://www.enterprisedb.com
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>