[postgis-devel] Handling of new default arguments in upgrade procedure

Sandro Santilli strk at kbt.io
Thu Dec 16 06:43:19 PST 2021


So I came up with another syntax, allowing a function to replace
not just one but MULTIPLE previous signatures (in case we will ever
add another default argument). The new proposed syntax is:

  -- Replaces ST_Intersection(geometry, geometry) deprecated in 3.1.0

We could have multiple such lines in the comments for the same function.
The above will result in the old st_intersection(geometry, geometry)
being renamed "st_intersection_deprecated_by_postgis_301(geometry,
geometry)" with all existing users (views/materialized/triggers) still
working fine.

I've removed the code which attempts to rewrite the views as I found
it to be possibly changing some characteristics of them, and I've
added support in postgis_full_version() to report the problem:

  postgis_reg=# SELECT postgis_full_version();
  POSTGIS="3.2.0dev 3.2.0rc1-8-gf55fe92be" [EXTENSION]
  PGSQL="120" GEOS="3.11.0dev-CAPI-1.16.0" PROJ="7.1.0" LIBXML="2.9.10"
  LIBJSON="0.15" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)"
  (deprecated functions exist, upgrade is not complete)

Note the last line (could be reworded slightly).

Calling `postgis_extensions_upgrade()` would attempt again at dropping
those deprecated functions, which can result in a similar message:


	postgis_reg=# select postgis_extensions_upgrade();
	NOTICE:  Updating extension postgis 3.2.0dev
	NOTICE:  Extension postgis_raster is not available or not packagable for some reason
	NOTICE:  Extension postgis_sfcgal is not available or not packagable for some reason
	NOTICE:  Extension postgis_topology is not available or not packagable for some reason
	NOTICE:  Extension postgis_tiger_geocoder is not available or not packagable for some reason
	WARNING:  Could not drop deprecated function st_intersection_deprecated_by_postgis_301(geometry,geometry):
	WARNING:  Could not drop deprecated function st_difference_deprecated_by_postgis_301(geometry,geometry):
	WARNING:  Could not drop deprecated function st_symdifference_deprecated_by_postgis_301(geometry,geometry):
	WARNING:  Could not drop deprecated function st_unaryunion_deprecated_by_postgis_301(geometry):
	WARNING:  Could not drop deprecated function st_subdivide_deprecated_by_postgis_301(geometry,integer):
	WARNING:  Could not drop deprecated function st_clusterkmeans_deprecated_by_postgis_302(geometry,integer):

In theory, after the column you should read a detail of what prevents dropping the
function, but I'm still working on that part.

--strk;

On Thu, Dec 16, 2021 at 12:14:15PM +0100, Sandro Santilli wrote:
> I came up with a solution for when views are defined to use functions
> that we add new default arguments to. I love the solution in that
> it only requires adding a comment above the function, like the
> Available and Changed ones. It's a new comment, like this:
> 
>   -- Replaced: ST_Intersection(geometry, geometry) in 3.1.0
> 
> The upgrade procedure which sees that comment will do the following:
> 
>   1. Rename the old signature function name to <newname>
>   2. Create the new signature
>   3. REPLACE views (now) using the <newname> to make them use their
>      original definition (now changed due to the rename in step 1)
>   4. Drop the <newname> signature
> 
> I made the above work with the signature I've added a gridSize
> parameter in 3.1.0, so now I can upgrade to 3.2.0dev from 3.1.3
> and from 3.0.5 even in presence of views.
> 
> I did NOT handle materialized views, for which we will probably still
> fail (but we could improve).
> 
> The reason why I'm writing this mail is because I'm not sure about
> the syntax of the comment we want to write. In particular I'm not
> sure if "Replaced" is specific enough, because the only thing we
> actually handle here is a "backward-compatible API replacement",
> while "Replaced" doesn't express any of that. Can you think of
> a more clear label for that comment ?
> 
> References:
> 
>   The ticket reporting the problem:
>   https://trac.osgeo.org/postgis/ticket/5033
> 
>   Staging PR which shows the failures (Dronie is probably the
>   only bot currently testing upgrades from older versions):
>   https://git.osgeo.org/gitea/postgis/postgis/pulls/66
> 
>   Copy of the PR on gitlab, which doesn't even notice
>   the problem (bad bot!):
>   https://gitlab.com/postgis/postgis/-/merge_requests/64
>   
> 
> --strk; 
> 
>   Libre GIS consultant/developer
>   https://strk.kbt.io/services.html
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-devel


More information about the postgis-devel mailing list