From 46b3201f34592d326da06a7af02452dea10e590f Mon Sep 17 00:00:00 2001 From: Regina Obe Date: Sun, 10 Mar 2019 19:04:28 +0000 Subject: [PATCH] Make _drop_raster_constraint_spatially_unique and _raster_constraint_info_spatially_unique allow for presence or absense of schema qual on geometry cast. Was failing before when installed as extension (but not by script) Reference #4291 for PostGIS 2.4.7 git-svn-id: http://svn.osgeo.org/postgis/branches/2.4@17322 b70326c6-7e19-0410-871a-916f4a2858ee --- raster/rt_pg/rtpostgis.sql.in | 4 ++-- raster/test/regress/check_raster_columns.sql | 9 ++++----- raster/test/regress/check_raster_columns_expected | 8 ++++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/raster/rt_pg/rtpostgis.sql.in b/raster/rt_pg/rtpostgis.sql.in index ae3318184..1d113f96f 100644 --- a/raster/rt_pg/rtpostgis.sql.in +++ b/raster/rt_pg/rtpostgis.sql.in @@ -7296,7 +7296,7 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_spatially_unique(rastschema n AND s.contype = 'x' AND 0::smallint = ANY (s.conkey) AND idx.indexrelid = s.conindid - AND pg_get_indexdef(idx.indexrelid, 1, true) LIKE '(' || quote_ident($3) || '::@extschema@.geometry)' + AND pg_get_indexdef(idx.indexrelid, 1, true) LIKE '(' || quote_ident($3) || '::%geometry)' AND s.conexclop[1] = op.oid AND op.oprname = '='; $$ LANGUAGE sql STABLE STRICT @@ -7344,7 +7344,7 @@ CREATE OR REPLACE FUNCTION _drop_raster_constraint_spatially_unique(rastschema n AND s.contype = 'x' AND 0::smallint = ANY (s.conkey) AND idx.indexrelid = s.conindid - AND pg_get_indexdef(idx.indexrelid, 1, true) LIKE '(' || quote_ident($3) || '::@extschema@.geometry)' + AND pg_get_indexdef(idx.indexrelid, 1, true) LIKE '(' || quote_ident($3) || '::%geometry)' AND s.conexclop[1] = op.oid AND op.oprname = '='; diff --git a/raster/test/regress/check_raster_columns.sql b/raster/test/regress/check_raster_columns.sql index 1092e1f1e..9fbee8973 100644 --- a/raster/test/regress/check_raster_columns.sql +++ b/raster/test/regress/check_raster_columns.sql @@ -62,7 +62,6 @@ CREATE OR REPLACE FUNCTION make_test_raster( rast := ST_MakeEmptyRaster(width, height, ul_x, ul_y, 1, 1, skew_x, skew_y, 0); rast := ST_AddBand(rast, 1, '8BUI', initvalue, nodataval); - INSERT INTO test_raster_columns VALUES (rid, rast); RETURN; @@ -105,7 +104,7 @@ SELECT make_test_raster(4, 3, 3, 3, 3); SELECT AddRasterConstraints(current_schema(), 'test_raster_columns', 'rast'::name); SELECT AddRasterConstraints(current_schema(), 'test_raster_columns', 'rast'::name, 'regular_blocking'); -SELECT r_table_name, r_raster_column, srid, scale_x, scale_y, blocksize_x, blocksize_y, same_alignment, regular_blocking, num_bands, pixel_types, nodata_values, ST_AsEWKT(extent) FROM raster_columns WHERE r_table_name = 'test_raster_columns'; +SELECT '#1', r_table_name, r_raster_column, srid, scale_x, scale_y, blocksize_x, blocksize_y, same_alignment, regular_blocking, num_bands, pixel_types, nodata_values, ST_AsEWKT(extent) FROM raster_columns WHERE r_table_name = 'test_raster_columns'; -- spatially unique, this should fail SELECT make_test_raster(0, 3, 3, 0, 0); @@ -114,7 +113,7 @@ SELECT make_test_raster(0, 3, 3, 0, 0); SELECT make_test_raster(0, 3, 3, 1, 0); SELECT DropRasterConstraints(current_schema(), 'test_raster_columns', 'rast'::name, 'regular_blocking'); -SELECT r_table_name, r_raster_column, srid, scale_x, scale_y, blocksize_x, blocksize_y, same_alignment, regular_blocking, num_bands, pixel_types, nodata_values, ST_AsEWKT(extent) FROM raster_columns WHERE r_table_name = 'test_raster_columns'; +SELECT '#2', r_table_name, r_raster_column, srid, scale_x, scale_y, blocksize_x, blocksize_y, same_alignment, regular_blocking, num_bands, pixel_types, nodata_values, ST_AsEWKT(extent) FROM raster_columns WHERE r_table_name = 'test_raster_columns'; -- check spatial_index SELECT @@ -139,8 +138,8 @@ FROM raster_columns WHERE r_table_name = 'test_raster_columns'; -- ticket #2215 CREATE TABLE test_raster_columns_2 AS SELECT rid, rast FROM test_raster_columns; -SELECT AddRasterConstraints(current_schema(), 'test_raster_columns_2', 'rast'::name); -SELECT AddRasterConstraints(current_schema(), 'test_raster_columns', 'rast'::name, 'regular_blocking'); +SELECT '#2215-1', AddRasterConstraints(current_schema(), 'test_raster_columns_2', 'rast'::name); +SELECT '#2215-2', AddRasterConstraints(current_schema(), 'test_raster_columns', 'rast'::name, 'regular_blocking'); DROP TABLE IF EXISTS test_raster_columns_2; DROP FUNCTION make_test_raster(integer, integer, integer, double precision, double precision, double precision, double precision, double precision, double precision); diff --git a/raster/test/regress/check_raster_columns_expected b/raster/test/regress/check_raster_columns_expected index 659365b6e..20e9f31e3 100644 --- a/raster/test/regress/check_raster_columns_expected +++ b/raster/test/regress/check_raster_columns_expected @@ -14,10 +14,10 @@ test_raster_columns|rast|0|||2|2|t|f|1||{0}|POLYGON((-2 -2,-2 4,4 4,4 -2,-2 -2)) t t t -test_raster_columns|rast|0|1|1|3|3|t|t|1|{8BUI}|{0}|POLYGON((0 0,0 6,6 6,6 0,0 0)) +#1|test_raster_columns|rast|0|1|1|3|3|t|t|1|{8BUI}|{0}|POLYGON((0 0,0 6,6 6,6 0,0 0)) ERROR: conflicting key value violates exclusion constraint "enforce_spatially_unique_test_raster_columns_rast" ERROR: new row for relation "test_raster_columns" violates check constraint "enforce_coverage_tile_rast" t -test_raster_columns|rast|0|1|1|3|3|t|f|1|{8BUI}|{0}|POLYGON((0 0,0 6,6 6,6 0,0 0)) -t -t +#2|test_raster_columns|rast|0|1|1|3|3|t|f|1|{8BUI}|{0}|POLYGON((0 0,0 6,6 6,6 0,0 0)) +#2215-1|t +#2215-2|t -- 2.40.0