dbTalk Databases Forums  

[BUGS] BUG #2251: NOT IN clause is not working correctly

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #2251: NOT IN clause is not working correctly in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Sergei Dubov
 
Posts: n/a

Default [BUGS] BUG #2251: NOT IN clause is not working correctly - 02-10-2006 , 08:03 PM







The following bug has been logged online:

Bug reference: 2251
Logged by: Sergei Dubov
Email address: sdubov (AT) gmail (DOT) com
PostgreSQL version: 8.1.2
Operating system: Windows XP
Description: NOT IN clause is not working correctly
Details:

I have two tables, let's say A and B.

B is a child of a in one to many relationship. A contains records that are
not referenced by B.

I am running a query:

select * from A t1 where t1.id not in (select t2.A_id from B t2);

It returns 0 rows.

Now I run
(select t1.id from A t1) except (select t2.A_id from B t2);

And now Postgres correctly returns records from A that are not referenced by
B.

Thanks a lot for your consideration of this bug.

Serge.

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Reply With Quote
  #2  
Old   
Stephan Szabo
 
Posts: n/a

Default Re: [BUGS] BUG #2251: NOT IN clause is not working correctly - 02-11-2006 , 09:13 AM






On Fri, 10 Feb 2006, Sergei Dubov wrote:

Quote:
I have two tables, let's say A and B.

B is a child of a in one to many relationship. A contains records that are
not referenced by B.

I am running a query:

select * from A t1 where t1.id not in (select t2.A_id from B t2);

It returns 0 rows.

Now I run
(select t1.id from A t1) except (select t2.A_id from B t2);

And now Postgres correctly returns records from A that are not referenced by
B.
This may not be a bug, since these two queries will do different things if
there are any nulls in B.A_id according to spec AFAIK. The short form is
that rvc NOT IN (<subselect returning nulls>) will not return true.

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.