Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 2EB43B5DBF1 for ; Tue, 9 Aug 2011 01:53:30 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 45520-03 for ; Tue, 9 Aug 2011 04:53:24 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 32AB1B5DBCB for ; Tue, 9 Aug 2011 01:53:24 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p794rKoC005933; Tue, 9 Aug 2011 00:53:20 -0400 (EDT) To: "ai" cc: "Kevin Grittner" , pgsql-bugs@postgresql.org Subject: Re: BUG #6154: wrong result with nested left-joins In-reply-to: <9240.1312827077@sss.pgh.pa.us> 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> <9240.1312827077@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 08 Aug 2011 14:11:17 -0400" Date: Tue, 09 Aug 2011 00:53:20 -0400 Message-ID: <5932.1312865600@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.712 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.812 X-Spam-Level: X-Archive-Number: 201108/74 X-Sequence-Number: 30886 I wrote: > "Kevin Grittner" writes: >> "ai" 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. > Yeah, I see it too. It seems to be evaluating the placeholder for the > COALESCE expression at the wrong join level. Not sure why, yet. Found it --- the code only fails for the case where the COALESCE subexpression is referenced in the upper targetlist, but not the quals (ie, not ON or WHERE). Patch committed, thanks for the report! regards, tom lane