From 947d14979f87f5f3da39435bd83cd241923e9a97 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 3 Feb 2022 12:59:52 +0900 Subject: [PATCH] Fix upgrade paths from 4.1 ~ 4.3 to 5.2 and later A number of C functions were added in releases 4.2 to 4.4; however these were renamed in 5.3 to prevent naming clashes with other extensions. This does however mean that when upgrading from one of the above versions, the intermediate upgrade steps will attempt to create SQL functions referencing C functions which no longer exist in repmgr.so, and hence cause the upgrade to fail. We can work around this by providing empty upgrade scripts from these versions to 4.4, which skip the problematic CREATE FUNCTION commands. The functions will be correctly created in the 5.2--5.3 upgrade script. --- repmgr--4.2--4.3.sql | 21 +++++++-------------- repmgr--4.3--4.4.sql | 24 +++++++----------------- 2 files changed, 14 insertions(+), 31 deletions(-) diff --git a/repmgr--4.2--4.3.sql b/repmgr--4.2--4.3.sql index 96a09196..eebab6ba 100644 --- a/repmgr--4.2--4.3.sql +++ b/repmgr--4.2--4.3.sql @@ -1,17 +1,10 @@ -- complain if script is sourced in psql, rather than via CREATE EXTENSION -\echo Use "CREATE EXTENSION repmgr" to load this file. \quit +\echo Use "ALTER EXTENSION repmgr UPDATE" to load this file. \quit -CREATE FUNCTION set_upstream_last_seen() - RETURNS VOID - AS 'MODULE_PATHNAME', 'set_upstream_last_seen' - LANGUAGE C STRICT; +-- This script is intentionally empty and exists to skip the CREATE FUNCTION +-- commands contained in the 4.2--4.3 and 4.3--4.4 extension upgrade scripts, +-- which reference C functions which no longer exist in 5.3 and later. +-- +-- These functions will be explicitly created in the 5.2--5.3 extension +-- upgrade step with the correct C function references. -CREATE FUNCTION get_upstream_last_seen() - RETURNS INT - AS 'MODULE_PATHNAME', 'get_upstream_last_seen' - LANGUAGE C STRICT; - -CREATE FUNCTION get_wal_receiver_pid() - RETURNS INT - AS 'MODULE_PATHNAME', 'get_wal_receiver_pid' - LANGUAGE C STRICT; diff --git a/repmgr--4.3--4.4.sql b/repmgr--4.3--4.4.sql index 4b4b8f97..5acf7272 100644 --- a/repmgr--4.3--4.4.sql +++ b/repmgr--4.3--4.4.sql @@ -1,19 +1,9 @@ -- complain if script is sourced in psql, rather than via CREATE EXTENSION -\echo Use "CREATE EXTENSION repmgr" to load this file. \quit +\echo Use "ALTER EXTENSION repmgr UPDATE" to load this file. \quit -DROP FUNCTION set_upstream_last_seen(); - -CREATE FUNCTION set_upstream_last_seen(INT) - RETURNS VOID - AS 'MODULE_PATHNAME', 'set_upstream_last_seen' - LANGUAGE C STRICT; - -CREATE FUNCTION get_upstream_node_id() - RETURNS INT - AS 'MODULE_PATHNAME', 'get_upstream_node_id' - LANGUAGE C STRICT; - -CREATE FUNCTION set_upstream_node_id(INT) - RETURNS VOID - AS 'MODULE_PATHNAME', 'set_upstream_node_id' - LANGUAGE C STRICT; +-- This script is intentionally empty and exists to skip the CREATE FUNCTION +-- commands contained in the 4.3--4.4 extension upgrade script, which reference +-- C functions which no longer exist in 5.3 and later. +-- +-- These functions will be explicitly created in the 5.2--5.3 extension +-- upgrade step with the correct C function references.