subquery results bypassed - Mailing list pgsql-bugs

From pgsql-bugs@postgresql.org
Subject subquery results bypassed
Date
Msg-id 200107310257.f6V2vKr73531@hub.org
Whole thread Raw
Responses Re: subquery results bypassed
Re: subquery results bypassed
List pgsql-bugs
Anthony Wood (woody+postgresqlbugs@switchonline.com.au) reports a bug with a severity of 1
The lower the number the more severe it is.

Short Description
subquery results bypassed

Long Description
The second query in the example code should return:

 a | b | c
---+---+---
(0 rows)

but actually returns

 a | b | c
---+---+---
 1 | 3 | 2
(1 row)


which is wrong, because this tuple is not in the subquery

Sample Code
CREATE TABLE "bug" ("a" TEXT, "b" TEXT, "c" TEXT);
INSERT INTO "bug" VALUES ('1','2','1');
INSERT INTO "bug" VALUES ('1','3','2');
SELECT DISTINCT ON ("a") * FROM "bug" ORDER BY "a","c";
SELECT * FROM (SELECT DISTINCT ON ("a") * FROM "bug" ORDER BY "a","c") bug WHERE "b"='3';
DROP TABLE "bug";


No file was uploaded with this report

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Postmaster will not restart
Next
From: Tom Lane
Date:
Subject: Re: subquery results bypassed