Skip site navigation (1) Skip section navigation (2)

BUG #6644: Query give wrong results when 'is not null' is applied inwhere clause

From: kwalbrecht(at)cghtech(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6644: Query give wrong results when 'is not null' is applied inwhere clause
Date: 2012-05-16 14:19:53
Message-ID: E1SUf4z-0002Yu-1y@wrigleys.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged on the website:

Bug reference:      6644
Logged by:          Karl Walbrecht
Email address:      kwalbrecht(at)cghtech(dot)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


Responses

pgsql-bugs by date

Next:From: Andrew DunstanDate: 2012-05-16 14:23:07
Subject: Re: 9.2beta1 regression: pg_restore --data-only does not set sequence values any more
Previous:From: Tom LaneDate: 2012-05-16 13:08:26
Subject: Re: 9.2beta1 regression: pg_restore --data-only does not set sequence values any more

Privacy Policy | About PostgreSQL
Copyright © 1996-2013 The PostgreSQL Global Development Group