pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #14883: Syntax SQL error (42601), but should be a different error no
6+ messages / 5 participants
[nested] [flat]
* BUG #14883: Syntax SQL error (42601), but should be a different error no
@ 2017-10-31 00:36 stefan.hanenberg@googlemail.com
2017-10-31 01:35 ` Re: BUG #14883: Syntax SQL error (42601), but should be a different error no David Rowley <david.rowley@2ndquadrant.com>
0 siblings, 1 reply; 6+ messages in thread
From: stefan.hanenberg@googlemail.com @ 2017-10-31 00:36 UTC (permalink / raw)
To: pgsql-bugs; +Cc: stefan.hanenberg@googlemail.com
The following bug has been logged on the website:
Bug reference: 14883
Logged by: Stefan Hanenberg
Email address: stefan.hanenberg@googlemail.com
PostgreSQL version: 10.0
Operating system: Windows 10/64
Description:
I am not 100% sure whether this is really a bug, I report it anyway.
The following SQL statement leads to an error 42601 (syntax error), although
the error is not a syntax error.
create table t1 (a integer,b integer);
create table t2 (a integer,b integer,c integer);
select * from t1 union select * from t2;
We are currently running automated tests on hundreds of thousands SQL in
order to check, what kind of errors they contain. It is really problematic
for us that the error is a 42601 error, although it seems rather as if it is
a type error.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #14883: Syntax SQL error (42601), but should be a different error no
2017-10-31 00:36 BUG #14883: Syntax SQL error (42601), but should be a different error no stefan.hanenberg@googlemail.com
@ 2017-10-31 01:35 ` David Rowley <david.rowley@2ndquadrant.com>
2017-10-31 02:07 ` Re: BUG #14883: Syntax SQL error (42601), but should be a different error no David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: David Rowley @ 2017-10-31 01:35 UTC (permalink / raw)
To: stefan.hanenberg@googlemail.com; +Cc: pgsql-bugs
On 31 October 2017 at 13:36, <stefan.hanenberg@googlemail.com> wrote:
> The following SQL statement leads to an error 42601 (syntax error), although
> the error is not a syntax error.
>
> create table t1 (a integer,b integer);
> create table t2 (a integer,b integer,c integer);
> select * from t1 union select * from t2;
>
> We are currently running automated tests on hundreds of thousands SQL in
> order to check, what kind of errors they contain. It is really problematic
> for us that the error is a 42601 error, although it seems rather as if it is
> a type error.
I guess it depends on how you've written the query. If you'd done:
select a,b from t1 union select a,b,c from t2;
then a syntax error seems a bit more reasonable.
The problem is that the '*' is just expanded to all non-dropped
columns well before getting to where that error is generated.
To fix it we'd likely need to just mark that the RangeTblEntry was
expanded in expandRelAttrs() then generate some other SQLCODE if any
of the RangeTblEntries where expanded.
So it looks simple enough to fix, at first glance.
--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #14883: Syntax SQL error (42601), but should be a different error no
2017-10-31 00:36 BUG #14883: Syntax SQL error (42601), but should be a different error no stefan.hanenberg@googlemail.com
2017-10-31 01:35 ` Re: BUG #14883: Syntax SQL error (42601), but should be a different error no David Rowley <david.rowley@2ndquadrant.com>
@ 2017-10-31 02:07 ` David G. Johnston <david.g.johnston@gmail.com>
2017-10-31 02:50 ` Re: BUG #14883: Syntax SQL error (42601), but should be a different error no Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: David G. Johnston @ 2017-10-31 02:07 UTC (permalink / raw)
To: David Rowley <david.rowley@2ndquadrant.com>; +Cc: pgsql-bugs
On Mon, Oct 30, 2017 at 6:35 PM, David Rowley <david.rowley@2ndquadrant.com>
wrote:
> On 31 October 2017 at 13:36, <stefan.hanenberg@googlemail.com> wrote:
> > The following SQL statement leads to an error 42601 (syntax error),
> although
> > the error is not a syntax error.
>
> > We are currently running automated tests on hundreds of thousands SQL in
> > order to check, what kind of errors they contain. It is really
> problematic
> > for us that the error is a 42601 error, although it seems rather as if
> it is
> > a type error.
>
> then a syntax error seems a bit more reasonable.
>
Someone familiar with the SQL standard would need to confirm that our
choice in this case is not governed by the standard before I'd consider
changing it.
That said, I can make an argument for 42804 (datatype_mismatch) - which
still has a syntax error classification - since the implicit row-types from
the two input relations do not match each other.
The example error would read:
UNION types (int, int) and (int, int, int) cannot be matched
David J.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #14883: Syntax SQL error (42601), but should be a different error no
2017-10-31 00:36 BUG #14883: Syntax SQL error (42601), but should be a different error no stefan.hanenberg@googlemail.com
2017-10-31 01:35 ` Re: BUG #14883: Syntax SQL error (42601), but should be a different error no David Rowley <david.rowley@2ndquadrant.com>
2017-10-31 02:07 ` Re: BUG #14883: Syntax SQL error (42601), but should be a different error no David G. Johnston <david.g.johnston@gmail.com>
@ 2017-10-31 02:50 ` Tom Lane <tgl@sss.pgh.pa.us>
2017-11-03 11:09 ` Re: BUG #14883: Syntax SQL error (42601), but should be a different error no Stefan Hanenberg <stefan.hanenberg@googlemail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Tom Lane @ 2017-10-31 02:50 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: David Rowley <david.rowley@2ndquadrant.com>; pgsql-bugs
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> Someone familiar with the SQL standard would need to confirm that our
> choice in this case is not governed by the standard before I'd consider
> changing it.
The SQL committee takes basically no interest in this area: their
taxonomy for syntax & semantic analysis errors consists of
(wait for it...)
Class 42 syntax error or access rule violation
with exactly no standard-defined subclasses. Whatever implementations
do to distinguish different subcategories is up to them (although IIRC
we borrowed some of our subcategories from DB2, so they're not things
we came up with out of noplace).
I agree that there's some case for considering this to be
ERRCODE_DATATYPE_MISMATCH, but I'm not sure that the case is strong
enough to justify a compatibility break from changing it.
More generally, there are a *lot* of ERRCODE_SYNTAX_ERROR calls in
the backend that could arguably be changed to something more specific,
even without inventing any new subcategories for the purpose. If we were
to decide that we're willing to make a compatibility break here, I'd
rather see a patch that goes through all of them and changes what seems
reasonable. Better a big break than drip drip drip ...
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #14883: Syntax SQL error (42601), but should be a different error no
2017-10-31 00:36 BUG #14883: Syntax SQL error (42601), but should be a different error no stefan.hanenberg@googlemail.com
2017-10-31 01:35 ` Re: BUG #14883: Syntax SQL error (42601), but should be a different error no David Rowley <david.rowley@2ndquadrant.com>
2017-10-31 02:07 ` Re: BUG #14883: Syntax SQL error (42601), but should be a different error no David G. Johnston <david.g.johnston@gmail.com>
2017-10-31 02:50 ` Re: BUG #14883: Syntax SQL error (42601), but should be a different error no Tom Lane <tgl@sss.pgh.pa.us>
@ 2017-11-03 11:09 ` Stefan Hanenberg <stefan.hanenberg@googlemail.com>
2017-11-03 14:12 ` Re: BUG #14883: Syntax SQL error (42601), but should be a different error no David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Hanenberg @ 2017-11-03 11:09 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; David G. Johnston <david.g.johnston@gmail.com>; +Cc: David Rowley <david.rowley@2ndquadrant.com>; pgsql-bugs
Am 31.10.2017 um 03:50 schrieb Tom Lane:
> More generally, there are a *lot* of ERRCODE_SYNTAX_ERROR calls in
> the backend that could arguably be changed to something more specific,
> even without inventing any new subcategories for the purpose. If we were
> to decide that we're willing to make a compatibility break here, I'd
> rather see a patch that goes through all of them and changes what seems
> reasonable. Better a big break than drip drip drip ...
I would be really happy if the error codes would reflect more on what
the error actually is -- at least for our automated tests, it turns out
to be quite complicated without directly using Postgres -- currently, we
have to use our own SQL parser in order to double check whether the
error is actually an syntac error or not.
Thanks for your reactions!
Best,
Stefan
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #14883: Syntax SQL error (42601), but should be a different error no
2017-10-31 00:36 BUG #14883: Syntax SQL error (42601), but should be a different error no stefan.hanenberg@googlemail.com
2017-10-31 01:35 ` Re: BUG #14883: Syntax SQL error (42601), but should be a different error no David Rowley <david.rowley@2ndquadrant.com>
2017-10-31 02:07 ` Re: BUG #14883: Syntax SQL error (42601), but should be a different error no David G. Johnston <david.g.johnston@gmail.com>
2017-10-31 02:50 ` Re: BUG #14883: Syntax SQL error (42601), but should be a different error no Tom Lane <tgl@sss.pgh.pa.us>
2017-11-03 11:09 ` Re: BUG #14883: Syntax SQL error (42601), but should be a different error no Stefan Hanenberg <stefan.hanenberg@googlemail.com>
@ 2017-11-03 14:12 ` David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 0 replies; 6+ messages in thread
From: David G. Johnston @ 2017-11-03 14:12 UTC (permalink / raw)
To: Stefan Hanenberg <stefan.hanenberg@googlemail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; David Rowley <david.rowley@2ndquadrant.com>; pgsql-bugs
On Fri, Nov 3, 2017 at 4:09 AM, Stefan Hanenberg <
stefan.hanenberg@googlemail.com> wrote:
> I would be really happy if the error codes would reflect more on what the
> error actually is -- at least for our automated tests,
>
This single example doesn't really motivate me to want to vote to change
even this single instance let alone wish for the big project Tom want's.
If you are unable to scratch your own itch here you are going to need to be
more forthcoming as to your application if you hope to convince others to
do so on your behalf. Though the lack of anyone else chiming in with a "me
too" doesn't bode well.
In any case I'd say this isn't a bug, or if it is at present its a "won't
fix". If you want to continue this please begin a new thread on
pgsql-general.
David J.
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2017-11-03 14:12 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-10-31 00:36 BUG #14883: Syntax SQL error (42601), but should be a different error no stefan.hanenberg@googlemail.com
2017-10-31 01:35 ` David Rowley <david.rowley@2ndquadrant.com>
2017-10-31 02:07 ` David G. Johnston <david.g.johnston@gmail.com>
2017-10-31 02:50 ` Tom Lane <tgl@sss.pgh.pa.us>
2017-11-03 11:09 ` Stefan Hanenberg <stefan.hanenberg@googlemail.com>
2017-11-03 14:12 ` David G. Johnston <david.g.johnston@gmail.com>
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