]> granicus.if.org Git - postgis/commitdiff
Fix access to random memory during ANALYZE
authorSandro Santilli <strk@keybit.net>
Tue, 9 Apr 2013 22:43:27 +0000 (22:43 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 9 Apr 2013 22:43:27 +0000 (22:43 +0000)
The bug was introduced with previous commit, see #2269

As part of this fix, the stawidth field of pg_statistics is
changed to represent the average _compressed_ size rather
than the average _uncompressed_ size of non-null geometry
values. This may have some consequence on the planner (not
known at time of commit).

git-svn-id: http://svn.osgeo.org/postgis/trunk@11276 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/geometry_estimate.c

index c61a68ffbd787db58f0eecd491b3559883df7cec..94a5a25936b6d1ca82c4bc3bcf3ccaeacce6b391 100644 (file)
@@ -872,7 +872,6 @@ compute_geometry_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
        for (i=0; i<samplerows; i++)
        {
                Datum datum;
-               GSERIALIZED *geom;
                GBOX box;
 
                datum = fetchfunc(stats, i, &isnull);
@@ -886,6 +885,9 @@ compute_geometry_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
                        continue;
                }
 
+               /** NOTE: we use the toasted width for stawidth */
+               total_width += VARSIZE_ANY(DatumGetPointer(datum));
+
                if ( LW_FAILURE == gserialized_datum_get_gbox_p(datum, &box) )
                {
                        /* Skip empty geometry */
@@ -934,8 +936,6 @@ compute_geometry_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
                                                          box.ymin);
                }
 
-               /** TODO: ask if we need geom or bvol size for stawidth */
-               total_width += VARSIZE(geom);
                total_boxes_area += (box.xmax-box.xmin)*(box.ymax-box.ymin);
 
                /*