Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id A58B3B5DBCB for ; Tue, 9 Aug 2011 02:04:30 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 81104-01 for ; Tue, 9 Aug 2011 05:04:24 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from smtp15.mail.ru (smtp15.mail.ru [94.100.176.133]) by mail.postgresql.org (Postfix) with ESMTP id E043BB5DBF2 for ; Tue, 9 Aug 2011 02:04:23 -0300 (ADT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:In-Reply-To:References:Cc:To:From; bh=gHNUXk5Dp644rgw6tTFhL6q/x0GS1yF8M4HwhfNrBzE=; b=O8EoKdjT4OtxgFt/mCCon7vFsjRIl7Qv+gt7rAMwyoZByuPIWhquSUSlQzJDlZLu8NG+J6ovRPFtMec+gxTApml4LWtxyKn26QqhKuBxlYAPtzSGmpf7isjwx3NXTsqP; Received: from [180.183.160.156] (port=16218 helo=ws) by smtp15.mail.ru with asmtp id 1QqeUH-0007Kt-00; Tue, 09 Aug 2011 09:04:22 +0400 From: "ai" To: "'Tom Lane'" Cc: "'Kevin Grittner'" , 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> <5932.1312865600@sss.pgh.pa.us> In-Reply-To: <5932.1312865600@sss.pgh.pa.us> Subject: Re: BUG #6154: wrong result with nested left-joins Date: Tue, 9 Aug 2011 12:04:15 +0700 Message-ID: <01fb01cc5651$cc6a25b0$653e7110$@mail.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQKtBagl8fgbDVr+0xwL5rgFD0w44gLDzn4lAgnuvfgC5NSmfwHPDG/SAu5N6pwBNq9qAJLlYvSQ Content-Language: ru X-Spam: Not detected X-Mras: Ok X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201108/76 X-Sequence-Number: 30888 Thank you! =) Best Regards, Alex -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us] Sent: Tuesday, August 09, 2011 11:53 AM To: ai Cc: Kevin Grittner; pgsql-bugs@postgresql.org Subject: Re: [BUGS] BUG #6154: wrong result with nested left-joins 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