[postgis-tickets] r14762 - Cleanup addition of search_path for upgrade scripts
Regina Obe
lr at pcorp.us
Tue Mar 8 11:15:18 PST 2016
Author: robe
Date: 2016-03-08 11:15:17 -0800 (Tue, 08 Mar 2016)
New Revision: 14762
Modified:
trunk/extensions/postgis/Makefile.in
trunk/utils/postgis_proc_set_search_path.pl
Log:
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)
Modified: trunk/extensions/postgis/Makefile.in
===================================================================
--- trunk/extensions/postgis/Makefile.in 2016-03-08 16:05:58 UTC (rev 14761)
+++ trunk/extensions/postgis/Makefile.in 2016-03-08 19:15:17 UTC (rev 14762)
@@ -84,10 +84,10 @@
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 @@
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 $^ >> $@
Modified: trunk/utils/postgis_proc_set_search_path.pl
===================================================================
--- trunk/utils/postgis_proc_set_search_path.pl 2016-03-08 16:05:58 UTC (rev 14761)
+++ trunk/utils/postgis_proc_set_search_path.pl 2016-03-08 19:15:17 UTC (rev 14762)
@@ -95,15 +95,22 @@
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(<INPUT>)
{
$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;
}
More information about the postgis-tickets
mailing list