Changes between Initial Version and Version 1 of PostGISExtensionPaths


Ignore:
Timestamp:
02/11/22 10:15:29 (3 years ago)
Author:
robe
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PostGISExtensionPaths

    v1 v1  
     1= RFC-6: Managing PostGIS Extension Paths with Fewer Files =
     2||Date:|| 2022/02/11||
     3||Author:|| Regina Obe||
     4||Last Edited:|| 2022/02/11||
     5||Last Updated By: || Regina Obe <lr at pcorp dot us> ||
     6||Status:|| In Discussion||
     7
     8== PROBLEM STATEMENT ==
     9With each new version of PostGIS, we need to ship more and more extension upgrade scripts.
     10In reality all the upgrade scripts are just a symlink to the main one or exact copies of the main one.
     11This results in a users extensions folder cluttered with 100s of PostGIS related scripts.
     12
     13Not only that, but for each new version we ship, we always need to remember to add the recently shipped micros of other versions
     14to the extensions/updateable.mk script.
     15
     16The largeness of the script files (when not symlinked, which is often the case), is the biggest issue of all, and will become even more of an issue
     17with shipping spatial_ref_sys updates.
     18
     19The solution of the above issues is to have: Solution 1, Solution 2, and Solution 3 implemented, as some solutions are not backward compatible but do provide extra benefits.
     20
     21
     22== SOLTUION 1 ==
     23
     24This has already been committed in master branch for PostGIS 3.3.0.
     25Embedded in:
     26
     27
     28----
     29SELECT postgis_extensions_upgrade();
     30----
     31
     32What it does:
     33Update the current version to ANY and then run the updates.
     34This has the affect of always forcing the  postgis--ANY--<current version>.sql script to run which handles all versions.
     35
     36Benefits of this approach:
     37
     381. We only need to ship one extension upgrade script file per extension.  The postgis--ANY--<current version>.sql
     392. No clutter of 100s of 1000s of files.
     403. We don't need to maintain extensions/updateable.mk and remember to update it.
     414. It is possible to upgrade from postgis (older PostgreSQL Version) 3.3.0 to (new PostgreSQL version)  3.3.0. This is generally what is needed in pg_upgrade.
     42
     43**Drawbacks:**
     44
     451. People can only upgrade using
     46
     47```
     48SELECT postgis_extensions_upgrade();
     49```
     50Or do the manually mock with the pg_catalog.pg_extension table themselves
     51
     522. We are mucking with system tables, pg_catalog.pg_extension, which we have done for other things, but is a questionable practice.
     53
     543.  Packagers who have put in nice features to auto upgrade extensions during pg_upgrade, now have to treat us a special snowflakes.
     55
     56
     57== SOLUTION 2 ==
     58
     59Beg and plea upstream to recognize a % or ANY as a first class citizen to mean any prior version.
     60
     61This approach allows for defining a new line item in the control file, that denotes something like
     62
     63
     64----
     65upgrade_script_pattern = %--<version>
     66----
     67
     68Where the % will be treated as a wildcard to match to provider the best match.
     69
     70**Benefits of this approach:**
     71
     721. We have made what we are doing, built into the postgis machinery, so no special care needs to be done by packagers or users.
     73It makes us not a special snowflake.
     74
     752.  It will help other extensions which have similar issues and just want a single upgrade script. We expect many extensions to benefit, though we will benefit the most.
     76
     77**Drawbacks:**
     78
     791. Old PostgreSQL versions, won't understand this new world order, so we still need to maintain a backward compatible way for 5 years or more.
     80
     81
     82=== SOLUTION 3 ===
     83
     84The 0-byte file and strip model.  This approach creates 0 or very small byte files, with their existing solely to maintain PostgreSQL extension chain model.
     85To reduce file bloat, we will only support the last two micros of any release.  Anyone who isn't in the latest micro (or latest to last micro) of each minor/major, with need to upgrade to said version OR use the postgis_extensions_upgrade() function.
     86
     87In this model, our extension files look like below:
     88An additional addendum to this SOLUTION 3, is to not maintain - extensions/updateable.mk but instead have this file generated as part of the build process and be shipped as part of the tar ball.
     89
     90The extensions/updateable.mk will be generated by looking at git tags all the prior versions, and picking the last two of each mino.
     91
     92our generated extension upgrade scripts will look like the below, with only the postgis--3.3.0MAX--3.3.0.sql having any upgrade statements in it.
     93
     94----
     95:
     96postgis--3.1.4--3.3.0MAX.sql
     97postgis--3.1.5--3.3.0MAX.sql
     98postgis--3.2.0--3.3.0MAX.sql
     99postgis--3.2.1--3.3.0MAX.sql
     100postgis--3.3.0MAX--3.3.0.sql
     101----
     102**Benefits of this approach:**
     103
     1041. We are staying between the lines. Respecting known practices, but still having much lighter weight scripts.
     1052. A little less clutter if we include the addendum (of only keeping the last 2)
     1063. A little little easier release cycle if we don't need to maintain extensions/updateable.mk and remember to update it.
     1074. No change in upgrade extension workflow for packagers (or users who think of PostGIS as any other extension).
     1085. It will work for all PostgreSQL versions supported
     109
     110** Downsides:**
     111
     1121. We still have some clutter of files, and without addendum, we have just as much clutter of files as before.
     1132. With addendum, it is not possible for a user to upgrade using ALTER EXTENSION from a version we don't ship a script for. They would have to use and that assumes this version -- has the ANY/MAX hack.
     114
     115----
     116SELECT postgis_extensions_upgrade();
     117----
     118
     1193. It is not possible to upgrade from version (prior PostgreSQL version) 3.3.0 to (newer PostgreSQL version) 3.3.0 which is needed often in pg_upgrade to gain the benefits of new features in latest PostgreSQL version that are not exposed in older PostgreSQL versions.  Such operation would just state "You are already at latest version" and not do anything, unless one does it via
     120
     121----
     122SELECT postgis_extensions_upgrade();
     123----
     124
     125which would have SOLUTION 1.
     126