From: Marc Mamin <marc@intershop.de>
To: pgsql-bugs@postgresql.org
Subject: BUG #6209: Invalid subquery is accepted within a IN() clause
Date: Fri, 16 Sep 2011 09:59:11 GMT
Message-ID: <201109160959.p8G9xBDu036900@wwwmaster.postgresql.org> (raw)
The following bug has been logged online:
Bug reference: 6209
Logged by: Marc Mamin
Email address: marc@intershop.de
PostgreSQL version: 9.1beta3
Operating system: Linux
Description: Invalid subquery is accepted within a IN() clause
Details:
Hello,
This is somehow similar to BUG #6154 but I don't have yet a 9.1. Version to
test and I'm not sure that 9.1 already contains the Fix.
This issue can also be reproduced in 8.3.13
HTH,
Marc Mamin
steps to repeat:
CREATE TABLE test_f_files_steps
(
id bigserial NOT NULL,
file_id integer NOT NULL,
class_id integer NOT NULL,
step_id integer NOT NULL,
"timestamp" bigint NOT NULL,
infotext character varying,
efm_uid integer,
CONSTRAINT test_f_files_steps_pk PRIMARY KEY (id)
);
CREATE TABLE test_f_files_status
(
id serial NOT NULL,
class_id integer NOT NULL,
file_name character varying NOT NULL,
last_step_id integer NOT NULL,
runs smallint,
size bigint,
"timestamp" bigint,
plainday integer,
success boolean,
linecount integer,
rejected integer,
efm_uid integer NOT NULL,
CONSTRAINT test_f_files_status_pk PRIMARY KEY (id, class_id)
);
This is not valid, but is accepted.
EXPLAIN analyze
select * from test_f_files_steps where id in
(select id from
(
select file_id,class_id from test_f_files_steps
EXCEPT
select id,class_id from test_f_files_status
)foo
)
Seq Scan on test_f_files_steps (cost=0.00..26895.75 rows=430 width=64)
(actual time=0.001..0.001 rows=0 loops=1)
Filter: (SubPlan 1)
SubPlan 1
-> Subquery Scan on foo (cost=0.00..62.00 rows=200 width=0) (never
executed)
-> HashSetOp Except (cost=0.00..60.00 rows=200 width=8) (never
executed)
-> Append (cost=0.00..52.00 rows=1600 width=8) (never
executed)
-> Subquery Scan on "*SELECT* 1" (cost=0.00..27.20
rows=860 width=8) (never executed)
-> Seq Scan on test_f_files_steps
(cost=0.00..18.60 rows=860 width=8) (never executed)
-> Subquery Scan on "*SELECT* 2" (cost=0.00..24.80
rows=740 width=8) (never executed)
-> Seq Scan on test_f_files_status
(cost=0.00..17.40 rows=740 width=8) (never executed)
Total runtime: 0.087 ms
calling the IN subquery is correctly rejected:
select id from
(
select file_id,class_id from test_f_files_steps
EXCEPT
select id,class_id from test_f_files_status
)foo
ERROR: column "id" does not exist
drop table test_f_files_steps;
drop table test_f_files_status;
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: marc@intershop.de
Subject: Re: BUG #6209: Invalid subquery is accepted within a IN() clause
In-Reply-To: <201109160959.p8G9xBDu036900@wwwmaster.postgresql.org>
References: <201109160959.p8G9xBDu036900@wwwmaster.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