From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: ai <listar@mail.ru>
To: 'Tom Lane' <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6154: wrong result with nested left-joins
Date: Mon, 08 Aug 2011 12:31:44 -0500
Message-ID: <4E3FD730020000250003FC3D@gw.wicourts.gov> (raw)
In-Reply-To: <01bc01cc55e0$4592ddf0$d0b899d0$@mail.ru>
References: <201108081313.p78DDX6W021751@wwwmaster.postgresql.org>
<4E3FA39B020000250003FC1F@gw.wicourts.gov>
<25701.1312815692@sss.pgh.pa.us>
<01bc01cc55e0$4592ddf0$d0b899d0$@mail.ru>
"ai" <listar@mail.ru> wrote:
> Oops.. I just saw, that I send you "correct" (already with
"workaround")
> sql-code instead of "wrong"...
> here is "wrong" (difference is in "SELECT sub3.key3, sub4.value2
FROM" ):
OK, that is still happening, and looks wrong to me. The outermost LEFT
JOIN is between this:
test=# SELECT * FROM (SELECT 1 as key1) sub1;
key1
------
1
(1 row)
as sub1 and this:
test=# SELECT sub3.key3, sub4.value2
test-# FROM (SELECT 1 as key3) sub3
test-# LEFT JOIN
test-# (
test(# SELECT sub5.key5, COALESCE(sub6.value1, 1) as
value2
test(# FROM (SELECT 1 as key5) sub5
test(# LEFT JOIN
test(# (
test(# SELECT 1 as key6, value1
test(# FROM (SELECT NULL::integer as value1) sub7
test(# WHERE false
test(# ) sub6 ON false
test(# ) sub4 ON sub4.key5=sub3.key3;
key3 | value2
------+--------
1 | 1
(1 row)
as sub2 joining on sub1.key1 = sub2.key3. Yet:
test=# SELECT *
test-# FROM (SELECT 1 as key1) sub1
test-# LEFT JOIN
test-# (
test(# SELECT sub3.key3, sub4.value2
test(# FROM (SELECT 1 as key3) sub3
test(# LEFT JOIN
test(# (
test(# SELECT sub5.key5, COALESCE(sub6.value1, 1) as
value2
test(# FROM (SELECT 1 as key5) sub5
test(# LEFT JOIN
test(# (
test(# SELECT 1 as key6, value1
test(# FROM (SELECT NULL::integer as value1) sub7
test(# WHERE false
test(# ) sub6 ON false
test(# ) sub4 ON sub4.key5=sub3.key3
test(# ) sub2 ON sub1.key1 = sub2.key3;
key1 | key3 | value2
------+------+--------
1 | 1 |
(1 row)
This is on HEAD from today. Clearly there's a problem.
-Kevin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: Kevin.Grittner@wicourts.gov, listar@mail.ru, tgl@sss.pgh.pa.us
Subject: Re: BUG #6154: wrong result with nested left-joins
In-Reply-To: <4E3FD730020000250003FC3D@gw.wicourts.gov>
References: <201108081313.p78DDX6W021751@wwwmaster.postgresql.org> <4E3FA39B020000250003FC1F@gw.wicourts.gov> <25701.1312815692@sss.pgh.pa.us> <01bc01cc55e0$4592ddf0$d0b899d0$@mail.ru> <4E3FD730020000250003FC3D@gw.wicourts.gov>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox