From 318cb2288cbc33f722a73e2ae49fd953d8254671 Mon Sep 17 00:00:00 2001 From: Lian Hu Date: Mon, 22 Jan 2024 17:34:16 +0100 Subject: [PATCH] add parameter to specify dropping replication slot or not when drop subscription [BF-2380] --- Makefile | 4 ++-- sql/aiven_extras--1.1.9--1.1.10.sql | 1 + sql/aiven_extras.sql | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 sql/aiven_extras--1.1.9--1.1.10.sql diff --git a/Makefile b/Makefile index ce6a815..77a28c0 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -short_ver = 1.1.10 -last_ver = 1.1.9 +short_ver = 1.1.11 +last_ver = 1.1.10 long_ver = $(shell git describe --long 2>/dev/null || echo $(short_ver)-0-unknown-g`git describe --always`) generated = aiven_extras.control \ sql/aiven_extras--$(short_ver).sql \ diff --git a/sql/aiven_extras--1.1.9--1.1.10.sql b/sql/aiven_extras--1.1.9--1.1.10.sql new file mode 100644 index 0000000..e2f08fc --- /dev/null +++ b/sql/aiven_extras--1.1.9--1.1.10.sql @@ -0,0 +1 @@ +-- NOOP diff --git a/sql/aiven_extras.sql b/sql/aiven_extras.sql index 7fce9e9..f346b87 100644 --- a/sql/aiven_extras.sql +++ b/sql/aiven_extras.sql @@ -170,8 +170,10 @@ END; $$; DROP FUNCTION IF EXISTS aiven_extras.pg_drop_subscription(TEXT); +DROP FUNCTION IF EXISTS aiven_extras.pg_drop_subscription(TEXT, BOOLEAN); CREATE FUNCTION aiven_extras.pg_drop_subscription( - arg_subscription_name TEXT + arg_subscription_name TEXT, + arg_drop_repl_slot BOOLEAN = TRUE ) RETURNS VOID LANGUAGE plpgsql SECURITY DEFINER @@ -191,7 +193,9 @@ BEGIN EXECUTE pg_catalog.format('ALTER SUBSCRIPTION %I DISABLE', arg_subscription_name); EXECUTE pg_catalog.format('ALTER SUBSCRIPTION %I SET (slot_name = NONE)', arg_subscription_name); EXECUTE pg_catalog.format('DROP SUBSCRIPTION %I', arg_subscription_name); - PERFORM aiven_extras.dblink_slot_create_or_drop(l_subconninfo, l_slot_name, 'drop'); + IF (arg_drop_repl_slot IS TRUE) THEN + PERFORM aiven_extras.dblink_slot_create_or_drop(l_subconninfo, l_slot_name, 'drop'); + END IF; END; $$;