Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id A6015B5DBFD for ; Wed, 29 Jun 2011 20:46:00 -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 06340-01 for ; Wed, 29 Jun 2011 23:45:53 +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 68903B5DBDA for ; Wed, 29 Jun 2011 20:45:53 -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 p5TNjkWq017007; Wed, 29 Jun 2011 19:45:47 -0400 (EDT) To: Dean Rasheed cc: Pavel Stehule , Renat , pgsql-bugs@postgresql.org Subject: Re: BUG #6079: Wrong select result In-reply-to: References: <201106281441.p5SEfU5x051446@wwwmaster.postgresql.org> Comments: In-reply-to Dean Rasheed message dated "Tue, 28 Jun 2011 22:45:45 +0100" Date: Wed, 29 Jun 2011 19:45:46 -0400 Message-ID: <17006.1309391146@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.287 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01, URIBL_SBL=1.623 X-Spam-Level: X-Archive-Number: 201106/227 X-Sequence-Number: 30606 Dean Rasheed writes: >> 2011/6/28 Renat : >>> select * from foo where date_to is null and date_to > '2011-01-01' >>> Expected: 0 rows >>> But: it return 1 row with id=2 > The problem seems to be in _bt_preprocess_keys(), which discards the > "a > 10000" predicate in favour of the "a is null" predicate on the > grounds that "null > 10000" in a nulls-last index. > It looks like a previous revision had the right check, based on the > logic that x IS NULL is incompatible with any other predicate. Yeah, seems to be my fault :-(. Will fix. regards, tom lane