BUG #4936: Bad result for SQL query - Mailing list pgsql-bugs

From Mathieu Dupuis
Subject BUG #4936: Bad result for SQL query
Date
Msg-id 200907231545.n6NFj1cs051379@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #4936: Bad result for SQL query
List pgsql-bugs
The following bug has been logged online:

Bug reference:      4936
Logged by:          Mathieu Dupuis
Email address:      mdupuis@premieresloges.ca
PostgreSQL version: 8.4.0
Operating system:   Ubuntu
Description:        Bad result for SQL query
Details:

I have found a probleme with a sql query that I run in one of my program.

I have simplified the query as much as I can to figure out what the problem
is. Have have also compere the result with the same data between postgresql
8.4 and postgresql 8.3 and the resultset is different.

Here are the result of the simplest query that recreate the problem, as you
can see the p.id and sod.performance_id are the same because I join on those
fields but if I compare with one, I have a different result that if I
compare the other.

-- 1) Return 1 rows (bad)
select p.performance_datetime, sod.id
from saleorder_details sod, performance p, sale
where p.id in (select 21030434)
  and p.id = sod.performance_id
  and sale.id = sod.sale_id;

-- 2) Return many rows (good)
select p.performance_datetime, sod.id
from saleorder_details sod, performance p, sale
where p.id in (21030434)
  and p.id = sod.performance_id
  and sale.id = sod.sale_id;

-- 3) Return many rows (good)
select p.performance_datetime, sod.id
from saleorder_details sod, performance p, sale
where sod.performance_id in (select 21030434)
  and p.id = sod.performance_id
  and sale.id = sod.sale_id;

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #4935: Weird input syntax for intervals, part 2
Next
From: Tom Lane
Date:
Subject: Re: BUG #4936: Bad result for SQL query