Re: BUG #14883: Syntax SQL error (42601), but should be a different error no

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: stefan(dot)hanenberg(at)googlemail(dot)com
Cc: PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14883: Syntax SQL error (42601), but should be a different error no
Date: 2017-10-31 01:35:17
Message-ID: CAKJS1f-30JFzWsuSmHzRb2KJxQWZ57qxtEEXd4FXMDm4PfMHcQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 31 October 2017 at 13:36, <stefan(dot)hanenberg(at)googlemail(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2017-10-31 02:07:23 Re: BUG #14883: Syntax SQL error (42601), but should be a different error no
Previous Message stefan.hanenberg 2017-10-31 00:36:01 BUG #14883: Syntax SQL error (42601), but should be a different error no