pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #15128: Erroneous inner query is executing with wrong results
2+ messages / 2 participants
[nested] [flat]
* BUG #15128: Erroneous inner query is executing with wrong results
@ 2018-03-22 14:25 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 2+ messages in thread
From: PG Bug reporting form @ 2018-03-22 14:25 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: yossi.eilaty@gong.io
The following bug has been logged on the website:
Bug reference: 15128
Logged by: Yossi Eilaty
Email address: yossi.eilaty@gong.io
PostgreSQL version: 9.6.2
Operating system: x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2
Description:
Consider the following tables:
CREATE TABLE a (
r BIGINT,
y BIGINT
);
CREATE TABLE b (
x BIGINT,
y BIGINT
);
with the following data:
INSERT INTO a (r, y) VALUES (1, 1);
INSERT INTO a (r, y) VALUES (2, 2);
INSERT INTO b (x, y) VALUES (1, 1);
INSERT INTO b (x, y) VALUES (2, 2);
If I run the following query:
SELECT y
FROM b
WHERE x IN (SELECT x
FROM (SELECT r
FROM a
WHERE y = 1) the_x);
I get, as a result, the y value of all rows of table b, which is wrong since
the inner query
SELECT x
FROM (SELECT r
FROM a
WHERE y = 1) the_x
is wrong and if run solely returns the error "[42703] ERROR: column "x" does
not exist", which is correct.
The same thing happens for the following query:
SELECT y
FROM b
WHERE x IN (SELECT x
FROM (SELECT x
FROM a
WHERE y = 1) the_x);
where, again, the innermost query is wrong (there's no x in a).
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #15128: Erroneous inner query is executing with wrong results
@ 2018-03-22 15:02 David G. Johnston <david.g.johnston@gmail.com>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 0 replies; 2+ messages in thread
From: David G. Johnston @ 2018-03-22 15:02 UTC (permalink / raw)
To: yossi.eilaty@gong.io <yossi.eilaty@gong.io>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
On Thursday, March 22, 2018, PG Bug reporting form <noreply@postgresql.org>
wrote:
>
> where, again, the innermost query is wrong (there's no x in a).
>
This is a correlated subquery working as designed.
David J.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2018-03-22 15:02 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-03-22 14:25 BUG #15128: Erroneous inner query is executing with wrong results PG Bug reporting form <noreply@postgresql.org>
2018-03-22 15:02 ` David G. Johnston <david.g.johnston@gmail.com>
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