From f96163265b82d7421f12dbfa2c59dd121ad8164c Mon Sep 17 00:00:00 2001 From: Carla Iriberri Date: Wed, 13 Apr 2016 17:49:38 +0200 Subject: [PATCH] Fix bug for tables without geom or with no potential overviews If the table doesn't have geometries but the createoverviews function is called, the current geometry type checks won't work because "null" will not give a boolean value in the type comparisons. Also, if the createoverviews function is called over a simple table with would not require overviews according to the strategies it is handled correctly. --- scripts-available/CDB_Overviews.sql | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts-available/CDB_Overviews.sql b/scripts-available/CDB_Overviews.sql index f8e2871..807c683 100644 --- a/scripts-available/CDB_Overviews.sql +++ b/scripts-available/CDB_Overviews.sql @@ -226,6 +226,12 @@ AS $$ WHEN internal_error THEN -- Get stats and execute again EXECUTE format('ANALYZE %1$s', reloid); + + -- We check the geometry type in case the error is due to empty geometries + IF _CDB_GeometryTypes(reloid) IS NULL THEN + RETURN NULL; + END IF; + EXECUTE ext_query INTO ext; END; @@ -622,7 +628,7 @@ AS $$ table_name TEXT; BEGIN SELECT _CDB_GeometryTypes(reloid) INTO gtypes; - IF array_upper(gtypes, 1) <> 1 OR gtypes[1] <> 'ST_Point' THEN + IF gtypes IS NULL OR array_upper(gtypes, 1) <> 1 OR gtypes[1] <> 'ST_Point' THEN -- This strategy only supports datasets with point geomety RETURN NULL; RETURN 'x'; @@ -738,6 +744,10 @@ BEGIN -- Determine the referece zoom level EXECUTE 'SELECT ' || quote_ident(refscale_strategy::text) || Format('(''%s'', %s);', reloid, tolerance_px) INTO ref_z; + IF ref_z < 0 OR ref_z IS NULL THEN + RETURN NULL; + END IF; + -- Determine overlay zoom levels -- TODO: should be handled by the refscale_strategy? overview_z := ref_z - 1;