pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #6209: Invalid subquery is accepted within a IN() clause
2+ messages / 2 participants
[nested] [flat]
* BUG #6209: Invalid subquery is accepted within a IN() clause
@ 2011-09-16 09:59 Marc Mamin <marc@intershop.de>
2011-09-16 11:06 ` Re: BUG #6209: Invalid subquery is accepted within a IN() clause Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
0 siblings, 1 reply; 2+ messages in thread
From: Marc Mamin @ 2011-09-16 09:59 UTC (permalink / raw)
To: pgsql-bugs
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;
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #6209: Invalid subquery is accepted within a IN() clause
2011-09-16 09:59 BUG #6209: Invalid subquery is accepted within a IN() clause Marc Mamin <marc@intershop.de>
@ 2011-09-16 11:06 ` Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
0 siblings, 0 replies; 2+ messages in thread
From: Heikki Linnakangas @ 2011-09-16 11:06 UTC (permalink / raw)
To: Marc Mamin <marc@intershop.de>; +Cc: pgsql-bugs
On 16.09.2011 12:59, Marc Mamin wrote:
> 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
> )
It is valid, it just doesn't do what you might expect. The "id" in
"select id from (..." refers to the id field in the outer query.
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2011-09-16 11:06 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-09-16 09:59 BUG #6209: Invalid subquery is accepted within a IN() clause Marc Mamin <marc@intershop.de>
2011-09-16 11:06 ` Heikki Linnakangas <heikki.linnakangas@enterprisedb.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