Upgrade spatio-temporal engine plug-ins

Updated at:

The Ganos spatio-temporal engine plug-ins include the Alibaba Cloud-developed Ganos plug-in and the PostGIS plug-in. This topic describes how to upgrade these plug-ins.

You can join the RDS PostgreSQL plug-in DingTalk group (ID: 103525002795) to ask questions, exchange ideas, provide feedback, and learn more about plug-ins.

Ganos plug-ins

Query installed Ganos plug-ins

  1. Connect to the database using a PostgreSQL command-line tool.

  2. Run the following SQL statement to query the installed Ganos plug-ins.

    SELECT
      *,
      installed_version < default_version AS need_update
    FROM
      pg_available_extensions
    WHERE
      name LIKE 'ganos%';

    Example output:

                    name           | default_version | installed_version |                                                       comment                        | need_update
    -------------------------------+-----------------+-------------------+--------------------------------------------------------------------------------------+-------------
     ganos_trajectory              | 5.5             | 5.4               | Ganos trajectory extension for PostgreSQL                                            | t
     ganos_pointcloud_geometry     | 5.5             | 5.4               | Ganos_pointcloud LIDAR data and ganos_geometry data for PostgreSQL                   | t
     ganos_raster                  | 5.5             | 5.4               | Ganos raster extension for PostgreSQL                                                | t
     ganos_networking              | 5.5             | 5.4               | Ganos networking extension for PostgreSQL                                            | t
     ganos_geometry_pyramid        | 5.5             | 5.4               | Ganos Geometry Pyramid extension for PostgreSQL                                      | t
     ganos_scene                   | 5.5             | 5.4               | Ganos scene extension for PostgreSQL                                                 | t
     ganos_geometry_topology       | 5.5             | 5.4               | Ganos geometry topology spatial types and functions extension for PostgreSQL         | t
     ganos_tiger_geocoder          | 5.5             | 5.4               | Ganos tiger geocoder and reverse geocoder                                            | t
     ganos_importer                | 5.5             | 5.4               | Ganos Spatial importer extension for PostgreSQL                                      | t
     ganos_vomesh                  | 5.5             | 5.4               | Ganos volumn mesh extension for PostgreSQL                                           | t
    ...

    Parameter

    Description

    name

    The name of the plug-in.

    default_version

    The latest version available for installation on the current database.

    installed_version

    The currently installed version.

    comment

    A description of the plug-in.

    need_update

    Indicates whether an upgrade is required.

    Note

    In the query result, a value of t in the need_update column indicates that an upgrade is required.

Upgrade Ganos plug-ins

  • If your Ganos plug-in version is 3.1 or later, run the following statement to upgrade all Ganos plug-ins.

    SELECT ganos_update();
  • If your Ganos plug-in version is earlier than 3.1, you must create a function to upgrade all Ganos plug-ins. Run the following statement:

    CREATE OR REPLACE FUNCTION ganos_update()
        RETURNS text AS
    $$
    DECLARE
        rec RECORD;
        sql text;
    BEGIN
        FOR rec IN
            SELECT extname
            FROM pg_extension
            WHERE extname like 'ganos_%'
            LOOP
                sql = 'ALTER EXTENSION '
                    || rec.extname
                    || ' UPDATE ';
                RAISE NOTICE '%', sql;
                EXECUTE sql;
            END LOOP;
        return 'All Ganos extensions have been updated to the latest version';
    END
    $$ LANGUAGE 'plpgsql' volatile STRICT;

PostGIS plug-ins

Step 1: Query installed PostGIS plug-ins

  1. Connect to the database using a PostgreSQL command-line tool.

  2. Run the following SQL statement to query the installed PostGIS plug-ins.

    SELECT
      *,
      installed_version < default_version AS need_update
    FROM
      pg_available_extensions
    WHERE
      name LIKE 'postgis%';

    Example output:

              name          | default_version | installed_version |              comment               | need_update 
    ------------------------+-----------------+-------------------+------------------------------------+-------------
     postgis                | 3.3.2           | 3.1.4             | Ganos PostGIS+                     | t
     postgis_tiger_geocoder | 3.3.2           | 3.1.4             | Ganos PostGIS+ tiger geocoder      | t
     postgis_raster         | 3.3.2           | 3.1.4             | PostGIS raster types and functions | t
     ...

    Parameter

    Description

    name

    The name of the plug-in.

    default_version

    The latest version available for installation on the current database.

    installed_version

    The currently installed version.

    comment

    A description of the plug-in.

    need_update

    Indicates whether an upgrade is required.

    Note

    In the query result, a value of t in the need_update column indicates that an upgrade is required.

Step 2: Upgrade PostGIS plug-ins

The upgrade method for PostGIS plug-ins depends on the major version of your RDS PostgreSQL instance.

Important

This operation is valid for a single database only. If your instance has multiple databases, you must repeat these steps for each database.

  • For RDS PostgreSQL major versions 10, 13, 14, or 15, upgrade as follows:

    Run the following SQL statement to upgrade the PostGIS plug-in.

    ALTER EXTENSION <plug-in_name> UPDATE;
    Note
    • You must run this statement for each plug-in individually.

    • Alternatively, you can run the PostGIS_Extensions_Upgrade function to upgrade the plug-ins. For more information, see PostGIS_Extensions_Upgrade.

    SELECT PostGIS_Extensions_Upgrade();
  • For RDS PostgreSQL major versions 11 and 12, upgrade as follows:

    Run the following SQL statement to upgrade the PostGIS plug-in.

    do
    $$
    DECLARE
        with_pgis boolean;
        with_ganos boolean;
    BEGIN
        SELECT ((SELECT 1 FROM pg_extension WHERE extname='postgis') IS NOT null)
        INTO with_pgis;
    
        SELECT ((SELECT 1 FROM pg_extension WHERE extname='ganos_geometry') IS NOT null)
        INTO with_ganos;
    
        IF with_pgis AND with_ganos THEN
            PERFORM ganos_update();
        ELSIF with_ganos THEN
            PERFORM ganos_update();
        ELSIF with_pgis THEN
            PERFORM PostGIS_Extensions_Upgrade();
        END IF;
    
        return 'PostGIS has been updated to ' || postgis_lib_version();
    END
    $$ LANGUAGE 'plpgsql' ;
    Important

    On some RDS PostgreSQL 11 and 12 instances, the PostGIS plug-in is implemented using Ganos. If you receive an error similar to ERROR: RETURN cannot have a parameter in function returning void when you run this SQL statement, you must run the SELECT postgis_lib_version(); command to verify that the PostGIS plug-in was upgraded successfully.