[postgis-tickets] [PostGIS] #4770: [raster] Calling st_union() with WINDOW PARTITION crashes server

PostGIS trac at osgeo.org
Thu Aug 19 14:30:57 PDT 2021


#4770: [raster] Calling st_union() with WINDOW PARTITION crashes server
----------------------+---------------------------
  Reporter:  Robins   |      Owner:  robe
      Type:  defect   |     Status:  new
  Priority:  blocker  |  Milestone:  PostGIS 3.0.4
 Component:  raster   |    Version:  3.0.x
Resolution:           |   Keywords:  st_union
----------------------+---------------------------

Comment (by pramsey):

 The problem appears to be the finalfn freeing the aggregate state object.
 When I add a pfree(state) to the (working) st_union(geometry) aggregate, I
 can induce the same crashes. Similarly when I remove the pfree from the
 raster finalfn, the crashes go away.

 The only concern I have about applying the fix over the various known
 cases is that I don't understand the mechanism behind leaving the state
 object intact... Magic Occurs! As far as I can tell, it's the correct
 magic, since the windowed results for the geometry union SEEM correct?
 {{{
 WITH w AS (
   SELECT
     ST_Union(g) OVER (PARTITION BY b ORDER BY a) AS g
   FROM (VALUES ('POINT(0 0)'::geometry, 'A0006', 300), ('POINT(1
 1)'::geometry, 'A0006', 302)) t(g, a, b)
 )
 SELECT ST_AsText(g) FROM w;

  st_astext
 ------------
  POINT(0 0)
  POINT(1 1)
 }}}
 or with the partition wider...
 {{{
 WITH w AS (
   SELECT
     ST_Union(g) OVER (PARTITION BY a ORDER BY b) AS g
   FROM (VALUES ('POINT(0 0)'::geometry, 'A0006', 300), ('POINT(1
 1)'::geometry, 'A0006', 302)) t(g, a, b)
 )
 SELECT ST_AsText(g) FROM w;

       st_astext
 ---------------------
  POINT(0 0)
  MULTIPOINT(0 0,1 1)
 }}}
 I'm hampered by not being 100% sure that the expected windowed results are
 from ST_Union(geometry) with PARTITION BY and ORDER BY are.

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4770#comment:9>
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-tickets mailing list