[postgis-tickets] [SCM] PostGIS branch master updated. 3.2.0-621-g8108dd5fd

git at osgeo.org git at osgeo.org
Mon Feb 28 17:17:24 PST 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  8108dd5fd31936f449d958629a5e503003b50b73 (commit)
       via  0b67924d22ec6ef5c095c41660d7cd9788027245 (commit)
      from  e057379151eba06435d46766eaad0bf8351a8971 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8108dd5fd31936f449d958629a5e503003b50b73
Merge: 0b67924d2 e05737915
Author: Regina Obe <lr at pcorp.us>
Date:   Mon Feb 28 20:17:03 2022 -0500

    Merge branch 'master' of git.osgeo.org:postgis/postgis


commit 0b67924d22ec6ef5c095c41660d7cd9788027245
Author: Regina Obe <lr at pcorp.us>
Date:   Mon Feb 28 15:40:17 2022 -0500

    search_path vulnerability during install. References #5069

diff --git a/extensions/postgis/unpackage_raster_if_needed.sql b/extensions/postgis/unpackage_raster_if_needed.sql
index 9d48244f1..bee2a83f9 100644
--- a/extensions/postgis/unpackage_raster_if_needed.sql
+++ b/extensions/postgis/unpackage_raster_if_needed.sql
@@ -1,10 +1,10 @@
 DO $unpackage_if_needed$
 BEGIN
 	IF EXISTS (
-		select t.typname from pg_depend d, pg_extension e, pg_type t where
+		select t.typname from pg_catalog.pg_depend d, pg_catalog.pg_extension e, pg_catalog.pg_type t where
 		e.extname = 'postgis' and d.refclassid =
 		'pg_catalog.pg_extension'::pg_catalog.regclass and d.refobjid = e.oid
-		and d.classid = 'pg_type'::regclass and d.objid = t.oid
+		and d.classid = 'pg_catalog.pg_type'::pg_catalog.regclass and d.objid = t.oid
 		and t.typname = 'raster'
 	) THEN
 
diff --git a/extensions/postgis_extension_helper.sql b/extensions/postgis_extension_helper.sql
index bc1e9f92d..77ef0db74 100644
--- a/extensions/postgis_extension_helper.sql
+++ b/extensions/postgis_extension_helper.sql
@@ -30,38 +30,38 @@ DECLARE
 	var_sql_list text := '';
 	var_pgsql_version integer := current_setting('server_version_num');
 BEGIN
-		var_class := CASE WHEN lower(param_type) = 'function' OR lower(param_type) = 'aggregate' THEN 'pg_proc' ELSE '' END;
-		var_is_aggregate := CASE WHEN lower(param_type) = 'aggregate' THEN true ELSE false END;
+		var_class := CASE WHEN pg_catalog.lower(param_type) = 'function' OR pg_catalog.lower(param_type) = 'aggregate' THEN 'pg_catalog.pg_proc' ELSE '' END;
+		var_is_aggregate := CASE WHEN pg_catalog.lower(param_type) = 'aggregate' THEN true ELSE false END;
 
 		IF var_pgsql_version < 110000 THEN
 			var_sql_list := $sql$SELECT 'ALTER EXTENSION ' || e.extname || ' DROP ' || $3 || ' ' || COALESCE(proc.proname || '(' || oidvectortypes(proc.proargtypes) || ')' ,typ.typname, cd.relname, op.oprname,
 					cs.typname || ' AS ' || ct.typname || ') ', opcname, opfname) || ';' AS remove_command
-			FROM pg_depend As d INNER JOIN pg_extension As e
-				ON d.refobjid = e.oid INNER JOIN pg_class As c ON
+			FROM pg_catalog.pg_depend As d INNER JOIN pg_catalog.pg_extension As e
+				ON d.refobjid = e.oid INNER JOIN pg_catalog.pg_class As c ON
 					c.oid = d.classid
-					LEFT JOIN pg_proc AS proc ON proc.oid = d.objid
-					LEFT JOIN pg_type AS typ ON typ.oid = d.objid
-					LEFT JOIN pg_class As cd ON cd.oid = d.objid
+					LEFT JOIN pg_catalog.pg_proc AS proc ON proc.oid = d.objid
+					LEFT JOIN pg_catalog.pg_type AS typ ON typ.oid = d.objid
+					LEFT JOIN pg_catalog.pg_class As cd ON cd.oid = d.objid
 					LEFT JOIN pg_operator As op ON op.oid = d.objid
-					LEFT JOIN pg_cast AS ca ON ca.oid = d.objid
-					LEFT JOIN pg_type AS cs ON ca.castsource = cs.oid
-					LEFT JOIN pg_type AS ct ON ca.casttarget = ct.oid
+					LEFT JOIN pg_catalog.pg_cast AS ca ON ca.oid = d.objid
+					LEFT JOIN pg_catalog.pg_type AS cs ON ca.castsource = cs.oid
+					LEFT JOIN pg_catalog.pg_type AS ct ON ca.casttarget = ct.oid
 					LEFT JOIN pg_opclass As oc ON oc.oid = d.objid
 					LEFT JOIN pg_opfamily As ofa ON ofa.oid = d.objid
 			WHERE d.deptype = 'e' and e.extname = $1 and c.relname = $2 AND COALESCE(proc.proisagg, false) = $4;$sql$;
 		ELSE -- for PostgreSQL 11 and above, they removed proc.proisagg among others and replaced with some func type thing
 			var_sql_list := $sql$SELECT 'ALTER EXTENSION ' || e.extname || ' DROP ' || $3 || ' ' || COALESCE(proc.proname || '(' || oidvectortypes(proc.proargtypes) || ')' ,typ.typname, cd.relname, op.oprname,
 					cs.typname || ' AS ' || ct.typname || ') ', opcname, opfname) || ';' AS remove_command
-			FROM pg_depend As d INNER JOIN pg_extension As e
-				ON d.refobjid = e.oid INNER JOIN pg_class As c ON
+			FROM pg_catalog.pg_depend As d INNER JOIN pg_catalog.pg_extension As e
+				ON d.refobjid = e.oid INNER JOIN pg_catalog.pg_class As c ON
 					c.oid = d.classid
-					LEFT JOIN pg_proc AS proc ON proc.oid = d.objid
-					LEFT JOIN pg_type AS typ ON typ.oid = d.objid
-					LEFT JOIN pg_class As cd ON cd.oid = d.objid
+					LEFT JOIN pg_catalog.pg_proc AS proc ON proc.oid = d.objid
+					LEFT JOIN pg_catalog.pg_type AS typ ON typ.oid = d.objid
+					LEFT JOIN pg_catalog.pg_class As cd ON cd.oid = d.objid
 					LEFT JOIN pg_operator As op ON op.oid = d.objid
-					LEFT JOIN pg_cast AS ca ON ca.oid = d.objid
-					LEFT JOIN pg_type AS cs ON ca.castsource = cs.oid
-					LEFT JOIN pg_type AS ct ON ca.casttarget = ct.oid
+					LEFT JOIN pg_catalog.pg_cast AS ca ON ca.oid = d.objid
+					LEFT JOIN pg_catalog.pg_type AS cs ON ca.castsource = cs.oid
+					LEFT JOIN pg_catalog.pg_type AS ct ON ca.casttarget = ct.oid
 					LEFT JOIN pg_opclass As oc ON oc.oid = d.objid
 					LEFT JOIN pg_opfamily As ofa ON ofa.oid = d.objid
 			WHERE d.deptype = 'e' and e.extname = $1 and c.relname = $2 AND (proc.prokind = 'a')  = $4;$sql$;
@@ -85,7 +85,7 @@ CREATE OR REPLACE FUNCTION postgis_extension_drop_if_exists(param_extension text
   RETURNS boolean AS
 $$
 DECLARE
-	var_sql_ext text := 'ALTER EXTENSION ' || quote_ident(param_extension) || ' ' || replace(param_statement, 'IF EXISTS', '');
+	var_sql_ext text := 'ALTER EXTENSION ' || pg_catalog.quote_ident(param_extension) || ' ' || replace(param_statement, 'IF EXISTS', '');
 	var_result boolean := false;
 BEGIN
 	BEGIN
@@ -109,13 +109,13 @@ DECLARE
 	var_result text;
 	var_cur_search_path text;
 BEGIN
-	SELECT reset_val INTO var_cur_search_path FROM pg_settings WHERE name = 'search_path';
-	IF var_cur_search_path LIKE '%' || quote_ident(a_schema_name) || '%' THEN
+	SELECT reset_val INTO var_cur_search_path FROM pg_catalog.pg_settings WHERE name = 'search_path';
+	IF var_cur_search_path LIKE '%' || pg_catalog.quote_ident(a_schema_name) || '%' THEN
 		var_result := a_schema_name || ' already in database search_path';
 	ELSE
 		var_cur_search_path := var_cur_search_path || ', '
-                        || quote_ident(a_schema_name);
-		EXECUTE 'ALTER DATABASE ' || quote_ident(current_database())
+                        || pg_catalog.quote_ident(a_schema_name);
+		EXECUTE 'ALTER DATABASE ' || pg_catalog.quote_ident(pg_catalog.current_database())
                               || ' SET search_path = ' || var_cur_search_path;
 		var_result := a_schema_name || ' has been added to end of database search_path ';
 	END IF;
diff --git a/extras/tiger_geocoder/utility/set_search_path.sql b/extras/tiger_geocoder/utility/set_search_path.sql
index c8e8595bb..19d2f9523 100644
--- a/extras/tiger_geocoder/utility/set_search_path.sql
+++ b/extras/tiger_geocoder/utility/set_search_path.sql
@@ -13,9 +13,9 @@ DECLARE
 	var_result text;
 	var_cur_search_path text;
 BEGIN
-	SELECT reset_val INTO var_cur_search_path FROM pg_settings WHERE name = 'search_path';
+	SELECT reset_val INTO var_cur_search_path FROM pg_catalog.pg_settings WHERE name = 'search_path';
 
-	EXECUTE 'SET search_path = ' || quote_ident(a_schema_name) || ', ' || var_cur_search_path;
+	EXECUTE 'SET search_path = ' || pg_catalog.quote_ident(a_schema_name) || ', ' || var_cur_search_path;
 	var_result := a_schema_name || ' has been made primary for install ';
   RETURN var_result;
 END
diff --git a/postgis/geography.sql.in b/postgis/geography.sql.in
index 5b4e904ab..372124147 100644
--- a/postgis/geography.sql.in
+++ b/postgis/geography.sql.in
@@ -162,7 +162,7 @@ CREATE OR REPLACE FUNCTION postgis_typmod_type(integer)
 -- Changed: 2.4.0 Limit to only list things that are tables
 CREATE OR REPLACE VIEW geography_columns AS
 	SELECT
-		current_database() AS f_table_catalog,
+		pg_catalog.current_database() AS f_table_catalog,
 		n.nspname AS f_table_schema,
 		c.relname AS f_table_name,
 		a.attname AS f_geography_column,
diff --git a/postgis/postgis.sql.in b/postgis/postgis.sql.in
index a66f82370..c0a206059 100644
--- a/postgis/postgis.sql.in
+++ b/postgis/postgis.sql.in
@@ -29,15 +29,15 @@ DO $$
 DECLARE
 	pgver text;
 BEGIN
-	SELECT substring(version(), 'PostgreSQL ([0-9\.]+)') INTO pgver;
+	SELECT pg_catalog.substring(pg_catalog.version(), 'PostgreSQL ([0-9\.]+)') INTO pgver;
 
 	IF POSTGIS_PGSQL_VERSION::text != ( SELECT CASE
-		WHEN split_part(s,'.',1)::integer > 9
-			THEN split_part(s,'.',1) || '0'
+		WHEN pg_catalog.split_part(s,'.',1)::integer > 9
+			THEN pg_catalog.split_part(s,'.',1) || '0'
 		ELSE
-			split_part(s,'.', 1) || split_part(s,'.', 2)
+			pg_catalog.split_part(s,'.', 1) || pg_catalog.split_part(s,'.', 2)
 		END
-		FROM substring(version(), 'PostgreSQL ([0-9\.]+)') AS s )
+		FROM pg_catalog.substring(pg_catalog.version(), 'PostgreSQL ([0-9\.]+)') AS s )
 	THEN
 		RAISE EXCEPTION 'PostGIS built for PostgreSQL % cannot be loaded in PostgreSQL %',
 			POSTGIS_PGSQL_HR_VERSION, pgver;
@@ -52,7 +52,7 @@ DECLARE
   rec RECORD;
 BEGIN
   FOR rec IN
-	SELECT n.nspname, p.proname FROM pg_proc p, pg_namespace n
+	SELECT n.nspname, p.proname FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n
 	WHERE p.proname = 'postgis_version'
 	AND p.pronamespace = n.oid
   LOOP
@@ -71,7 +71,7 @@ DECLARE
 BEGIN
 	SHOW pgaudit.log INTO pgalog;
 	RAISE DEBUG 'pgaudit is installed, pgaudit.log is set to ''%''', pgalog;
-	IF lower(pgalog) != 'none'
+	IF pg_catalog.lower(pgalog) != 'none'
 	THEN
 		RAISE EXCEPTION 'PostGIS installation stopped: pgaudit.log is set to ''%''. Set pgaudit.log to ''none'' before installing PostGIS. You may re-enable pgaudit after installation is complete.', pgalog;
 	END IF;
@@ -94,9 +94,9 @@ BEGIN
   -- a WARNING if in a previous version (only up to minor version checked)
   --
 	curver_text := POSTGIS_LIB_VERSION;
-	IF split_part(curver_text,'.',1)::int > split_part(version,'.',1)::int OR
-	   ( split_part(curver_text,'.',1) = split_part(version,'.',1) AND
-		 split_part(curver_text,'.',2) != split_part(version,'.',2) )
+	IF pg_catalog.split_part(curver_text,'.',1)::int > pg_catalog.split_part(version,'.',1)::int OR
+	   ( pg_catalog.split_part(curver_text,'.',1) = pg_catalog.split_part(version,'.',1) AND
+		 pg_catalog.split_part(curver_text,'.',2) != split_part(version,'.',2) )
 	THEN
 	  RAISE WARNING '% signature was deprecated in %. Please use %', oldname, version, newname;
 	ELSE
@@ -545,7 +545,7 @@ CREATE OR REPLACE FUNCTION geometry_gist_sortsupport_2d(internal)
 -- Given a table, column and query geometry, returns the estimate of what proportion
 -- of the table would be returned by a query using the &&/&&& operators. The mode
 -- changes whether the estimate is in x/y only or in all available dimensions.
-CREATE OR REPLACE FUNCTION _postgis_selectivity(tbl regclass, att_name text, geom geometry, mode text default '2')
+CREATE OR REPLACE FUNCTION _postgis_selectivity(tbl pg_catalog.regclass, att_name text, geom geometry, mode text default '2')
 	RETURNS float8
 	AS 'MODULE_PATHNAME', '_postgis_gserialized_sel'
 	LANGUAGE 'c' STRICT PARALLEL SAFE;
@@ -2943,7 +2943,7 @@ CREATE OR REPLACE FUNCTION _postgis_scripts_pgsql_version() RETURNS text
 CREATE OR REPLACE FUNCTION _postgis_pgsql_version() RETURNS text
 AS $$
 	SELECT CASE WHEN split_part(s,'.',1)::integer > 9 THEN split_part(s,'.',1) || '0' ELSE split_part(s,'.', 1) || split_part(s,'.', 2) END AS v
-	FROM substring(version(), 'PostgreSQL ([0-9\.]+)') AS s;
+	FROM pg_catalog.substring(version(), 'PostgreSQL ([0-9\.]+)') AS s;
 $$ LANGUAGE 'sql' STABLE;
 
 -- Availability: 2.5.0
diff --git a/postgis/postgis_after_upgrade.sql b/postgis/postgis_after_upgrade.sql
index 44772dd0e..a2195c1f1 100644
--- a/postgis/postgis_after_upgrade.sql
+++ b/postgis/postgis_after_upgrade.sql
@@ -239,7 +239,7 @@ BEGIN
 IF _postgis_scripts_pgsql_version()::integer >= 96 THEN
 -- mark ST_Union agg as parallel safe if it is not already
         BEGIN
-            UPDATE pg_proc SET proparallel = 's'
+            UPDATE pg_catalog.pg_proc SET proparallel = 's'
             WHERE oid = 'st_union(geometry)'::regprocedure AND proparallel = 'u';
         EXCEPTION WHEN OTHERS THEN
             RAISE DEBUG 'Could not update st_union(geometry): %', SQLERRM;
diff --git a/postgis/postgis_before_upgrade.sql b/postgis/postgis_before_upgrade.sql
index d02bdc42e..f901b22da 100644
--- a/postgis/postgis_before_upgrade.sql
+++ b/postgis/postgis_before_upgrade.sql
@@ -30,8 +30,8 @@
 --         FROM pg_catalog.pg_proc p
 --         LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
 --         WHERE
---                 LOWER(n.nspname) = LOWER('public') AND
---                 LOWER(p.proname) = LOWER('ST_AsGeoJson')
+--                 pg_catalog.LOWER(n.nspname) = pg_catalog.LOWER('public') AND
+--                 pg_catalog.LOWER(p.proname) = pg_catalog.LOWER('ST_AsGeoJson')
 --         ORDER BY 1, 2, 3, 4;
 CREATE OR REPLACE FUNCTION _postgis_drop_function_if_needed(
 	function_name text,
@@ -53,9 +53,9 @@ BEGIN
 	SELECT oid
 	FROM pg_catalog.pg_proc p
 	WHERE pronamespace = postgis_namespace
-	AND LOWER(p.proname) = LOWER(function_name)
+	AND pg_catalog.LOWER(p.proname) = pg_catalog.LOWER(function_name)
 	AND pg_catalog.pg_function_is_visible(p.oid)
-	AND LOWER(pg_catalog.pg_get_function_identity_arguments(p.oid)) ~ LOWER(function_arguments)
+	AND pg_catalog.LOWER(pg_catalog.pg_get_function_identity_arguments(p.oid)) ~ pg_catalog.LOWER(function_arguments)
 	INTO matching_function;
 
 	IF matching_function IS NOT NULL THEN
diff --git a/raster/rt_pg/rtpostgis.sql.in b/raster/rt_pg/rtpostgis.sql.in
index 1be585ddb..02de3390a 100644
--- a/raster/rt_pg/rtpostgis.sql.in
+++ b/raster/rt_pg/rtpostgis.sql.in
@@ -47,7 +47,7 @@ DECLARE
   rec RECORD;
 BEGIN
   FOR rec IN
-    SELECT n.nspname, p.proname FROM pg_proc p, pg_namespace n
+    SELECT n.nspname, p.proname FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n
     WHERE p.proname = 'postgis_raster_lib_version'
     AND p.pronamespace = n.oid
   LOOP
@@ -63,11 +63,11 @@ DECLARE
   nsp TEXT;
 BEGIN
   SELECT n.nspname
-	INTO nsp FROM pg_proc p, pg_namespace n
+	INTO nsp FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n
   WHERE p.proname = 'postgis_lib_version'
   AND p.pronamespace = n.oid;
 
-	IF nsp != current_schema() THEN
+	IF nsp != pg_catalog.current_schema() THEN
     RAISE EXCEPTION
 			'PostGIS Raster must be in the same schema as PostGIS (%)',
 			nsp;
@@ -8715,7 +8715,7 @@ BEGIN
   sql := 'SELECT r.r_table_schema sch, r.r_table_name tab, '
       || 'r.scale_x sfx, r.scale_y sfy, r.blocksize_x tw, '
       || 'r.blocksize_y th, r.extent ext, r.srid FROM @extschema at .raster_columns r, '
-      || 'pg_class c, pg_namespace n WHERE r.r_table_schema = n.nspname '
+      || 'pg_class c, pg_catalog.pg_namespace n WHERE r.r_table_schema = n.nspname '
       || 'AND r.r_table_name = c.relname AND r_raster_column = $2 AND '
       || ' c.relnamespace = n.oid AND c.oid = $1'
   ;
diff --git a/raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in b/raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in
index 0d6f3ba00..cbcae6bcd 100644
--- a/raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in
+++ b/raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in
@@ -94,11 +94,11 @@ BEGIN
 	IF NOT EXISTS (
 			SELECT
 				proname
-			FROM pg_proc f
-			JOIN pg_type r
+			FROM pg_catalog.pg_proc f
+			JOIN pg_catalog.pg_type r
 				ON r.typname = 'raster'
 					AND (f.proargtypes::oid[])[0] = r.oid
-			JOIN pg_type g
+			JOIN pg_catalog.pg_type g
 				ON g.typname = 'geometry'
 					AND (f.proargtypes::oid[])[1] = g.oid
 			WHERE proname = 'raster_contained_by_geometry'
@@ -117,11 +117,11 @@ BEGIN
 	IF NOT EXISTS (
 			SELECT
 				proname
-			FROM pg_proc f
-			JOIN pg_type r
+			FROM pg_catalog.pg_proc f
+			JOIN pg_catalog.pg_type r
 				ON r.typname = 'raster'
 					AND (f.proargtypes::oid[])[1] = r.oid
-			JOIN pg_type g
+			JOIN pg_catalog.pg_type g
 				ON g.typname = 'geometry'
 					AND (f.proargtypes::oid[])[0] = g.oid
 			WHERE proname = 'geometry_contained_by_raster'
@@ -589,7 +589,7 @@ BEGIN
 	FROM pg_proc f
 	JOIN pg_type t
 		ON f.prorettype = t.oid
-	WHERE lower(f.proname) = '_raster_constraint_nodata_values'
+	WHERE pg_catalog.lower(f.proname) = '_raster_constraint_nodata_values'
 		AND f.pronargs = 1
 		AND t.typname = '_float8'; -- array form
 
diff --git a/topology/sql/manage/ManageHelper.sql.in b/topology/sql/manage/ManageHelper.sql.in
index 31b70756b..2acfd9c41 100644
--- a/topology/sql/manage/ManageHelper.sql.in
+++ b/topology/sql/manage/ManageHelper.sql.in
@@ -25,13 +25,13 @@ DECLARE
 	var_result text;
 	var_cur_search_path text;
 BEGIN
-	SELECT reset_val INTO var_cur_search_path FROM pg_settings WHERE name = 'search_path';
-	IF var_cur_search_path LIKE '%' || quote_ident(a_schema_name) || '%' THEN
+	SELECT reset_val INTO var_cur_search_path FROM pg_catalog.pg_settings WHERE name = 'search_path';
+	IF var_cur_search_path LIKE '%' || pg_catalog.quote_ident(a_schema_name) || '%' THEN
 		var_result := a_schema_name || ' already in database search_path';
 	ELSE
 		var_cur_search_path := var_cur_search_path || ', '
-                        || quote_ident(a_schema_name);
-		EXECUTE 'ALTER DATABASE ' || quote_ident(current_database())
+                        || pg_catalog.quote_ident(a_schema_name);
+		EXECUTE 'ALTER DATABASE ' || pg_catalog.quote_ident(pg_catalog.current_database())
                               || ' SET search_path = ' || var_cur_search_path;
 		var_result := a_schema_name || ' has been added to end of database search_path ';
 	END IF;
diff --git a/utils/postgis_proc_upgrade.pl b/utils/postgis_proc_upgrade.pl
index a7fd59061..dff97bc79 100755
--- a/utils/postgis_proc_upgrade.pl
+++ b/utils/postgis_proc_upgrade.pl
@@ -610,22 +610,22 @@ BEGIN
 --    FOR rec IN
 --        SELECT n.nspname AS schemaname,
 --            c.relname AS viewname,
---            pg_get_userbyid(c.relowner) AS viewowner,
---            pg_get_viewdef(c.oid) AS definition,
+--            pg_catalog.pg_get_userbyid(c.relowner) AS viewowner,
+--            pg_catalog.pg_get_viewdef(c.oid) AS definition,
 --            CASE
 --                WHEN 'check_option=cascaded' = ANY (c.reloptions) THEN 'WITH CASCADED CHECK OPTION'
 --                WHEN 'check_option=local' = ANY (c.reloptions) THEN 'WITH LOCAL CHECK OPTION'
 --                ELSE ''
 --            END::text AS check_option
---        FROM pg_class c
---        LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
+--        FROM pg_catalog.pg_class c
+--        LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
 --        WHERE c.relkind = 'v'
---        AND pg_get_viewdef(c.oid) ~ 'deprecated_by_postgis'
+--        AND pg_catalog.pg_get_viewdef(c.oid) ~ 'deprecated_by_postgis'
 --    LOOP
---        sql := format('CREATE OR REPLACE VIEW %I.%I AS %s %s',
+--        sql := pg_catalog.format('CREATE OR REPLACE VIEW %I.%I AS %s %s',
 --            rec.schemaname,
 --            rec.viewname,
---            regexp_replace(rec.definition, '_deprecated_by_postgis_[^(]*', '', 'g'),
+--            pg_catalog.regexp_replace(rec.definition, '_deprecated_by_postgis_[^(]*', '', 'g'),
 --            rec.check_option
 --        );
 --        RAISE NOTICE 'Updating view % to not use deprecated signatures', rec.viewname;
@@ -635,25 +635,25 @@ BEGIN
 --        WHEN OTHERS THEN
 --                GET STACKED DIAGNOSTICS detail := PG_EXCEPTION_DETAIL;
 --                RAISE WARNING 'Could not rewrite view % using deprecated functions', rec.viewname
---                        USING DETAIL = format('%s: %s', SQLERRM, detail);
+--                        USING DETAIL = pg_catalog.format('%s: %s', SQLERRM, detail);
 --        END;
 --    END LOOP;
 
     -- Try to drop all deprecated functions, or rewrite those
     -- who cannot be drop and rewrite them in SQL
 
-    FOR rec IN SELECT unnest(deprecated_functions) as proc
+    FOR rec IN SELECT pg_catalog.unnest(deprecated_functions) as proc
     LOOP --{
 
         RAISE DEBUG 'Handling deprecated function %', rec.proc;
 
-        new_name := regexp_replace(
+        new_name := pg_catalog.regexp_replace(
             rec.proc::text,
             '_deprecated_by_postgis[^(]*\\(.*',
             ''
         );
 
-        sql := format('DROP FUNCTION %s', rec.proc);
+        sql := pg_catalog.format('DROP FUNCTION %s', rec.proc);
         --RAISE DEBUG 'SQL: %', sql;
         BEGIN
             EXECUTE sql;
@@ -662,7 +662,7 @@ BEGIN
             hint = 'Resolve the issue';
             GET STACKED DIAGNOSTICS detail := PG_EXCEPTION_DETAIL;
             IF detail LIKE '%view % depends%' THEN
-                hint = format(
+                hint = pg_catalog.format(
                     'Replace the view changing all occurrences of %s in its definition with %s',
                     rec.proc,
                     new_name
@@ -678,7 +678,7 @@ BEGIN
             -- Try to rewrite the function as an SQL WRAPPER
             -- {
             SELECT pg_get_functiondef(oid) def, pronargs
-            FROM pg_proc WHERE oid = rec.proc
+            FROM pg_catalog.pg_proc WHERE oid = rec.proc
             INTO procrec;
             --
             -- TODO: don't even try if it's an aggregate or windowing
@@ -687,14 +687,14 @@ BEGIN
             --       function (procrec.prokind)
             --
             -- Force LANGUAGE to be SQL
-            sql := regexp_replace(procrec.def, 'LANGUAGE [^ \n]*', 'LANGUAGE sql');
+            sql := pg_catalog.regexp_replace(procrec.def, 'LANGUAGE [^ \n]*', 'LANGUAGE sql');
             --RAISE DEBUG 'SQL (LANGUAGE): %', sql;
             -- Change body to be a wrapper
-            sql := regexp_replace(
+            sql := pg_catalog.regexp_replace(
                 sql,
                 -- Find a stricted match here ?
                 'AS .*',
-                format(
+                pg_catalog.format(
                     -- TODO: have the function raise a warning too ?
                     'AS \$\$ SELECT %s(%s) \$\$',
                     new_name,
@@ -727,16 +727,16 @@ BEGIN
             FOR extrec IN
                 SELECT e.extname
                 FROM
-                    pg_extension e,
-                    pg_depend d
+                    pg_catalog.pg_extension e,
+                    pg_catalog.pg_depend d
                 WHERE
                     d.refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass AND
                     d.refobjid = e.oid AND
-                    d.classid = 'pg_proc'::regclass AND
+                    d.classid = 'pg_catalog.pg_proc'::pg_catalog.regclass AND
                     d.objid = rec.proc::oid
             LOOP
                 RAISE DEBUG 'Unpackaging % from extension %', rec.proc, extrec.extname;
-                sql := format('ALTER EXTENSION %I DROP FUNCTION %s', extrec.extname, rec.proc);
+                sql := pg_catalog.format('ALTER EXTENSION %I DROP FUNCTION %s', extrec.extname, rec.proc);
                 EXECUTE sql;
             END LOOP;
         END;
@@ -783,8 +783,8 @@ BEGIN
         SELECT into old_scripts MODULE_scripts_installed();
     END;
     SELECT into new_scripts 'NEWVERSION';
-    SELECT into old_maj substring(old_scripts from 1 for 1);
-    SELECT into new_maj substring(new_scripts from 1 for 1);
+    SELECT into old_maj pg_catalog.substring(old_scripts, 1, 1);
+    SELECT into new_maj pg_catalog.substring(new_scripts, 1, 1);
 
     -- 2.x to 3.x was upgrade-compatible, see
     -- https://trac.osgeo.org/postgis/ticket/4170#comment:1
@@ -802,18 +802,18 @@ BEGIN
     ) SELECT
       upgraded as scripts_upgraded,
       installed as scripts_installed,
-      substring(upgraded from '([0-9]+)\.')::int * 100 +
-      substring(upgraded from '[0-9]+\.([0-9]+)(\.|$)')::int
+      pg_catalog.substring(upgraded, '([0-9]+)\.')::int * 100 +
+      pg_catalog.substring(upgraded, '[0-9]+\.([0-9]+)(\.|$)')::int
         as version_to_num,
-      substring(installed from '([0-9]+)\.')::int * 100 +
-      substring(installed from '[0-9]+\.([0-9]+)(\.|$)')::int
+      pg_catalog.substring(installed, '([0-9]+)\.')::int * 100 +
+      pg_catalog.substring(installed, '[0-9]+\.([0-9]+)(\.|$)')::int
         as version_from_num,
       installed ~ 'dev|alpha|beta'
         as version_from_isdev
       FROM versions INTO postgis_upgrade_info
     ;
 
-    postgis_upgrade_info_func_code := format($func_code$
+    postgis_upgrade_info_func_code := pg_catalog.format($func_code$
         CREATE FUNCTION _postgis_upgrade_info(OUT scripts_upgraded TEXT,
                                               OUT scripts_installed TEXT,
                                               OUT version_to_num INT,

-----------------------------------------------------------------------

Summary of changes:
 extensions/postgis/unpackage_raster_if_needed.sql |  4 +-
 extensions/postgis_extension_helper.sql           | 46 +++++++++----------
 extras/tiger_geocoder/utility/set_search_path.sql |  4 +-
 postgis/geography.sql.in                          |  2 +-
 postgis/postgis.sql.in                            | 24 +++++-----
 postgis/postgis_after_upgrade.sql                 |  2 +-
 postgis/postgis_before_upgrade.sql                |  8 ++--
 raster/rt_pg/rtpostgis.sql.in                     |  8 ++--
 raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in     | 14 +++---
 topology/sql/manage/ManageHelper.sql.in           |  8 ++--
 utils/postgis_proc_upgrade.pl                     | 54 +++++++++++------------
 11 files changed, 87 insertions(+), 87 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list