--- /dev/null
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r
+--\r
+--\r
+-- PostGIS - Spatial Types for PostgreSQL\r
+-- http://postgis.net\r
+-- Copyright 2016 Regina Obe\r
+--\r
+-- This is free software; you can redistribute and/or modify it under\r
+-- the terms of the GNU General Public Licence. See the COPYING file.\r
+--\r
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \r
+-- This routine adds search_path to functions known to have issues\r
+-- during restore. Functions that call other postgis functions \r
+-- or spatial_ref_sys should be in here\r
+-- These are functions that are called by restore process for purposes of\r
+-- creating indexes, creating constraints, and creating materialized views\r
+-- Also functions that are used in foreign tables \r
+-- that call other postgis functions. Eventually all functions should be here\r
+-- At that point we decide to add to all functions, \r
+-- this script should be autogenerated\r
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r
+\r
+\r
+\r
+DO language plpgsql\r
+$$\r
+DECLARE param_postgis_schema text;\r
+BEGIN\r
+-- check if PostGIS is already installed\r
+param_postgis_schema = (SELECT n.nspname from pg_extension e join pg_namespace n on e.extnamespace = n.oid WHERE extname = 'postgis');\r
+\r
+-- if in middle install, it will be the current_schema or what was there already\r
+param_postgis_schema = COALESCE(param_postgis_schema, current_schema());\r
+EXECUTE 'set search_path TO ' || quote_ident(param_postgis_schema);\r
+\r
+-- PostGIS geometry funcs\r
+EXECUTE 'ALTER FUNCTION st_transform(geometry, integer) SET search_path=' || quote_ident(param_postgis_schema) || ';';\r
+\r
+-- PostGIS raster funcs\r
+EXECUTE 'ALTER FUNCTION _raster_constraint_pixel_types(raster) SET search_path=' || quote_ident(param_postgis_schema) || ';';\r
+EXECUTE 'ALTER FUNCTION _raster_constraint_info_regular_blocking(name,name,name) SET search_path=' || quote_ident(param_postgis_schema) || ';';\r
+END;\r
+$$
\ No newline at end of file