Re: [SQL] Is there a bug in PostgreSQL ?

2008-12-11 Thread Pascal Tufenkji
Hello again,

 

Actually I'm using PostgreSQL 8.2.4

 

By the way, I tried reindexing the tables but the problem remains 

REINDEX TABLE sip_carriere_dates;

REINDEX TABLE sip_carriere;

 

I also made a pg_dump of the database and then restored it in a test one,
the queries run perfectly well but it gives an error when I add the
condition with the operator is null, for example:

 

dragon_test=# 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 = 2700
;

 emp_id | institution | emp_id | demission_date

+-++

   2700 |  11 ||

   2700 |  52 ||

(2 rows)

 

dragon_test=# 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 = 2700
and d.emp_id is null;

 emp_id | institution | emp_id | demission_date

+-++

(0 rows)

 

Also, when I run the following command to vacuum all the databases :
/usr/local/pgsql/bin/vacuumdb -a -f -z -v -U pascal

All the queries become busted again

 

Weird, isn't it !

 

I'd appreciate any help

Pascal 

 

 

-Original Message-
From: Richard Huxton [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 10, 2008 7:45 PM
To: [EMAIL PROTECTED]
Cc: [email protected]
Subject: Re: [SQL] Is there a bug in PostgreSQL ?

 

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



Re: [SQL] Is there a bug in PostgreSQL ?

2008-12-11 Thread Pascal Tufenkji
I can't, it's an integer column ?!

 

-Original Message-
From: Andreas Kraftl [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 11, 2008 11:47 AM
To: [EMAIL PROTECTED]
Subject: Re: [SQL] Is there a bug in PostgreSQL ?

 

Am Donnerstag, den 11.12.2008, 11:33 +0200 schrieb Pascal Tufenkji:

 

> dragon_test=# 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 = 2700 and d.emp_id is null;

> 

>  emp_id | institution | emp_id | demission_date

> 

> +-++

> 

> (0 rows)

 

What happens, if you try instead of "is null" a =""?

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 = 2700

and d.emp_id = "";

 

Greetings

Andreas

-- 

Kraftl EDV - Dienstleistungen

Linux, Linuxschulungen, Webprogrammierung

Autofabrikstraße 16/6

1230 Wien



Re: [SQL] Is there a bug in PostgreSQL ?

2008-12-11 Thread Tom Lane
"Pascal Tufenkji" <[EMAIL PROTECTED]> writes:
> Actually I'm using PostgreSQL 8.2.4

Well, in that case the answer to $SUBJECT is "Yes".  Please update to
something reasonably current --- at least 8.2.7, which contains the most
recent fix for join planning logic according to a quick scan of the
CVS logs.  (8.2.11 is the most recent release in that branch.)

If you can still reproduce the problem on 8.2.latest then it would be
worth investigating further; but right at the moment I think it's a
good bet that this is the same as one of the already-identified bugs
in outer join planning.

regards, tom lane

-- 
Sent via pgsql-sql mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql