[postgis-tickets] [SCM] PostGIS branch stable-3.4 updated. 3.4.0-4-gfe22c1177

git at osgeo.org git at osgeo.org
Mon Aug 28 11:45:46 PDT 2023


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, stable-3.4 has been updated
       via  fe22c117751e1de0968ed444ac10df5028f82ecc (commit)
      from  0adf05207b4b1fe13178a90a0f16fe5a473278f8 (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 fe22c117751e1de0968ed444ac10df5028f82ecc
Author: Sandro Santilli <strk at kbt.io>
Date:   Mon Aug 28 11:20:31 2023 +0200

    Fix upgrade with view using st_value(raster,geometry,bool)
    
    Adds support for argument names in Replaces sql comments.
    Includes regression test.
    
    References #5484 in 3.4 branch (3.4.1dev)

diff --git a/NEWS b/NEWS
index dce553251..2d9d4e459 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ To take advantage of all SFCGAL featurs, SFCGAL 1.4.1+ is needed.
 
 * Bug Fixes *
 
+ - #5484, Fix upgrade with view using st_value(raster,geometry,bool)
  - #5479, postgis_full_version() and postgis_gdal_version() sometimes
           warn of deprecated SRID: 2163 (Regina Obe)
 
diff --git a/raster/rt_pg/rtpostgis.sql.in b/raster/rt_pg/rtpostgis.sql.in
index ef0aa82ef..dad551aa3 100644
--- a/raster/rt_pg/rtpostgis.sql.in
+++ b/raster/rt_pg/rtpostgis.sql.in
@@ -5,7 +5,7 @@
 -- http://trac.osgeo.org/postgis/wiki/WKTRaster
 --
 -- Copyright (c) 2015-2017 Regina Obe <lr at pcorp.us>
--- Copyright (c) 2009-2012 Sandro Santilli <strk at kbt.io>
+-- Copyright (c) 2009-2023 Sandro Santilli <strk at kbt.io>
 -- Copyright (c) 2009-2010 Pierre Racine <pierre.racine at sbf.ulaval.ca>
 -- Copyright (c) 2009-2010 Jorge Arevalo <jorge.arevalo at deimos-space.com>
 -- Copyright (c) 2009-2010 Mateusz Loskot <mateusz at loskot.net>
@@ -4622,6 +4622,10 @@ CREATE OR REPLACE FUNCTION st_value(rast raster, x integer, y integer, exclude_n
     AS $$ SELECT st_value($1, 1::integer, $2, $3, $4) $$
     LANGUAGE 'sql' IMMUTABLE STRICT PARALLEL SAFE _COST_MEDIUM;
 
+-- Availability: 2.0.0
+-- Changed: 2.1.0 - renamed the boolean parameter name
+-- Replaces st_value(raster, geometry) deprecated in 2.0.0 (signature existed in WKTRaster)
+-- Replaces st_value(rast raster, pt geometry, hasnodata boolean) deprecated in 2.1.0
 CREATE OR REPLACE FUNCTION st_value(rast raster, pt geometry, exclude_nodata_value boolean DEFAULT TRUE)
     RETURNS float8
     AS $$ SELECT @extschema at .ST_value($1, 1::integer, $2, $3, 'nearest'::text) $$
diff --git a/raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in b/raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in
index cbcae6bcd..95f2e2e6c 100644
--- a/raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in
+++ b/raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in
@@ -7,6 +7,7 @@
 -- Copyright (c) 2011 Regina Obe <lr at pcorp.us>
 -- Copyright (C) 2011 Regents of the University of California
 --   <bkpark at ucdavis.edu>
+-- Copyright (c) 2013-2023 Sandro Santilli <strk at kbt.io>
 --
 -- This program is free software; you can redistribute it and/or
 -- modify it under the terms of the GNU General Public License
@@ -250,12 +251,10 @@ DROP FUNCTION IF EXISTS st_bandpixeltype(raster, integer);
 DROP FUNCTION IF EXISTS st_value(raster, integer, integer, integer);
 DROP FUNCTION IF EXISTS st_value(raster, integer, integer);
 DROP FUNCTION IF EXISTS st_value(raster, integer, geometry);
-DROP FUNCTION IF EXISTS st_value(raster, geometry);
 -- signature changed
 DROP FUNCTION IF EXISTS st_value(raster, integer, integer, integer, boolean);
 DROP FUNCTION IF EXISTS st_value(raster, integer, integer, boolean);
 DROP FUNCTION IF EXISTS st_value(raster, integer, geometry, boolean);
-DROP FUNCTION IF EXISTS st_value(raster, geometry, boolean);
 DROP FUNCTION IF EXISTS st_value(raster, integer, geometry, double precision);
 DROP FUNCTION IF EXISTS st_value(raster, geometry, double precision);
 
diff --git a/raster/test/regress/hooks/hook-after-upgrade-raster.sql b/raster/test/regress/hooks/hook-after-upgrade-raster.sql
index b220246ea..fffb6f7f0 100644
--- a/raster/test/regress/hooks/hook-after-upgrade-raster.sql
+++ b/raster/test/regress/hooks/hook-after-upgrade-raster.sql
@@ -1,2 +1,6 @@
+DROP VIEW upgrade_test_raster_view_st_value;
 DROP TABLE upgrade_test_raster;
 DROP TABLE upgrade_test_raster_with_regular_blocking;
+
+-- Drop functions deprecated on upgrade
+DROP FUNCTION IF EXISTS st_value_deprecated_by_postgis_201(raster,geometry,boolean);
diff --git a/raster/test/regress/hooks/hook-before-upgrade-raster.sql b/raster/test/regress/hooks/hook-before-upgrade-raster.sql
index 94d972fc3..c2e42c97f 100644
--- a/raster/test/regress/hooks/hook-before-upgrade-raster.sql
+++ b/raster/test/regress/hooks/hook-before-upgrade-raster.sql
@@ -31,3 +31,10 @@ INSERT INTO upgrade_test_raster_with_regular_blocking(r) VALUES
 
 --SET client_min_messages TO ERROR;
 SELECT AddRasterConstraints('upgrade_test_raster_with_regular_blocking', 'r', 'regular_blocking');
+
+
+-- See https://trac.osgeo.org/postgis/ticket/5484
+CREATE VIEW upgrade_test_raster_view_st_value AS
+SELECT
+	ST_Value(r, ST_MakePoint(0, 0))
+FROM upgrade_test_raster;
diff --git a/utils/create_upgrade.pl b/utils/create_upgrade.pl
index afc6f00b0..eeaf4ed43 100755
--- a/utils/create_upgrade.pl
+++ b/utils/create_upgrade.pl
@@ -4,7 +4,7 @@
 # PostGIS - Spatial Types for PostgreSQL
 # http://postgis.net
 #
-# Copyright (C) 2014-2021 Sandro Santilli <strk at kbt.io>
+# Copyright (C) 2014-2023 Sandro Santilli <strk at kbt.io>
 # Copyright (C) 2009-2010 Paul Ramsey <pramsey at opengeo.org>
 # Copyright (C) 2005 Refractions Research Inc.
 #
@@ -202,16 +202,79 @@ while(<INPUT>)
         {
             my ($name, $args, $ver) = @$replaced;
             $name = lc($name); # lowercase the name
+
+            # Check if there are argument names
+            my @argtypearray;
+            my @argnamearray;
+            my $numnamedargs = 0;
+            foreach my $a ( split ',', $args )
+            {
+                my $argtype = $a;
+
+                # NOTE: we should not consider OUT parameters
+                #print "-- ARG: [$argtype]\n";
+                if ( $argtype =~ / *([^ ]+)  *([^ ]+)/ ) {
+                    my $argname = $1;
+                    $argtype = $2;
+                    #print "-- ARGNAME: [$argname]\n";
+                    #print "-- ARGTYPE: [$argtype]\n";
+                    push @argnamearray, "'$argname'";
+                    $numnamedargs++;
+                }
+
+                push @argtypearray, "$argtype";
+            }
+            my $argnames = join ',', @argnamearray;
+            my $argtypes = join ',', @argtypearray;
+
             my $renamed = $name . '_deprecated_by_postgis_' . ${ver};
             my $replacement = "${renamed}(${args})";
             push @renamed_deprecated_functions, ${renamed};
             print <<"EOF";
--- Rename $name ( $args ) deprecated in PostGIS $ver
+-- Rename $name ( $args ) deprecated in PostGIS $ver, if needed
 DO LANGUAGE 'plpgsql'
 \$postgis_proc_upgrade\$
 DECLARE
     detail TEXT;
+    argnames TEXT[];
 BEGIN
+
+    -- Check if the deprecated function exists
+    BEGIN
+
+        SELECT proargnames
+        FROM pg_catalog.pg_proc
+        WHERE oid = '$name($argtypes)'::regprocedure
+        INTO argnames;
+
+EOF
+            # Check for argument names match, if any argument name
+            # was given in the Replaces comment
+            if ( $numnamedargs )
+            {
+                print <<"EOF";
+        -- Check if the deprecated function has the expected $numnamedargs argument names
+        IF argnames[1:$numnamedargs] != ARRAY[$argnames]::text[]
+        THEN
+            RAISE DEBUG
+                'Function $name($argtypes) exist but has argnames % (not %)',
+                argnames, ARRAY[$argnames];
+            RETURN; -- nothing to do
+        END IF;
+EOF
+            }
+            print <<"EOF";
+
+    EXCEPTION
+    WHEN undefined_function THEN
+        RAISE DEBUG 'Replaced function $name($argtypes) does not exist';
+        RETURN; -- nothing to do
+    WHEN OTHERS THEN
+        GET STACKED DIAGNOSTICS detail := PG_EXCEPTION_DETAIL;
+        RAISE EXCEPTION 'Checking if replaced function $name($args) exists got % (%)', SQLERRM, SQLSTATE
+            USING DETAIL = detail;
+    END;
+
     -- Rename the replaced function, to avoid ambiguities.
     -- The renamed function will eventually be drop.
     BEGIN

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

Summary of changes:
 NEWS                                               |  1 +
 raster/rt_pg/rtpostgis.sql.in                      |  6 +-
 raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in      |  3 +-
 .../regress/hooks/hook-after-upgrade-raster.sql    |  4 ++
 .../regress/hooks/hook-before-upgrade-raster.sql   |  7 +++
 utils/create_upgrade.pl                            | 67 +++++++++++++++++++++-
 6 files changed, 83 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list