From: kai@schwebke.com
To: pgsql-bugs@postgresql.org
Subject: BUG #10793: Empty result set instead of column does not exist error using CTE.
Date: Sat, 28 Jun 2014 06:41:57 +0000
Message-ID: <20140628064157.15696.15715@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: 10793
Logged by: Kai Schwebke
Email address: kai@schwebke.com
PostgreSQL version: 9.3.4
Operating system: Linux
Description:
To reproduce the issue create a table:
CREATE TABLE t1 (id INTEGER, val INTEGER);
INSERT INTO t1 VALUES (1, 1);
INSERT INTO t1 VALUES (2, 2);
This query returns an empty result set:
WITH t1_cte AS
(SELECT id FROM t1 WHERE val=1)
SELECT id FROM t1
WHERE id NOT IN
(SELECT val FROM t1_cte);
-->
id
----
(0 rows)
Instead the query should be rejected with
'ERROR: column "val" does not exist',
because val is not in the CTE t1_cte.
Note that this query does return a non-empty result set:
WITH t1_cte AS
(SELECT id, val FROM t1 WHERE val=1)
SELECT id FROM t1
WHERE id NOT IN
(SELECT val FROM t1_cte);
-->
id
----
2
(1 row)
So the issue is not just that the columns which are not selected
in the CTE are still present and just the error message is missing.
Instead the error message is missing and a wrong result set is returned.
--
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: kai@schwebke.com
Subject: Re: BUG #10793: Empty result set instead of column does not exist error using CTE.
In-Reply-To: <20140628064157.15696.15715@wrigleys.postgresql.org>
References: <20140628064157.15696.15715@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