From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | yossi(dot)eilaty(at)gong(dot)io |
Subject: | BUG #15128: Erroneous inner query is executing with wrong results |
Date: | 2018-03-22 14:25:01 |
Message-ID: | 152172870101.9509.2495966056168831824@wrigleys.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 15128
Logged by: Yossi Eilaty
Email address: yossi(dot)eilaty(at)gong(dot)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).
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-03-22 14:35:02 | Re: BUG #15127: epoch lies 1 hour ahead |
Previous Message | PG Bug reporting form | 2018-03-22 13:22:29 | BUG #15127: epoch lies 1 hour ahead |