Bug #40874 Buffer function doesn't work with
Submitted: 20 Nov 2008 3:23 Modified: 12 May 2009 10:17
Reporter: Sam Minnee Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: GIS Severity:S3 (Non-critical)
Version:lp:~mysql/mysql-server/mysql-5.1-wl1326 OS:Linux
Assigned to: Alexey Botchkov CPU Architecture:Any
Tags: gis, openGIS extensions

[20 Nov 2008 3:23] Sam Minnee
Description:
The buffer() function has a runaway memory leak when used on a linestring.

How to repeat:
create table test(geom geometrycollection);

insert into test values(geomfromtext('LINESTRING(173.265943716 -41.2915789912,173.265915663 -41.2916039443,173.265718055 -41.2915795579,173.265630666 -41.2919521859,173.265540286 -41.2924042609,173.265406888 -41.2927968576,173.26525724 -41.2932465814,173.26510778 -41.2937410044,173.26503309 -41.2939969098,173.264912863 -41.2943944287,173.264818401 -41.2946478933,173.264580713 -41.2953113459,173.264378634 -41.2958232659,173.264044945 -41.2963528616,173.263560118 -41.2969622459,173.263131147 -41.2975466763,173.262777678 -41.2980763125,173.262065953 -41.2987606867,173.261458579 -41.2991940491,173.260700824 -41.2999008672,173.260724318 -41.2999328449)');

select astext(geom), area(geom),area(buffer(geom,2)) from test;

Warning: this will use up all of your memory and swap if left unchecked!  Keep your finger on the "sudo kill -KILL" command after you run the query.
[20 Nov 2008 6:29] Sveta Smirnova
Thank you for the report.

Please provide definition of function buffer.
[20 Nov 2008 6:37] Sveta Smirnova
Got version information. No comment additionally needed.
[20 Nov 2008 8:03] Sam Minnee
Hi, it sounds like you figured this out already, but the buffer() function is SQL-level function that is part of the openGIS specification, and has been implemented in the GIS-improvements bzr branch lp:~mysql/mysql-server/mysql-5.1-wl1326
[20 Nov 2008 8:04] Sveta Smirnova
Thank you again for the report.

Verified as described.
[21 Nov 2008 0:56] Sam Minnee
I'm not familiar with how development on the OpenGIS branch of MySQL works - are you able to set an expectation for how long before this might be resolved?
[11 Dec 2008 14:45] Reinis Rozitis
Any update/progress on this?
[25 Dec 2008 7:39] Alexey Botchkov
The bug was probably fixed with one of the former patches.
Can't reproduce it now.
[12 May 2009 10:17] Lenz Grimmer
Updating bug status accordingly.
[7 Jul 2009 11:13] Lenz Grimmer
Just verified this with a recent snapshot build of mysql-5.1-wl1326:

mysql> SET @g = 'LINESTRING(
    '> 173.265943716 -41.2915789912,
    '> 173.265915663 -41.2916039443,
    '> 173.265718055 -41.2915795579,
    '> 173.265630666 -41.2919521859,
    '> 173.265540286 -41.2924042609,
    '> 173.265406888 -41.2927968576,
    '> 173.26525724 -41.2932465814,
    '> 173.26510778 -41.2937410044,
    '> 173.26503309 -41.2939969098,
    '> 173.264912863 -41.2943944287,
    '> 173.264818401 -41.2946478933,
    '> 173.264580713 -41.2953113459,
    '> 173.264378634 -41.2958232659,
    '> 173.264044945 -41.2963528616,
    '> 173.263560118 -41.2969622459,
    '> 173.263131147 -41.2975466763,
    '> 173.262777678 -41.2980763125,
    '> 173.262065953 -41.2987606867,
    '> 173.261458579 -41.2991940491,
    '> 173.260700824 -41.2999008672,
    '> 173.260724318 -41.2999328449
    '> )';
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO test VALUES(GeomFromText(@g));
Query OK, 1 row affected (0.00 sec)

mysql> describe test;
+-------+--------------------+------+-----+---------+-------+
| Field | Type               | Null | Key | Default | Extra |
+-------+--------------------+------+-----+---------+-------+
| geom  | geometrycollection | YES  |     | NULL    |       |
+-------+--------------------+------+-----+---------+-------+
1 row in set (0.01 sec)

mysql> select astext(geom), area(geom),area(buffer(geom,2)) from test \G
*************************** 1. row ***************************
        astext(geom): LINESTRING(173.265943716 -41.2915789912,173.265915663 -41.
2916039443,173.265718055 -41.2915795579,173.265630666 -41.2919521859,173.2655402
86 -41.2924042609,173.265406888 -41.2927968576,173.26525724 -41.2932465814,173.2
6510778 -41.2937410044,173.26503309 -41.2939969098,173.264912863 -41.2943944287,
173.264818401 -41.2946478933,173.264580713 -41.2953113459,173.264378634 -41.2958
232659,173.264044945 -41.2963528616,173.263560118 -41.2969622459,173.263131147 -
41.2975466763,173.262777678 -41.2980763125,173.262065953 -41.2987606867,173.2614
58579 -41.2991940491,173.260700824 -41.2999008672,173.260724318 -41.2999328449)
          area(geom): NULL
area(buffer(geom,2)): 12.1908557643275
1 row in set (0.03 sec)

The "area(geom): NULL" looks strange to me, or is it expected?