Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aZJtP-0001DU-Ls for pgsql-sql@arkaria.postgresql.org; Fri, 26 Feb 2016 15:01:19 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aZJtP-0007mi-7b for pgsql-sql@arkaria.postgresql.org; Fri, 26 Feb 2016 15:01:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aZJsR-0006L5-JU for pgsql-sql@postgresql.org; Fri, 26 Feb 2016 15:00:19 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aZJsK-0006Cx-Ix for pgsql-sql@postgresql.org; Fri, 26 Feb 2016 15:00:19 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u1QF05iH032308; Fri, 26 Feb 2016 10:00:05 -0500 From: Tom Lane To: Desmond Coertzen cc: pgsql-sql@postgresql.org Subject: Re: Subselect left join / not exists() In-reply-to: References: Comments: In-reply-to Desmond Coertzen message dated "Fri, 26 Feb 2016 13:17:50 +0200" Date: Fri, 26 Feb 2016 10:00:05 -0500 Message-ID: <32307.1456498805@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Desmond Coertzen writes: > On Postgres 8.4.22. You realize of course that 8.4.x has been out of support for more than a year ... > The first form of the query looked like: > select lots, of, stuff, > (select max(ls2.fiscal_ts)::date > from long_story ls2 > where ls2.contract_id = ls.contract_id and ls2.tr_value > 0 and > sp_tr_is_cash(ls2.primary_key_id) > and not exists(select * from long_story ls2r where ls2r.reverse_of_pk_id = > ls2.primary_key_id) > ) as last_cash_tr_ts > from long_story ls > where ls.create_ts >= current_date and ls.tr_type_id = 4; > The subselect columm "last_cash_tr_ts" produces null or bogus result. You haven't provided nearly enough detail for anyone to judge whether this is actually a bug or just your wrong expectation of what should happen. If you'd like people to look into it, please provide a self-contained test case: not only the query but table definitions and sample data. (Ideally, a SQL script that reproduces the problem starting from an empty database would make it easy for people to test. We're not likely to take the time to try to reverse-engineer context from an incomplete bug report.) If it is a bug, it will not get fixed in 8.4.x anyway, because there will never be any more 8.4.x releases. However, if the bug still exists in newer release branches, we'd definitely endeavor to fix it there. regards, tom lane -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql