Re: BUG #3308: Nested outer join gives wrong results - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #3308: Nested outer join gives wrong results
Date
Msg-id 22156.1180128112@sss.pgh.pa.us
Whole thread Raw
In response to BUG #3308: Nested outer join gives wrong results  ("George Sakkis" <george.sakkis@gmail.com>)
List pgsql-bugs
"George Sakkis" <george.sakkis@gmail.com> writes:
> SELECT *
> FROM (
>   SELECT query.id as q_id
>   FROM ranker, run, query
>   WHERE ranker.id = 72 AND
>         run.id = ranker.run_id AND
>         query.set_id = run.set_id
> ) AS t1
> LEFT JOIN (
>   SELECT serp_result.q_id
>   FROM serp_result LEFT OUTER JOIN editor_rating using (q_id,norm_url)
>   WHERE serp_result.ranker_id = 72 AND
>         serp_result.rank <= 1
>         AND editor_rating.grade is null
> ) AS t2 USING (q_id)

This query looks like it's probably affected by the same bug reported a
couple days ago:
http://archives.postgresql.org/pgsql-bugs/2007-05/msg00187.php
and patched here:
http://archives.postgresql.org/pgsql-committers/2007-05/msg00305.php

The "WHERE editor_rating.grade is null" bit prevents the two outer joins
from being re-ordered, but released 8.2.x versions fail to notice that.

            regards, tom lane

pgsql-bugs by date:

Previous
From: "George Sakkis"
Date:
Subject: BUG #3308: Nested outer join gives wrong results
Next
From: "Dmitry Dmitriev"
Date:
Subject: BUG #3309: The limitation for number of connection with ODBC driver