]> granicus.if.org Git - postgis/commitdiff
Revise script generation to exclude SQL functions that are NOT STRICT.
authorRegina Obe <lr@pcorp.us>
Sat, 5 Mar 2016 05:37:31 +0000 (05:37 +0000)
committerRegina Obe <lr@pcorp.us>
Sat, 5 Mar 2016 05:37:31 +0000 (05:37 +0000)
Integrate into testing
Integrate into create extension
References #3490 for PostGIS 2.3

git-svn-id: http://svn.osgeo.org/postgis/trunk@14750 b70326c6-7e19-0410-871a-916f4a2858ee

extensions/postgis/Makefile.in
postgis/Makefile.in
raster/rt_pg/Makefile.in
regress/run_test.pl
utils/postgis_proc_set_search_path.pl

index e7c93c512c565715a56d8cace2e5c586b397f185..53cb09c8d7daa967ea01d5e5a757db926fa317a3 100644 (file)
@@ -37,7 +37,7 @@ ifeq ($(PG91),yes)
        
 all: sql/$(EXTENSION)--$(EXTVERSION).sql sql/$(EXTENSION)--unpackaged--$(EXTVERSION).sql sql/$(EXTENSION)--$(EXTVERSION)--$(EXTVERSION)next.sql sql/$(EXTENSION)--$(EXTVERSION)next--$(EXTVERSION).sql sql_minor_upgrade
 
-sql/$(EXTENSION).sql: sql_bits/postgis.sql sql_bits/postgis_comments.sql sql_bits/rtpostgis.sql sql_bits/spatial_ref_sys_config_dump.sql sql_bits/raster_comments.sql sql_bits/spatial_ref_sys.sql
+sql/$(EXTENSION).sql: sql_bits/postgis.sql sql_bits/postgis_proc_set_search_path.sql sql_bits/postgis_comments.sql sql_bits/rtpostgis.sql sql_bits/rtpostgis_proc_set_search_path.sql sql_bits/spatial_ref_sys_config_dump.sql sql_bits/raster_comments.sql sql_bits/spatial_ref_sys.sql
        mkdir -p sql
        echo '\echo Use "CREATE EXTENSION $(EXTENSION)" to load this file. \quit' > $@
        cat $^ >> $@
@@ -70,6 +70,12 @@ sql_bits/postgis.sql: ../../postgis/postgis.sql
 
 sql_bits/postgis_comments.sql: ../../doc/postgis_comments.sql
        cp $< $@
+       
+sql_bits/postgis_proc_set_search_path.sql: ../../postgis/postgis_proc_set_search_path.sql
+       cp $< $@
+       
+sql_bits/rtpostgis_proc_set_search_path.sql: ../../raster/rt_pg/rtpostgis_proc_set_search_path.sql
+       cp $< $@
 
 #strip BEGIN/COMMIT since these are not allowed in extensions
 sql_bits/rtpostgis.sql: ../../raster/rt_pg/rtpostgis.sql
@@ -78,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_upgrade.sql: ../../raster/rt_pg/rtpostgis_upgrade.sql sql_bits/rtpostgis_proc_set_search_path.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_upgrade.sql: ../../postgis/postgis_upgrade.sql sql_bits/postgis_proc_set_search_path.sql 
        $(PERL) -pe "s/BEGIN\;//g ; s/COMMIT\;//g; s/^(DROP .*)\;/SELECT postgis_extension_drop_if_exists('$(EXTENSION)', '\1');\n\1\;/" $< > $@
 
 
index 603094bc4b16db368ecc68a0a2181b569df8e110..6a176a1e7d80a12d66a9cf491db076d0bc865a2a 100644 (file)
@@ -27,7 +27,7 @@ MODULE_big=postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@
 MODULEDIR=contrib/$(MODULE_big)
 
 # Files to be copied to the contrib/ directory
-SQL_built=postgis.sql uninstall_postgis.sql postgis_upgrade.sql  legacy.sql uninstall_legacy.sql legacy_minimal.sql legacy_gist.sql 
+SQL_built=postgis.sql uninstall_postgis.sql postgis_upgrade.sql postgis_proc_set_search_path.sql legacy.sql uninstall_legacy.sql legacy_minimal.sql legacy_gist.sql 
 DATA=../spatial_ref_sys.sql
 
 # SQL objects (files requiring pre-processing)
@@ -173,6 +173,9 @@ $(PG_OBJS): ../liblwgeom/.libs/liblwgeom.a ../libpgcommon/libpgcommon.a ../postg
 
 postgis_upgrade.sql.in: postgis.sql ../utils/postgis_proc_upgrade.pl
        $(PERL) ../utils/postgis_proc_upgrade.pl $< UNUSED > $@
+       
+postgis_proc_set_search_path.sql: postgis.sql ../utils/postgis_proc_set_search_path.pl
+       $(PERL) ../utils/postgis_proc_set_search_path.pl $< UNUSED > $@
 
 postgis_upgrade.sql: postgis_drop_before.sql postgis_upgrade.sql.in postgis_drop_after.sql
        echo "BEGIN;" > $@
index ce08dd4d10054a10501fcda5b1ba0acfb8cada5a..9503caa813988b6151c0f44b876376ed3a784c45 100644 (file)
@@ -24,7 +24,7 @@ MODULE_big=rtpostgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@
 MODULEDIR=contrib/postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@
 
 # Files to be copied to the contrib/ directory
-DATA_built=rtpostgis.sql rtpostgis_upgrade.sql uninstall_rtpostgis.sql rtpostgis_legacy.sql
+DATA_built=rtpostgis.sql rtpostgis_upgrade.sql rtpostgis_proc_set_search_path.sql uninstall_rtpostgis.sql rtpostgis_legacy.sql
 DATA=
 
 # SQL preprocessor
@@ -122,6 +122,9 @@ $(SQL_OBJS): ../../postgis/sqldefines.h ../../postgis_svn_revision.h
 
 rtpostgis_upgrade.sql.in: rtpostgis.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 > $@
 
 rtpostgis_upgrade.sql: rtpostgis_upgrade_cleanup.sql rtpostgis_upgrade.sql.in rtpostgis_drop.sql
        echo 'BEGIN;' > $@
index 05435f132377aac40b052fef8e042b7eec290721..2613089c523ca41e0472f07dea29723815f8a99e 100755 (executable)
@@ -1317,6 +1317,7 @@ sub prepare_spatial
        # Load postgis.sql into the database
        load_sql_file("${STAGED_SCRIPTS_DIR}/postgis.sql", 1);
        load_sql_file("${STAGED_SCRIPTS_DIR}/postgis_comments.sql", 0);
+       load_sql_file("${STAGED_SCRIPTS_DIR}/postgis_proc_set_search_path.sql", 0);
        
        if ( $OPT_WITH_TOPO )
        {
@@ -1330,6 +1331,7 @@ sub prepare_spatial
                print "Loading Raster into '${DB}'\n";
                load_sql_file("${STAGED_SCRIPTS_DIR}/rtpostgis.sql", 1);
                load_sql_file("${STAGED_SCRIPTS_DIR}/raster_comments.sql", 0);
+               load_sql_file("${STAGED_SCRIPTS_DIR}/rtpostgis_proc_set_search_path.sql", 0);
        }
 
        if ( $OPT_WITH_SFCGAL )
index 93c27b94d8b0a4a785dd95c91debf13289d103c5..206d3927bb5b1923fcf09636c13b7bfa9a7c6b72 100644 (file)
@@ -98,6 +98,7 @@ while(<INPUT>)
                my $funchead = $1; #contains function header except the end )\r
                my $endhead = 0;\r
                my $endfunchead = $2;\r
+               my $search_path_safe = 0; # we can put a search path on it without disrupting spatial index use\r
                if ($2 eq ')') ## reached end of header\r
                {\r
                        $endhead = 1;\r
@@ -129,8 +130,25 @@ while(<INPUT>)
                #strip off default args from the function header\r
                $funchead =~ s/(default\s+[A-Za-z\.\+\-0-9\'\[\]\:\s]*)//ig;\r
                \r
+               #check to see if function is STRICT or c or plpgsql\r
+               # we can't put search path on non-STRICT sql since search path breaks SQL inlining\r
+               # breaking sql inlining will break use of spatial index\r
+               my $endfunc = 0;\r
+               while(<INPUT>)\r
+               {\r
+                       $endfunc = 1 if /^\s*(\$\$\s*)?LANGUAGE /i;\r
+                       if ( $endfunc == 1 ){\r
+                               $search_path_safe = 1 if /LANGUAGE\s+[\']*(c|plpgsql)/i;\r
+                               $search_path_safe = 1 if /STRICT/i;\r
+                       }\r
+                       last if ( $endfunc && /\;/ );\r
+               }\r
 \r
-               print "EXECUTE 'ALTER FUNCTION $funchead $endfunchead SET search_path=' || quote_ident(param_postgis_schema) || ';';\n";\r
+               \r
+               if ($search_path_safe == 1)\r
+               {\r
+                       print "EXECUTE 'ALTER FUNCTION $funchead $endfunchead SET search_path=' || quote_ident(param_postgis_schema) || ';';\n";\r
+               }\r
        }\r
 \r
 }\r
@@ -139,7 +157,7 @@ close( INPUT );
 \r
 ## End of DO\r
 print 'END;';\r
-print '$$';\r
+print '$$;';\r
 \r
 __END__\r
  \r