Re: [BUGS] BUG #14883: Syntax SQL error (42601), but should be adifferent error no - Mailing list pgsql-bugs

From David Rowley
Subject Re: [BUGS] BUG #14883: Syntax SQL error (42601), but should be adifferent error no
Date
Msg-id CAKJS1f-30JFzWsuSmHzRb2KJxQWZ57qxtEEXd4FXMDm4PfMHcQ@mail.gmail.com
Whole thread Raw
In response to [BUGS] BUG #14883: Syntax SQL error (42601),but should be a different error no  (stefan.hanenberg@googlemail.com)
Responses Re: [BUGS] BUG #14883: Syntax SQL error (42601), but should be adifferent error no  ("David G. Johnston" <david.g.johnston@gmail.com>)
List 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

pgsql-bugs by date:

Previous
From: stefan.hanenberg@googlemail.com
Date:
Subject: [BUGS] BUG #14883: Syntax SQL error (42601),but should be a different error no
Next
From: "David G. Johnston"
Date:
Subject: Re: [BUGS] BUG #14883: Syntax SQL error (42601), but should be adifferent error no