[postgis-tickets] r15025 - #3496 patch commit - Make postgis non-relocateable and schema qualify at least core functions
Regina Obe
lr at pcorp.us
Wed Jul 27 14:50:30 PDT 2016
Author: robe
Date: 2016-07-27 14:50:30 -0700 (Wed, 27 Jul 2016)
New Revision: 15025
Modified:
trunk/extensions/postgis/Makefile.in
trunk/extensions/postgis/postgis.control.in
trunk/raster/rt_pg/Makefile.in
trunk/raster/rt_pg/rtpostgis.sql.in
Log:
#3496 patch commit - Make postgis non-relocateable and schema qualify at least core functions
make postgis extension not schema relocateble
revise several raster functions to use schema qualified operators and function calls
revise make scripts to strip out schema qualified for non-extension installed, and keep for extension installed
Modified: trunk/extensions/postgis/Makefile.in
===================================================================
--- trunk/extensions/postgis/Makefile.in 2016-07-25 08:38:22 UTC (rev 15024)
+++ trunk/extensions/postgis/Makefile.in 2016-07-27 21:50:30 UTC (rev 15025)
@@ -46,7 +46,7 @@
mkdir -p sql
cp $< $@
-sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql: ../../postgis/postgis.sql ../../raster/rt_pg/rtpostgis.sql ../../utils/create_unpackaged.pl
+sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql: sql_bits/postgis.sql sql_bits/rtpostgis.sql ../../utils/create_unpackaged.pl
mkdir -p sql
cat ../../postgis/postgis.sql ../../raster/rt_pg/rtpostgis.sql | $(PERL) ../../utils/create_unpackaged.pl postgis > $@
@@ -78,13 +78,13 @@
cp $< $@
#strip BEGIN/COMMIT since these are not allowed in extensions
-sql_bits/rtpostgis.sql: ../../raster/rt_pg/rtpostgis.sql
+sql_bits/rtpostgis.sql: ../../raster/rt_pg/rtpostgis_for_extension.sql
$(PERL) -pe 's/BEGIN\;//g ; s/COMMIT\;//g' $< > $@
sql_bits/spatial_ref_sys_config_dump.sql: ../../spatial_ref_sys.sql ../../utils/create_spatial_ref_sys_config_dump.pl
../../utils/create_spatial_ref_sys_config_dump.pl $< > $@
-sql_bits/rtpostgis_upgrade.sql: ../../raster/rt_pg/rtpostgis_upgrade.sql
+sql_bits/rtpostgis_upgrade.sql: ../../raster/rt_pg/rtpostgis_upgrade_for_extension.sql
$(PERL) -pe "s/BEGIN\;//g ; s/COMMIT\;//g; s/^(DROP .*)\;/SELECT postgis_extension_drop_if_exists('$(EXTENSION)', '\1');\n\1\;/" $< > $@
sql_bits/postgis_upgrade.sql: ../../postgis/postgis_upgrade.sql
Modified: trunk/extensions/postgis/postgis.control.in
===================================================================
--- trunk/extensions/postgis/postgis.control.in 2016-07-25 08:38:22 UTC (rev 15024)
+++ trunk/extensions/postgis/postgis.control.in 2016-07-27 21:50:30 UTC (rev 15025)
@@ -2,4 +2,4 @@
comment = 'PostGIS geometry, geography, and raster spatial types and functions'
default_version = '@POSTGIS_LIB_VERSION@'
module_pathname = '$libdir/postgis- at POSTGIS_MAJOR_VERSION@. at POSTGIS_MINOR_VERSION@'
-relocatable = true
+relocatable = false
Modified: trunk/raster/rt_pg/Makefile.in
===================================================================
--- trunk/raster/rt_pg/Makefile.in 2016-07-25 08:38:22 UTC (rev 15024)
+++ trunk/raster/rt_pg/Makefile.in 2016-07-27 21:50:30 UTC (rev 15025)
@@ -24,7 +24,7 @@
MODULEDIR=contrib/postgis- at POSTGIS_MAJOR_VERSION@. at POSTGIS_MINOR_VERSION@
# Files to be copied to the contrib/ directory
-DATA_built=rtpostgis.sql rtpostgis_upgrade.sql rtpostgis_proc_set_search_path.sql uninstall_rtpostgis.sql rtpostgis_legacy.sql
+DATA_built=rtpostgis.sql rtpostgis_for_extension.sql rtpostgis_upgrade_for_extension.sql rtpostgis_upgrade.sql rtpostgis_proc_set_search_path.sql uninstall_rtpostgis.sql rtpostgis_legacy.sql
DATA=
# SQL preprocessor
@@ -98,11 +98,15 @@
# Borrow the $libdir substitution from PGXS but customise by running the preprocessor
# and adding the version number
+# replace @extschema at . with nothing, this is only used as placeholder for extension install
%.sql: %.sql.in
$(SQLPP) -I../../postgis/ -I../../ $< | grep -v '^#' | \
+ $(PERL) -lpe "s'MODULE_PATHNAME'\$$libdir/rtpostgis- at POSTGIS_MAJOR_VERSION@. at POSTGIS_MINOR_VERSION@'g;s'@extschema@\.''g" > $@
+
+rtpostgis_for_extension.sql: rtpostgis.sql.in
+ $(SQLPP) -I../../postgis/ -I../../ $< | grep -v '^#' | \
$(PERL) -lpe "s'MODULE_PATHNAME'\$$libdir/rtpostgis- at POSTGIS_MAJOR_VERSION@. at POSTGIS_MINOR_VERSION@'g" > $@
-
../../liblwgeom/.libs/liblwgeom.a:
$(MAKE) -C ../../liblwgeom
@@ -120,9 +124,13 @@
# SQL objects deps here
$(SQL_OBJS): ../../postgis/sqldefines.h ../../postgis_svn_revision.h
+#this is redundant but trying to fold in with the other just hangs
rtpostgis_upgrade.sql.in: rtpostgis.sql ../../utils/postgis_proc_upgrade.pl
$(PERL) ../../utils/postgis_proc_upgrade.pl $< UNUSED > $@
+rtpostgis_upgrade_for_extension.sql.in: rtpostgis_for_extension.sql ../../utils/postgis_proc_upgrade.pl
+ $(PERL) ../../utils/postgis_proc_upgrade.pl $< UNUSED > $@
+
rtpostgis_proc_set_search_path.sql: rtpostgis.sql ../../utils/postgis_proc_set_search_path.pl
$(PERL) ../../utils/postgis_proc_set_search_path.pl $< UNUSED > $@
@@ -130,6 +138,12 @@
echo 'BEGIN;' > $@
cat $^ | sed -e 's/^BEGIN;$$//' -e 's/^COMMIT;$$//' >> $@
echo 'COMMIT;' >> $@
+
+#this keeps the @extschema at . in place since extension machinery will replace during install
+rtpostgis_upgrade_for_extension.sql: rtpostgis_upgrade_cleanup.sql rtpostgis_upgrade_for_extension.sql.in rtpostgis_drop.sql
+ echo 'BEGIN;' > $@
+ cat $^ | sed -e 's/^BEGIN;$$//' -e 's/^COMMIT;$$//' >> $@
+ echo 'COMMIT;' >> $@
uninstall_rtpostgis.sql: rtpostgis.sql ../../utils/create_undef.pl
$(PERL) ../../utils/create_undef.pl $< $(POSTGIS_PGSQL_VERSION) > $@
Modified: trunk/raster/rt_pg/rtpostgis.sql.in
===================================================================
--- trunk/raster/rt_pg/rtpostgis.sql.in 2016-07-25 08:38:22 UTC (rev 15024)
+++ trunk/raster/rt_pg/rtpostgis.sql.in 2016-07-27 21:50:30 UTC (rev 15025)
@@ -5728,7 +5728,7 @@
CREATE OR REPLACE FUNCTION raster_overlap(raster, raster)
RETURNS bool
- AS 'select $1::geometry && $2::geometry'
+ AS 'select $1::geometry OPERATOR(@extschema at .&&) $2::geometry'
LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
-- raster/geometry functions
@@ -5748,7 +5748,7 @@
-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION raster_geometry_overlap(raster, geometry)
RETURNS bool
- AS 'select $1::geometry && $2'
+ AS 'select $1::geometry OPERATOR(@extschema at .&&) $2'
LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
-- geometry/raster functions
@@ -5768,7 +5768,7 @@
-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_raster_overlap(geometry, raster)
RETURNS bool
- AS 'select $1 && $2::geometry'
+ AS 'select $1 OPERATOR(@extschema at .&&) $2::geometry'
LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
------------------------------------------------------------------------------
@@ -6110,13 +6110,13 @@
CREATE OR REPLACE FUNCTION st_intersects(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_intersects(st_convexhull($1), st_convexhull($3)) ELSE _st_intersects($1, $2, $3, $4) END $$
+ AS $$ SELECT $1 OPERATOR(@extschema at .&&) $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN @extschema at ._st_intersects(@extschema at .st_convexhull($1), @extschema at .st_convexhull($3)) ELSE @extschema at ._st_intersects($1, $2, $3, $4) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_intersects(rast1 raster, rast2 raster)
RETURNS boolean
- AS $$ SELECT st_intersects($1, NULL::integer, $2, NULL::integer) $$
+ AS $$ SELECT @extschema at .st_intersects($1, NULL::integer, $2, NULL::integer) $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
@@ -6137,7 +6137,7 @@
_geom := ST_ConvexHull(rast);
IF nband IS NOT NULL THEN
- SELECT CASE WHEN bmd.nodatavalue IS NULL THEN FALSE ELSE NULL END INTO hasnodata FROM ST_BandMetaData(rast, nband) AS bmd;
+ SELECT CASE WHEN bmd.nodatavalue IS NULL THEN FALSE ELSE NULL END INTO hasnodata FROM @extschema at .ST_BandMetaData(rast, nband) AS bmd;
END IF;
IF ST_Intersects(geom, _geom) IS NOT TRUE THEN
@@ -6146,8 +6146,8 @@
RETURN TRUE;
END IF;
- SELECT ST_Collect(t.geom) INTO _geom FROM ST_PixelAsPolygons(rast, nband) AS t;
- RETURN ST_Intersects(geom, _geom);
+ SELECT @extschema at .ST_Collect(t.geom) INTO _geom FROM @extschema at .ST_PixelAsPolygons(rast, nband) AS t;
+ RETURN @extschema at .ST_Intersects(geom, _geom);
END;
$$ LANGUAGE 'plpgsql' IMMUTABLE
COST 1000;
@@ -6155,7 +6155,7 @@
-- This function can not be STRICT
CREATE OR REPLACE FUNCTION st_intersects(geom geometry, rast raster, nband integer DEFAULT NULL)
RETURNS boolean AS
- $$ SELECT $1 && $2::geometry AND _st_intersects($1, $2, $3); $$
+ $$ SELECT $1 OPERATOR(@extschema at .&&) $2::geometry AND @extschema at ._st_intersects($1, $2, $3); $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
@@ -6165,13 +6165,13 @@
CREATE OR REPLACE FUNCTION st_intersects(rast raster, geom geometry, nband integer DEFAULT NULL)
RETURNS boolean
- AS $$ SELECT $1::geometry && $2 AND _st_intersects($2, $1, $3) $$
+ AS $$ SELECT $1::geometry OPERATOR(@extschema at .&&) $2 AND @extschema at ._st_intersects($2, $1, $3) $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_intersects(rast raster, nband integer, geom geometry)
RETURNS boolean
- AS $$ SELECT $1::geometry && $3 AND _st_intersects($3, $1, $2) $$
+ AS $$ SELECT $1::geometry OPERATOR(@extschema at .&&) $3 AND @extschema at ._st_intersects($3, $1, $2) $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
@@ -6187,13 +6187,13 @@
CREATE OR REPLACE FUNCTION st_overlaps(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_overlaps(st_convexhull($1), st_convexhull($3)) ELSE _st_overlaps($1, $2, $3, $4) END $$
+ AS $$ SELECT $1 OPERATOR(@extschema at .&&) $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN @extschema at ._st_overlaps(@extschema at .st_convexhull($1), @extschema at .st_convexhull($3)) ELSE _st_overlaps($1, $2, $3, $4) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_overlaps(rast1 raster, rast2 raster)
RETURNS boolean
- AS $$ SELECT st_overlaps($1, NULL::integer, $2, NULL::integer) $$
+ AS $$ SELECT @extschema at .st_overlaps($1, NULL::integer, $2, NULL::integer) $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
@@ -6209,13 +6209,13 @@
CREATE OR REPLACE FUNCTION st_touches(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_touches(st_convexhull($1), st_convexhull($3)) ELSE _st_touches($1, $2, $3, $4) END $$
+ AS $$ SELECT $1 OPERATOR(@extschema at .&&) $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN @extschema at ._st_touches(@extschema at .st_convexhull($1), @extschema at .st_convexhull($3)) ELSE @extschema at ._st_touches($1, $2, $3, $4) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_touches(rast1 raster, rast2 raster)
RETURNS boolean
- AS $$ SELECT st_touches($1, NULL::integer, $2, NULL::integer) $$
+ AS $$ SELECT @extschema at .st_touches($1, NULL::integer, $2, NULL::integer) $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
@@ -6231,13 +6231,13 @@
CREATE OR REPLACE FUNCTION st_contains(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_contains(st_convexhull($1), st_convexhull($3)) ELSE _st_contains($1, $2, $3, $4) END $$
+ AS $$ SELECT $1 OPERATOR(@extschema at .&&) $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN @extschema at ._st_contains(@extschema at .st_convexhull($1), @extschema at .st_convexhull($3)) ELSE @extschema at ._st_contains($1, $2, $3, $4) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_contains(rast1 raster, rast2 raster)
RETURNS boolean
- AS $$ SELECT st_contains($1, NULL::integer, $2, NULL::integer) $$
+ AS $$ SELECT @extschema at .st_contains($1, NULL::integer, $2, NULL::integer) $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
@@ -6253,13 +6253,13 @@
CREATE OR REPLACE FUNCTION st_containsproperly(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_containsproperly(st_convexhull($1), st_convexhull($3)) ELSE _st_containsproperly($1, $2, $3, $4) END $$
+ AS $$ SELECT $1 OPERATOR(@extschema at .&&) $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN @extschema at ._st_containsproperly(@extschema at .st_convexhull($1), @extschema at .st_convexhull($3)) ELSE @extschema at ._st_containsproperly($1, $2, $3, $4) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_containsproperly(rast1 raster, rast2 raster)
RETURNS boolean
- AS $$ SELECT st_containsproperly($1, NULL::integer, $2, NULL::integer) $$
+ AS $$ SELECT @extschema at .st_containsproperly($1, NULL::integer, $2, NULL::integer) $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
@@ -6275,13 +6275,13 @@
CREATE OR REPLACE FUNCTION st_covers(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_covers(st_convexhull($1), st_convexhull($3)) ELSE _st_covers($1, $2, $3, $4) END $$
+ AS $$ SELECT $1 OPERATOR(@extschema at .&&) $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN @extschema at ._st_covers(@extschema at .st_convexhull($1), @extschema at .st_convexhull($3)) ELSE @extschema at ._st_covers($1, $2, $3, $4) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_covers(rast1 raster, rast2 raster)
RETURNS boolean
- AS $$ SELECT st_covers($1, NULL::integer, $2, NULL::integer) $$
+ AS $$ SELECT @extschema at .st_covers($1, NULL::integer, $2, NULL::integer) $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
@@ -6297,13 +6297,13 @@
CREATE OR REPLACE FUNCTION st_coveredby(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_coveredby(st_convexhull($1), st_convexhull($3)) ELSE _st_coveredby($1, $2, $3, $4) END $$
+ AS $$ SELECT $1 OPERATOR(@extschema at .&&) $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN @extschema at ._st_coveredby(@extschema at .st_convexhull($1), @extschema at .st_convexhull($3)) ELSE @extschema at ._st_coveredby($1, $2, $3, $4) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_coveredby(rast1 raster, rast2 raster)
RETURNS boolean
- AS $$ SELECT st_coveredby($1, NULL::integer, $2, NULL::integer) $$
+ AS $$ SELECT @extschema at .st_coveredby($1, NULL::integer, $2, NULL::integer) $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
@@ -6313,19 +6313,19 @@
CREATE OR REPLACE FUNCTION _st_within(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT _st_contains($3, $4, $1, $2) $$
+ AS $$ SELECT @extschema at ._st_contains($3, $4, $1, $2) $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_within(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_within(st_convexhull($1), st_convexhull($3)) ELSE _st_contains($3, $4, $1, $2) END $$
+ AS $$ SELECT $1 OPERATOR(@extschema at .&&) $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN @extschema at ._st_within(@extschema at .st_convexhull($1), @extschema at .st_convexhull($3)) ELSE @extschema at ._st_contains($3, $4, $1, $2) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_within(rast1 raster, rast2 raster)
RETURNS boolean
- AS $$ SELECT st_within($1, NULL::integer, $2, NULL::integer) $$
+ AS $$ SELECT @extschema at .st_within($1, NULL::integer, $2, NULL::integer) $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
@@ -6341,13 +6341,13 @@
CREATE OR REPLACE FUNCTION st_dwithin(rast1 raster, nband1 integer, rast2 raster, nband2 integer, distance double precision)
RETURNS boolean
- AS $$ SELECT $1::geometry && ST_Expand(ST_ConvexHull($3), $5) AND $3::geometry && ST_Expand(ST_ConvexHull($1), $5) AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_dwithin(st_convexhull($1), st_convexhull($3), $5) ELSE _st_dwithin($1, $2, $3, $4, $5) END $$
+ AS $$ SELECT $1::geometry OPERATOR(@extschema at .&&) ST_Expand(ST_ConvexHull($3), $5) AND $3::geometry OPERATOR(@extschema at .&&) ST_Expand(ST_ConvexHull($1), $5) AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_dwithin(st_convexhull($1), st_convexhull($3), $5) ELSE _st_dwithin($1, $2, $3, $4, $5) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
CREATE OR REPLACE FUNCTION st_dwithin(rast1 raster, rast2 raster, distance double precision)
RETURNS boolean
- AS $$ SELECT st_dwithin($1, NULL::integer, $2, NULL::integer, $3) $$
+ AS $$ SELECT @extschema at .st_dwithin($1, NULL::integer, $2, NULL::integer, $3) $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
@@ -6363,7 +6363,7 @@
CREATE OR REPLACE FUNCTION st_dfullywithin(rast1 raster, nband1 integer, rast2 raster, nband2 integer, distance double precision)
RETURNS boolean
- AS $$ SELECT $1::geometry && ST_Expand(ST_ConvexHull($3), $5) AND $3::geometry && ST_Expand(ST_ConvexHull($1), $5) AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_dfullywithin(st_convexhull($1), st_convexhull($3), $5) ELSE _st_dfullywithin($1, $2, $3, $4, $5) END $$
+ AS $$ SELECT $1::geometry OPERATOR(@extschema at .&&) ST_Expand(ST_ConvexHull($3), $5) AND $3::geometry OPERATOR(@extschema at .&&) ST_Expand(ST_ConvexHull($1), $5) AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN _st_dfullywithin(st_convexhull($1), st_convexhull($3), $5) ELSE _st_dfullywithin($1, $2, $3, $4, $5) END $$
LANGUAGE 'sql' IMMUTABLE
COST 1000;
More information about the postgis-tickets
mailing list