Maarten Fokkinga ([EMAIL PROTECTED]) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
Three levels deeply nested SELECT goes wrong

Long Description
A 3 levels deeply nested SELECT with "R(a)" in the top-most FROM part and "R.a=S.a AND 
XXX" in the middle WHERE part may give different results if in a SELECT within XXX the 
term "S.a" is replaced by "R.a".

Since the innermost SELECT lies in the "scope" of the conjunct "R.a=S.a", it should 
not make any difference if "R.a" is used or "S.a".

See the simple example code to reproduce the error.

Version: PostgreSQL 7.0.3 on i686-pc-linux-gnu, compiled by gcc 2.96


Sample Code
create table R(a int);
create table S(a int, b int);
create table T(a int, b int);
insert into R values (1);
insert into R values (2);
insert into S values (2,20);
insert into S values (1,10);
insert into T values (2,20);
insert into T values (1,10);
-- the order of the rows in R, S, T is significant

-- first query:
select a from R where
exists (select b from S where 
        S.a=R.a AND S.b in (select b from T where a=S.a));
-- gives two rows (rows "(1)" and "(2)")

-- second query:
select a from R where
exists (select b from S where 
        S.a=R.a AND S.b in (select b from T where a=R.a));
-- gives one row ("(1)" only)

No file was uploaded with this report


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to