Opened 11 years ago

Closed 11 years ago

#1030 closed defect (fixed)

[raster] ST_SummaryStats on coverage crashes with the sample_percent parameter

Reported by: pracine Owned by: pracine
Priority: high Milestone: PostGIS 2.0.0
Component: raster Version: master
Keywords: Cc:

Description

SELECT * 
FROM st_summarystats('srtm_22_03_tiled_100x100', 'rast', FALSE);

works, but:

SELECT * 
FROM st_summarystats('srtm_22_03_tiled_100x100', 'rast', FALSE, 1.0);

crashes with:

ERROR: rt_raster_from_wkb: wkb size < min size (61)

Change History (4)

comment:1 by Bborie Park, 11 years ago

That is a very odd error. From what I can tell from rt_api.c and rt_pg.c, the only way to call rt_raster_from_wkb is from rt_raster_from_hexwkb, which is only called from RASTER_in through the SQL function raster_in.

So, I think there is something wrong in your setup.

Also, the second example shouldn't work. The possible variations of ST_SummaryStats for coverages are:

  1. ST_SummaryStats(rastertable text, rastercolumn text, nband integer DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 1)
  1. ST_SummaryStats(rastertable text, rastercolumn text, exclude_nodata_value boolean)

comment:2 by Bborie Park, 11 years ago

Now this gets very strange. It appears that PostgreSQL is passing your second example

SELECT * 
FROM st_summarystats('srtm_22_03_tiled_100x100', 'rast', FALSE, 1.0);

to the function

ST_SummaryStats(rast raster, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 1)

I tested this by deleting all ST_SummaryStats functions and adding them back one at a time. If you explicitly cast the first parameter of your example, you get the appropriate message "No function matches the given name and argument types. You might need to add explicit type casts.".

SELECT * 
FROM st_summarystats('srtm_22_03_tiled_100x100'::text, 'rast', FALSE, 1.0);

It appears that PostgreSQL is interpreting 'srtm_22_03_tiled_100x100' as a raster type and 'rast' as an integer. I don't know what I can do about the function parameter type conversion.

http://www.postgresql.org/docs/8.4/static/typeconv-func.html

Besides, no function exists for your second example. Granted, we could modify one function declaration to add a parameter for the sample_percent. If we don't modify that one declaration though, it would be best to consider this ticket as a "won't fix".

comment:3 by Bborie Park, 11 years ago

I've refactored the set of ST_SummaryStats functions in r7410. Your second example should fail as no ST_SummaryStats function should have a sample_percent parameter. Only ST_ApproxSummaryStats functions have the sample_percent parameter.

comment:4 by Bborie Park, 11 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.