From: zuberre@gmail.com
To: pgsql-bugs@postgresql.org
Cc: zuberre@gmail.com
Subject: BUG #14754: ecpg SQL parsing error
Date: Fri, 21 Jul 2017 14:16:40 +0000
Message-ID: <20170721141640.19351.88347@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 14754
Logged by: Richard Zuber
Email address: zuberre@gmail.com
PostgreSQL version: 9.5.7
Operating system: CentOS 7.3.1611
Description:
Hello,
I’ve been using ecpg as part of my automated test framework to ensure my
various SQL migrations have proper syntax. I believe I have run into an
error where ECPG is reporting a syntax error that does not in fact exist.
Assume the following table is defined (though this should not be relevant to
the issue):
CREATE TABLE foo
(
id SERIAL NOT NULL,
name text NOT NULL,
PRIMARY KEY (id)
);
There are two files to be fed into ecpg (version - ecpg (PostgreSQL 9.5.7)
4.11.0) :
--doesnt_work.sql
EXEC SQL WITH cte AS
(
INSERT INTO foo(name)
VALUES
('bar')
RETURNING id
)
SELECT * FROM foo;
--EOF
The output of “doesn’t_work.sql” is:
$ ecpg doesnt_work.sql
doesnt_work.sql:7: ERROR: syntax error at or near ")"
$ echo $?
3
Since this is a valid statement from a syntax perspective (ignoring what the
statement does), I would expect no error.
The following appears to work as expected:
--works.sql
EXEC SQL WITH cte AS
(
INSERT INTO foo(name)
VALUES
('bar')
)
SELECT * FROM foo;
--EOF
$ ecpg works.sql
$ echo $?
0
The difference between the two is the use of the “RETURNING” statement in
the CTE. I have reviewed section 33.5 of the manual. While I took note of
33.5.3 in the manual, this statement does not actually return a result set.
That said, I may be misinterpreting the documentation in this matter.
I have reviewed release notes from later versions of postgres as well as the
open TODOs, but have not seen anything that appears to relate to this
behavior.
I appreciate your attention,
Richard Zuber
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: zuberre@gmail.com
Subject: Re: BUG #14754: ecpg SQL parsing error
In-Reply-To: <20170721141640.19351.88347@wrigleys.postgresql.org>
References: <20170721141640.19351.88347@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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