potential bug in error message in with clause

Lists: pgsql-hackers
From: Szymon Guz <mabewlun(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: potential bug in error message in with clause
Date: 2013-07-29 07:03:40
Message-ID: CAFjNrYsjzd3SCsNzrg9tywwXDX6thNqwvagBBkQCc9OP8ur3dw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,
today on IRC there was a strange problem shown. The small working example
looks like this:

x=# with x as (insert into a(t) values('1') returning *) select * from x;
t
---
1
(1 row)

x=# with x (insert into a(t) values('1') returning *) select * from x;
ERROR: syntax error at or near "into"
LINE 1: with x (insert into a(t) values('1') returning *) select * f...
^

The initial code was run on 9.2; I've checked that on 9.4devel.

The error message is really not useful, as there is missing "as" after
"with x". There is no problem with "into".

regards
Szymon


From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Szymon Guz *EXTERN*" <mabewlun(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: potential bug in error message in with clause
Date: 2013-07-29 08:11:38
Message-ID: A737B7A37273E048B164557ADEF4A58B17BF1986@ntex2010a.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Szymon Guz wrote:
> today on IRC there was a strange problem shown. The small working example looks like this:
>
> x=# with x as (insert into a(t) values('1') returning *) select * from x;
> t
> ---
> 1
> (1 row)
>
> x=# with x (insert into a(t) values('1') returning *) select * from x;
> ERROR: syntax error at or near "into"
> LINE 1: with x (insert into a(t) values('1') returning *) select * f...
> ^
>
> The initial code was run on 9.2; I've checked that on 9.4devel.
>
> The error message is really not useful, as there is missing "as" after "with x". There is no problem
> with "into".

I don't think that's a bug.

A parenthesis after with_query_name introduces the list of column
names for the WITH-query, and it complains that there is no comma
or closing parenthesis after "insert".

Yours,
Laurenz Albe