]> granicus.if.org Git - postgis/commitdiff
Fix crasher in raster when fed an empty raster (note was tempted to change the def...
authorRegina Obe <lr@pcorp.us>
Wed, 28 Mar 2018 08:37:30 +0000 (08:37 +0000)
committerRegina Obe <lr@pcorp.us>
Wed, 28 Mar 2018 08:37:30 +0000 (08:37 +0000)
References #3055 for PostGIS 2.5 (trunk),
also minor doc fix references #2925 for PostGIS 2.5 (trunk)

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

doc/reference_raster.xml
raster/rt_pg/rtpg_mapalgebra.c
raster/test/regress/tickets.sql
raster/test/regress/tickets_expected

index bc89a431d1ff3f5d513f3c643baaf4ffad2db724..04898c9a87f0305383f27a90221eb677fe628c76 100644 (file)
@@ -1132,7 +1132,7 @@ SELECT short_name, long_name, can_write
 FROM st_gdaldrivers()
 ORDER BY short_name;
 
-   short_name    |                          long_name                          | can_write 
+   short_name    |                          long_name                          | can_write
 -----------------+-------------------------------------------------------------+-----------
  AAIGrid         | Arc/Info ASCII Grid                                         | t
  ACE2            | ACE2                                                        | f
@@ -1845,7 +1845,7 @@ FROM ST_BandMetadata(
                                                  </informalfigure></para>
                 <programlisting>
 -- this will output a black circle taking up 150 x 150 pixels --
-SELECT ST_AsPNG(ST_AsRaster(ST_Buffer(ST_Point(1,5),10),150, 150, '2BUI'));</programlisting>
+SELECT ST_AsPNG(ST_AsRaster(ST_Buffer(ST_Point(1,5),10),150, 150));</programlisting>
 
  <para><informalfigure>
                                                        <mediaobject>
@@ -3795,7 +3795,7 @@ FROM ST_BandMetadata(
        ARRAY[1,3,2]::int[]
 );
 
- bandnum | pixeltype | nodatavalue | isoutdb |                                      path                                      | outdbbandnum 
+ bandnum | pixeltype | nodatavalue | isoutdb |                                      path                                      | outdbbandnum
 ---------+-----------+-------------+---------+--------------------------------------------------------------------------------+--------------
        1 | 8BUI      |             | t       | /home/pele/devel/geo/postgis-git/raster/test/regress/loader/Projected.tif      |            1
        3 | 8BUI      |             | t       | /home/pele/devel/geo/postgis-git/raster/test/regress/loader/Projected.tif      |            3
@@ -7204,7 +7204,7 @@ FROM ST_BandMetadata(
 )
 ORDER BY 1, 2;
 
- query | bandnum | pixeltype | nodatavalue | isoutdb |                                      path                                       | outdbbandnum 
+ query | bandnum | pixeltype | nodatavalue | isoutdb |                                      path                                       | outdbbandnum
 -------+---------+-----------+-------------+---------+---------------------------------------------------------------------------------+--------------
      1 |       1 | 8BUI      |             | t       | /home/pele/devel/geo/postgis-git/raster/test/regress/loader/Projected.tif       |            1
      1 |       2 | 8BUI      |             | t       | /home/pele/devel/geo/postgis-git/raster/test/regress/loader/Projected.tif       |            2
@@ -7295,7 +7295,7 @@ FROM ST_BandMetadata(
 )
 ORDER BY 1, 2;
 
- query | bandnum | pixeltype | nodatavalue | isoutdb |                                      path                                       | outdbbandnum 
+ query | bandnum | pixeltype | nodatavalue | isoutdb |                                      path                                       | outdbbandnum
 -------+---------+-----------+-------------+---------+---------------------------------------------------------------------------------+--------------
      1 |       1 | 8BUI      |             | t       | /home/pele/devel/geo/postgis-git/raster/test/regress/loader/Projected.tif       |            1
      1 |       2 | 8BUI      |             | t       | /home/pele/devel/geo/postgis-git/raster/test/regress/loader/Projected.tif       |            2
@@ -8337,7 +8337,7 @@ SELECT (ST_Metadata(
        )
 )).* AS metadata;
 
- upperleftx | upperlefty | width | height | scalex | scaley | skewx | skewy | srid | numbands 
+ upperleftx | upperlefty | width | height | scalex | scaley | skewx | skewy | srid | numbands
 ------------+------------+-------+--------+--------+--------+-------+-------+------+----------
         0.5 |        0.5 |    10 |     20 |      2 |      3 |     0 |     0 |   10 |        0
                                </programlisting>
@@ -8347,9 +8347,9 @@ SELECT (ST_Metadata(
                        <refsection>
                                <title>See Also</title>
                                <para>
-                                       <xref linkend="RT_ST_MetaData" />, 
-                                       <xref linkend="RT_ST_RastFromHexWKB" />, 
-                                       <xref linkend="RT_ST_AsBinary" />, 
+                                       <xref linkend="RT_ST_MetaData" />,
+                                       <xref linkend="RT_ST_RastFromHexWKB" />,
+                                       <xref linkend="RT_ST_AsBinary" />,
                                        <xref linkend="RT_ST_AsHexWKB" />
                                </para>
                        </refsection>
@@ -8390,7 +8390,7 @@ SELECT (ST_Metadata(
        )
 )).* AS metadata;
 
- upperleftx | upperlefty | width | height | scalex | scaley | skewx | skewy | srid | numbands 
+ upperleftx | upperlefty | width | height | scalex | scaley | skewx | skewy | srid | numbands
 ------------+------------+-------+--------+--------+--------+-------+-------+------+----------
         0.5 |        0.5 |    10 |     20 |      2 |      3 |     0 |     0 |   10 |        0
                                </programlisting>
@@ -8400,9 +8400,9 @@ SELECT (ST_Metadata(
                        <refsection>
                                <title>See Also</title>
                                <para>
-                                       <xref linkend="RT_ST_MetaData" />, 
-                                       <xref linkend="RT_ST_RastFromWKB" />, 
-                                       <xref linkend="RT_ST_AsBinary" />, 
+                                       <xref linkend="RT_ST_MetaData" />,
+                                       <xref linkend="RT_ST_RastFromWKB" />,
+                                       <xref linkend="RT_ST_AsBinary" />,
                                        <xref linkend="RT_ST_AsHexWKB" />
                                </para>
                        </refsection>
@@ -8471,7 +8471,7 @@ SELECT ST_AsBinary(rast) As rastbin FROM dummy_rast WHERE rid=1;
                        <refsection>
                                <title>See Also</title>
                                <para>
-                                       <xref linkend="RT_ST_RastFromWKB" />, 
+                                       <xref linkend="RT_ST_RastFromWKB" />,
                                        <xref linkend="RT_ST_AsHexWKB" />
                                </para>
                        </refsection>
@@ -8515,7 +8515,7 @@ SELECT ST_AsBinary(rast) As rastbin FROM dummy_rast WHERE rid=1;
                                        <programlisting>
 SELECT ST_AsHexWKB(rast) As rastbin FROM dummy_rast WHERE rid=1;
 
-                                                        st_ashexwkb                                                         
+                                                        st_ashexwkb
 ----------------------------------------------------------------------------------------------------------------------------
  010000000000000000000000400000000000000840000000000000E03F000000000000E03F000000000000000000000000000000000A0000000A001400
                                </programlisting>
@@ -8525,7 +8525,7 @@ SELECT ST_AsHexWKB(rast) As rastbin FROM dummy_rast WHERE rid=1;
                        <refsection>
                                <title>See Also</title>
                                <para>
-                                       <xref linkend="RT_ST_RastFromHexWKB" />, 
+                                       <xref linkend="RT_ST_RastFromHexWKB" />,
                                        <xref linkend="RT_ST_AsBinary" />
                                </para>
                        </refsection>
@@ -15578,30 +15578,30 @@ fs.file-max = 6145324
                                        <programlisting>
 $ ps aux | grep postgres
 postgres 31713  0.0  0.4 179012 17564 pts/0    S    Dec26   0:03 /home/dustymugs/devel/postgresql/sandbox/10/usr/local/bin/postgres -D /home/dustymugs/devel/postgresql/sandbox/10/pgdata
-postgres 31716  0.0  0.8 179776 33632 ?        Ss   Dec26   0:01 postgres: checkpointer process   
-postgres 31717  0.0  0.2 179144  9416 ?        Ss   Dec26   0:05 postgres: writer process   
-postgres 31718  0.0  0.2 179012  8708 ?        Ss   Dec26   0:06 postgres: wal writer process   
-postgres 31719  0.0  0.1 179568  7252 ?        Ss   Dec26   0:03 postgres: autovacuum launcher process   
-postgres 31720  0.0  0.1  34228  4124 ?        Ss   Dec26   0:09 postgres: stats collector process   
-postgres 31721  0.0  0.1 179308  6052 ?        Ss   Dec26   0:00 postgres: bgworker: logical replication launcher   
+postgres 31716  0.0  0.8 179776 33632 ?        Ss   Dec26   0:01 postgres: checkpointer process
+postgres 31717  0.0  0.2 179144  9416 ?        Ss   Dec26   0:05 postgres: writer process
+postgres 31718  0.0  0.2 179012  8708 ?        Ss   Dec26   0:06 postgres: wal writer process
+postgres 31719  0.0  0.1 179568  7252 ?        Ss   Dec26   0:03 postgres: autovacuum launcher process
+postgres 31720  0.0  0.1  34228  4124 ?        Ss   Dec26   0:09 postgres: stats collector process
+postgres 31721  0.0  0.1 179308  6052 ?        Ss   Dec26   0:00 postgres: bgworker: logical replication launcher
 
 $ cat /proc/31718/limits
-Limit                     Soft Limit           Hard Limit           Units     
-Max cpu time              unlimited            unlimited            seconds   
-Max file size             unlimited            unlimited            bytes     
-Max data size             unlimited            unlimited            bytes     
-Max stack size            8388608              unlimited            bytes     
-Max core file size        0                    unlimited            bytes     
-Max resident set          unlimited            unlimited            bytes     
-Max processes             15738                15738                processes 
+Limit                     Soft Limit           Hard Limit           Units
+Max cpu time              unlimited            unlimited            seconds
+Max file size             unlimited            unlimited            bytes
+Max data size             unlimited            unlimited            bytes
+Max stack size            8388608              unlimited            bytes
+Max core file size        0                    unlimited            bytes
+Max resident set          unlimited            unlimited            bytes
+Max processes             15738                15738                processes
 <emphasis role="strong">Max open files            1024                 4096                 files</emphasis>
-Max locked memory         65536                65536                bytes     
-Max address space         unlimited            unlimited            bytes     
-Max file locks            unlimited            unlimited            locks     
-Max pending signals       15738                15738                signals   
-Max msgqueue size         819200               819200               bytes     
-Max nice priority         0                    0                    
-Max realtime priority     0                    0                    
+Max locked memory         65536                65536                bytes
+Max address space         unlimited            unlimited            bytes
+Max file locks            unlimited            unlimited            locks
+Max pending signals       15738                15738                signals
+Max msgqueue size         819200               819200               bytes
+Max nice priority         0                    0
+Max realtime priority     0                    0
 Max realtime timeout      unlimited            unlimited            us
                                        </programlisting>
 
index 04cd34839eb9474ab259fab3e07aaa0d4c33f870..bba510567a56272949c8c9ee659a61fa56fb8f0d 100644 (file)
@@ -3022,8 +3022,8 @@ Datum RASTER_clip(PG_FUNCTION_ARGS)
        }
 
        /* raster is empty, return empty raster */
-       if (rt_raster_is_empty(arg->raster)) {
-               elog(NOTICE, "Input raster is empty. Returning empty raster");
+       if (rt_raster_is_empty(arg->raster) || rt_raster_get_num_bands(arg->raster) == 0) {
+               elog(NOTICE, "Input raster is empty or has no bands. Returning empty raster");
 
                rtpg_clip_arg_destroy(arg);
                PG_FREE_IF_COPY(pgraster, 0);
index cba9b72aac0b0a48ed8c70ef489a7920738615d7..4a62cb3b320f2b514c196c2c2e035675a1d1b916 100644 (file)
@@ -112,3 +112,8 @@ DROP TABLE IF EXISTS test_raster_scale_big;
 DROP TABLE IF EXISTS test_raster_scale_small;
 
 SET client_min_messages TO DEFAULT;
+
+/******************************************************************************
+ #3055 ST_Clip() on a raster without band crashes the server
+******************************************************************************/
+SELECT ST_SummaryStats(ST_Clip(ST_MakeEmptyRaster(42, 42, 0, 0, 1.0, 1.0, 0, 0, 4269), ST_MakeEnvelope(0, 0, 20, 20, 4269)));
index f758838d7670dbac131ee0b477018cfee8203bf5..de6373b22e03f438c4be8be96375a906f1118b68 100644 (file)
@@ -12,3 +12,5 @@ ERROR:  new row for relation "test_raster_scale_big" violates check constraint "
 t
 test_raster_scale_small|rast||1
 ERROR:  new row for relation "test_raster_scale_small" violates check constraint "enforce_scaley_rast"
+NOTICE:  Input raster is empty or has no bands. Returning empty raster
+NOTICE:  Invalid band index (must use 1-based). Returning NULL