Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 13CACB5DD30 for ; Tue, 28 Jun 2011 11:41:46 -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 31925-05-5 for ; Tue, 28 Jun 2011 14:41:45 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id 2D58AB5DC31 for ; Tue, 28 Jun 2011 11:41:30 -0300 (ADT) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p5SEfUoW051447 for ; Tue, 28 Jun 2011 14:41:30 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p5SEfU5x051446; Tue, 28 Jun 2011 14:41:30 GMT (envelope-from www) Date: Tue, 28 Jun 2011 14:41:30 GMT Message-Id: <201106281441.p5SEfU5x051446@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6079: Wrong select result From: "Renat" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201106/208 X-Sequence-Number: 30587 The following bug has been logged online: Bug reference: 6079 Logged by: Renat Email address: renat.nasyrov@itv.ru PostgreSQL version: 9.0.4 Operating system: Windows Description: Wrong select result Details: INPUT: create table foo ( id bigint not null, date_to timestamp without time zone, CONSTRAINT foo_pkey PRIMARY KEY (id) ); CREATE INDEX foo_date_to_index ON foo USING btree (date_to) insert into foo (id, date_to) values (1, now()); insert into foo (id, date_to) values (2, NULL); 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 If we will replace foo_date_to_index to: CREATE INDEX foo_date_to_index ON foo USING btree (date_to) WHERE date_to is NOT NULL Then: SELECT * FROM foo where date_to is null and date_to > '2011-01-01' Return: 0 rows Please explain for me what happens?