Re: Is there a bug in PostgreSQL ? - Mailing list pgsql-sql

From Richard Huxton
Subject Re: Is there a bug in PostgreSQL ?
Date
Msg-id 49400022.7000803@archonet.com
Whole thread Raw
In response to Is there a bug in PostgreSQL ?  ("Pascal Tufenkji" <ptufenkji@usj.edu.lb>)
Responses Re: Is there a bug in PostgreSQL ?
List pgsql-sql
Pascal Tufenkji wrote:
> 
> SELECT distinct c.emp_id,c.institution,d.* from sip_carriere c left join
> sip_demissionaire d on d.emp_id = c.emp_id where c.emp_id = 342 ;
[snip - rows]
> 
> SELECT distinct c.emp_id,c.institution,d.* from sip_carriere c left join
> sip_demissionaire d on d.emp_id = c.emp_id where c.institution = 1;
[snip - rows]
> 
> BUT IF I PUT BOTH CONDITIONS
> 
>  
> 
> SELECT distinct c.emp_id,c.institution,d.* from sip_carriere c left join
> sip_demissionaire d on d.emp_id = c.emp_id where c.emp_id = 342 and
> c.institution = 1;
[snip - no rows]

> What's the problem ?
> 
> I'm sure that the problem is with the view "sip_demissionaire" cause when I
> copied its content to a temp table, the query returned a result.

> SELECT * into temp foo from sip_demissionaire ;
> 
> SELECT distinct c.emp_id,c.institution,d.* from sip_carriere c left join foo
> d on d.emp_id = c.emp_id where c.emp_id = 342 and c.institution = 1;

Good testing. It looks to me like you have a corrupted index. If you run
EXPLAIN ANALYSE SELECT ... for each of your queries, you'll probably see
that the one that returns no rows is using a particular index that the
other queries aren't.

Have you had any crashes / power failures / disk errors recently?

Oh - and what version of PostgreSQL is this?

--  Richard Huxton Archonet Ltd


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Is there a bug in PostgreSQL ?
Next
From: Bryce Nesbitt
Date:
Subject: Re: Best way to "and" from a one-to-many joined table?