]> granicus.if.org Git - postgis/commitdiff
Exclude all c functions from schema qual except ST_Transform we know calls spatial_re...
authorRegina Obe <lr@pcorp.us>
Fri, 11 Mar 2016 01:34:04 +0000 (01:34 +0000)
committerRegina Obe <lr@pcorp.us>
Fri, 11 Mar 2016 01:34:04 +0000 (01:34 +0000)
References #3490 for 2.3 (also added pg_catalog since dumps have it - in theory it gets automatically added, but just in case)

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

utils/postgis_proc_set_search_path.pl

index 9c96373de2ed8ccbaed19e963af01e8b63cc0a4d..8425787b6464e353ceb507560153651dabd47c68 100644 (file)
@@ -112,6 +112,14 @@ while(<INPUT>)
                        $search_path_safe = 0; \r
                }\r
                \r
+               if ( /st_transform/i){\r
+                       # st_transform functions query spatial_ref_sys\r
+                       # so could fail in materialized views and spatial indexes,\r
+                       # though often all done in C\r
+                       $search_path_safe = 1; \r
+               }\r
+\r
+               \r
                #raster folks decided to break their func head in multiple lines \r
                # so we need to do this crazy thing\r
                if ($endhead != 1)\r
@@ -146,8 +154,12 @@ while(<INPUT>)
                {\r
                        $endfunc = 1 if /^\s*(\$\$\s*)?LANGUAGE /i;\r
                        if ( $endfunc == 1 && $search_path_safe == -1 ){\r
-                               $search_path_safe = 1 if /LANGUAGE\s+[\']*(c|plpgsql)/i;\r
+                               $search_path_safe = 1 if /LANGUAGE\s+[\']*(plpgsql)/i;\r
                                $search_path_safe = 1 if /STRICT/i;\r
+                               #exclude C functions unless we've include, \r
+                               # in most cases except ST_Transform\r
+                               # c functions don't call dependent functions or tables\r
+                               $search_path_safe = 0 if /LANGUAGE\s+[\']*(c)/i;\r
                        }\r
                        last if ( $endfunc && /\;/ );\r
                }\r
@@ -155,7 +167,7 @@ while(<INPUT>)
                \r
                if ($search_path_safe == 1)\r
                {\r
-                       print "EXECUTE 'ALTER FUNCTION $funchead $endfunchead SET search_path=' || quote_ident(param_postgis_schema) || ';';\n";\r
+                       print "EXECUTE 'ALTER FUNCTION $funchead $endfunchead SET search_path=' || quote_ident(param_postgis_schema) || ',pg_catalog;';\n";\r
                }\r
        }\r
 \r