Re: Is there a bug in PostgreSQL ?

From: Richard Huxton <dev(at)archonet(dot)com>
To: ptufenkji(at)usj(dot)edu(dot)lb
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Is there a bug in PostgreSQL ?
Date: 2008-12-10 17:45:06
Message-ID: 49400022.7000803@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Bryce Nesbitt 2008-12-10 18:54:29 Re: Best way to "and" from a one-to-many joined table?
Previous Message Tom Lane 2008-12-10 17:43:33 Re: Is there a bug in PostgreSQL ?