[postgis-devel] [PostGIS] #544: alias construct fails in SELECT

PostGIS trac at osgeo.org
Tue Jun 15 19:41:38 PDT 2010


#544: alias construct fails in SELECT
-----------------------+----------------------------------------------------
 Reporter:  darkblueb  |       Owner:  pramsey      
     Type:  defect     |      Status:  new          
 Priority:  medium     |   Milestone:  PostGIS 1.5.2
Component:  postgis    |     Version:  1.5.X        
 Keywords:             |  
-----------------------+----------------------------------------------------
 using two queries, with identical constructs other than an alias in the
 SELECT list, the one with the alias gives inconsistent results.. maybe the
 identifier 'area' is being used for something else?

 --- this one works without error
 dbb_grid_hack=# select
 b.ogc_fid,
 st_area( a.wkb_geometry) as area,
 st_area(a.wkb_geometry)/(150*150) as area_perc,
 st_area(b.wkb_geometry) as area_b
 from
 constrained_sum2 a,
 ct_sac_0 b
 where
 (a.id150=b.id150) order by area desc;

 --------------------------------
 -- this one gives wrong results sometimes
 dbb_grid_hack=# select
 b.ogc_fid,
 st_area( a.wkb_geometry) as area,
 area/(150*150) as area_perc,
 st_area(b.wkb_geometry) as area_b
 from
 constrained_sum2 a,
 ct_sac_0 b
 where
 (a.id150=b.id150) order by area desc;


 ==================

  ogc_fid |         area         |      area_perc       | area_b
 ---------+----------------------+----------------------+--------
    21061 |                22500 |     1.11713319443597 |  22500
    36756 |                22500 |                    1 |  22500
    98425 |                22500 |                    1 |  22500
    83585 |                22500 |                    1 |  22500
    98683 |                22500 |     2.21060802547667 |  22500
   101783 |                22500 |     1.21702020789252 |  22500
    83590 |                22500 |                    1 |  22500
    92120 |                22500 |                    1 |  22500
     5870 |                22500 |                    5 |  22500
   110706 |                22500 |     2.88152405025164 |  22500
    19157 |                22500 |     1.83199074812995 |  22500
    17504 |                22500 |                    1 |  22500
   105455 |                22500 |       2.985409233284 |  22500
    28576 |                22500 |     1.10312756123013 |  22500
    41484 |                22500 |                    1 |  22500
    86113 |                22500 |                    1 |  22500
    80264 |                22500 |                    1 |  22500
    97363 |                22500 |     3.07222351900736 |  22500
   112246 |                22500 |                    3 |  22500
   114085 |                22500 |      2.3938812451058 |  22500
   113627 |                22500 |     3.97366612998115 |  22500
    71307 |                22500 |     1.34081633254157 |  22500
    98943 |                22500 |                    2 |  22500

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/544>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list