Thread: Bug #470: INTERSECT fails

Bug #470: INTERSECT fails

From
pgsql-bugs@postgresql.org
Date:
Tamas Vincze (vincze@neb.com) reports a bug with a severity of 1
The lower the number the more severe it is.

Short Description
INTERSECT fails

Long Description
I've used INTERSECT to get the common rows in 3 simple SELECTs.
If I write the query without grouping parentheses, PG reports 0 rows
which is incorrect. If I use parentheses to group the last two
SELECTs then it gives a better answer. If I reorder the SELECTs
then it gives another different answer. (see examples)
The result should be independent of the order and grouping of
the SELECTs, so I think it's a serious bug.
I use version 7.1.2 on solaris/sparc.


Sample Code
sites=# select recseq from frags where len>2222 and len<2406
sites-# intersect select recseq from frags where len>1503 and len<1627
sites-# intersect select recseq from frags where len>752 and len<814;
 recseq
--------
(0 rows)

sites=# select recseq from frags where len>2222 and len<2406
sites-# intersect (select recseq from frags where len>1503 and len<1627
sites(# intersect select recseq from frags where len>752 and len<814);
 recseq
--------
 CACTG
 CAGTG
 CASTG
 RGCGCY
 YAACCT
(5 rows)

sites=# select recseq from frags where len>1503 and len<1627
sites-# intersect select recseq from frags where len>752 and len<814
sites-# intersect select recseq from frags where len>2222 and len<2406;
 recseq
--------
 CACTG
 CAGTG
 RGCGCY
 YAACCT
(4 rows)


No file was uploaded with this report

Re: Bug #470: INTERSECT fails

From
Tom Lane
Date:
pgsql-bugs@postgresql.org writes:
> INTERSECT fails

I believe this is fixed in current sources (7.2-to-be).  The problem
is with INTERSECT (or EXCEPT) as the input to another INTERSECT/EXCEPT.
You could work around it in 7.1 by doing one INTERSECT into a temp
table and then intersecting with that.

            regards, tom lane