Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 38E911F9BE73 for ; Wed, 16 May 2012 11:20:07 -0300 (ADT) Received: from mahout.postgresql.org ([98.129.198.123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SUf5B-0006r3-TS for pgsql-bugs@postgresql.org; Wed, 16 May 2012 14:20:06 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SUf4z-0001h0-GL for pgsql-bugs@postgresql.org; Wed, 16 May 2012 14:19:53 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1SUf4z-0002Yu-1y for pgsql-bugs@postgresql.org; Wed, 16 May 2012 14:19:53 +0000 Date: Wed, 16 May 2012 14:19:53 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #6644: Query give wrong results when 'is not null' is applied in where clause To: pgsql-bugs@postgresql.org From: kwalbrecht@cghtech.com X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201205/101 X-Sequence-Number: 33072 The following bug has been logged on the website: Bug reference: 6644 Logged by: Karl Walbrecht Email address: kwalbrecht@cghtech.com PostgreSQL version: 9.0.3 Operating system: SunOS 5.10 Description: = geom.ArcToStreight(integer) is a function which returns the following type: Composite type "geom.t_line_ref" Column | Type = -----------+------------------- line_id | integer start_id | integer mid_id | integer end_id | integer line | geometry line_type | character varying chart_id | integer The following queries show 1) the total number of rows. 2) the number of null rows. 3) the number of not null rows. The problem is that results of query 2 + the results of query 3 should equal the result of query 1 which they do not. SELECT count(*) FROM ( select geom.ArcToStreight(line_id) as a from sdat_legacy.lines where mid_node is not null ) foo = ; count ------- 14177 (1 row) SELECT count(*) FROM ( select geom.ArcToStreight(line_id) as a from sdat_legacy.lines where mid_node is not null ) foo WHERE foo.a is null = ; count ------- 13796 (1 row) SELECT count(*) FROM ( select geom.ArcToStreight(line_id) as a from sdat_legacy.lines where mid_node is not null ) foo WHERE foo.a is not null = ; count ------- 0 (1 row) Clearly something is amiss. 14197 Total number of rows - 13796 Number of null row -------- 381 Expected number of not null rows 0 Number of not null rows returned