[postgis-users] crashing PostgreSQL connections

James Marca jmarca at translab.its.uci.edu
Tue May 3 12:34:38 PDT 2005


Sorry, I deleted the thread already, but there was a message this
morning about crashing postgis/postgresql

The result so far was 

psql -U slash -d crash -c "SELECT GeometryFromText('POINT(-106 40.67)', -1);"
              geometryfromtext              
--------------------------------------------
 01010000000000000000805AC0F6285C8FC2554440
(1 row)


I had a similar crashing problem last week related to typos and
casting, as in

'SRID=32611; POINT(414160.003328498 3726591.60052614)'::geometry

(I think I picked up the ::geometry  idiom  from the docs)

I found out that typos here cause catastrophic failures.

First, note that casting works if typed correctly:

james at emma:~$ psql -U slash -d crash -c "SELECT 'SRID=32611;POINT(414160.003328498 3726591.60052614)'::geometry;"
                      geometry                      
----------------------------------------------------
 0101000020637F0000B88B680340471941620ADECC7F6E4C41
(1 row)

but typos cause more severe errors, as in (double close parens):

james at emma:~$ psql -U slash -d crash -c "SELECT 'SRID=32611;POINT(414160.003328498 3726591.60052614))'::geometry;"
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
connection to server was lost

and LINESTRING with one point, not two

james at emma:~$ psql -U slash -d crash -c "SELECT 'SRID=32611;LINESTRING(414160.003328498 3726591.60052614)'::geometry;"
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
connection to server was lost

Using GeomFromEWKT is much more stable:

james at emma:~$ psql -U slash -d crash -c "SELECT geomfromewkt('SRID=32611;POINT(414160.003328498 3726591.60052614))')"
ERROR:  parse error - invalid geometry

and

james at emma:~$ psql -U slash -d crash -c "SELECT geomfromewkt('SRID=32611;LINESTRING(414160.003328498 3726591.60052614)')"
ERROR:  geometry requires more points

The moral for me was to find and fix all places in my Java where I
cast to ::geometry and instead use GeomFromEWKT().

I have no idea how casting works in postgresql/postGIS.  Is it
supposed to be this fragile, or can it be made to be an alias for
GeomFromText or GeomFromEWKT instead?

James



More information about the postgis-users mailing list