From: Regina Obe Date: Tue, 8 Mar 2016 19:15:17 +0000 (+0000) Subject: Cleanup addition of search_path for upgrade scripts X-Git-Tag: 2.3.0beta1~179 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f1ba3c51424bf4cd2cee7a72dfa78fa04c7b257f;p=postgis Cleanup addition of search_path for upgrade scripts exclude addgeometry*, addraster*, addoverview* from seach_path function setting. These in calls that don't take schema use the current search_path to find table. References #3495 for 2.3 (trunk) git-svn-id: http://svn.osgeo.org/postgis/trunk@14762 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/extensions/postgis/Makefile.in b/extensions/postgis/Makefile.in index 53cb09c8d..490892f63 100644 --- a/extensions/postgis/Makefile.in +++ b/extensions/postgis/Makefile.in @@ -84,10 +84,10 @@ sql_bits/rtpostgis.sql: ../../raster/rt_pg/rtpostgis.sql 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_proc_set_search_path.sql +sql_bits/rtpostgis_upgrade.sql: ../../raster/rt_pg/rtpostgis_upgrade.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 sql_bits/postgis_proc_set_search_path.sql +sql_bits/postgis_upgrade.sql: ../../postgis/postgis_upgrade.sql $(PERL) -pe "s/BEGIN\;//g ; s/COMMIT\;//g; s/^(DROP .*)\;/SELECT postgis_extension_drop_if_exists('$(EXTENSION)', '\1');\n\1\;/" $< > $@ @@ -98,7 +98,7 @@ sql_bits/raster_comments.sql: ../../doc/raster_comments.sql cp $< $@ #postgis_extension_upgrade_minor.sql is the one that contains both postgis AND raster -sql_bits/postgis_extension_upgrade_minor.sql: ../postgis_extension_helper.sql sql_bits/postgis_upgrade.sql sql_bits/rtpostgis_upgrade.sql ../../doc/raster_comments.sql ../../doc/postgis_comments.sql ../postgis_extension_helper_uninstall.sql +sql_bits/postgis_extension_upgrade_minor.sql: ../postgis_extension_helper.sql sql_bits/postgis_upgrade.sql sql_bits/postgis_proc_set_search_path.sql sql_bits/rtpostgis_upgrade.sql sql_bits/rtpostgis_proc_set_search_path.sql ../../doc/raster_comments.sql ../../doc/postgis_comments.sql ../postgis_extension_helper_uninstall.sql echo '\echo Use "CREATE EXTENSION $(EXTENSION)" to load this file. \quit' > $@ cat $^ >> $@ diff --git a/utils/postgis_proc_set_search_path.pl b/utils/postgis_proc_set_search_path.pl index 206d3927b..d1bcaacd6 100644 --- a/utils/postgis_proc_set_search_path.pl +++ b/utils/postgis_proc_set_search_path.pl @@ -95,15 +95,22 @@ while() if ( /^create or replace function([^\)]+)([\)]{0,1})/i ) { - my $funchead = $1; #contains function header except the end ) + my $funchead = $1; # contains function header except the end ) my $endhead = 0; my $endfunchead = $2; - my $search_path_safe = 0; # we can put a search path on it without disrupting spatial index use + my $search_path_safe = -1; # we can put a search path on it without disrupting spatial index use + if ($2 eq ')') ## reached end of header { $endhead = 1; } + if ( /add(geometry|overview|raster)/i){ + # can't put search_path on addgeometrycolumn or addrasterconstraints + # since table names are sometimes passed in non-qualified + $search_path_safe = 0; + } + #raster folks decided to break their func head in multiple lines # so we need to do this crazy thing if ($endhead != 1) @@ -137,7 +144,7 @@ while() while() { $endfunc = 1 if /^\s*(\$\$\s*)?LANGUAGE /i; - if ( $endfunc == 1 ){ + if ( $endfunc == 1 && $search_path_safe == -1 ){ $search_path_safe = 1 if /LANGUAGE\s+[\']*(c|plpgsql)/i; $search_path_safe = 1 if /STRICT/i; }