]> granicus.if.org Git - postgis/commitdiff
Fix for #2956 Thanks strk
authorNicklas Avén <nicklas.aven@jordogskog.no>
Fri, 10 Oct 2014 09:23:26 +0000 (09:23 +0000)
committerNicklas Avén <nicklas.aven@jordogskog.no>
Fri, 10 Oct 2014 09:23:26 +0000 (09:23 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@13054 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_inout.c
regress/tickets.sql
regress/tickets_expected

index fa2904584ad8712c9c2b53e6772f31ce32b379a7..7a0045d9e4ac28005142d7481394278ffaab2766 100644 (file)
@@ -429,7 +429,7 @@ Datum WKBFromLWGEOM(PG_FUNCTION_ARGS)
 PG_FUNCTION_INFO_V1(TWKBFromLWGEOM);
 Datum TWKBFromLWGEOM(PG_FUNCTION_ARGS)
 {
-       GSERIALIZED *geom = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+       GSERIALIZED *geom;
        LWGEOM *lwgeom;
        uint8_t *twkb;
        size_t twkb_size;
@@ -438,6 +438,11 @@ Datum TWKBFromLWGEOM(PG_FUNCTION_ARGS)
        int64_t id;
        int prec;
        
+       /*check for null input since we cannot have the sql-function as strict. 
+       That is because we use null as default for optional ID*/        
+       if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
+               geom = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+       
        /* If user specified precision, respect it */
        if ( (PG_NARGS()>1) && (!PG_ARGISNULL(1)) )
        {
index d869055e9667a6832621e512ef5dd4302787f153..0dab8e3d53c6ffcaeb30edfbaca2615e04774fe4 100644 (file)
@@ -882,5 +882,6 @@ SELECT '#2788', valid, reason, ST_AsText(location) from ST_IsValidDetail('POLYGO
 
 SELECT '#2870', ST_Summary('Point(151.215289 -33.856885)'::geometry::bytea::geography) ;
 
+SELECT '#2956', st_astwkb(null,0) is null;
 -- Clean up
 DELETE FROM spatial_ref_sys;
index 4b3524476fd52d870c43860366d5b75d4b9580aa..514e22e17d666c7a2332a6150adbaf25bb73fca1 100644 (file)
@@ -260,3 +260,4 @@ ERROR:  invalid GML representation
 #2712|LINESTRING EMPTY
 #2788|f|Self-intersection|POINT(1 1)
 #2870|Point[GS]
+#2956|t