Skip to content

Commit

Permalink
support for PG17
Browse files Browse the repository at this point in the history
Added support for changes introduced in ReplicationSlotCreate for PG17.
Now supporting failover and synced parameters.
  • Loading branch information
kathia-barahona committed Aug 1, 2024
1 parent e120e4f commit 1270874
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
PGUSER: postgres
strategy:
matrix:
postgresql_version: [11, 12, 13, 14, 15, 16]
postgresql_version: [12, 13, 14, 15, 16, 17]
experimental: [false]
repo: ["pgdg"]
# Define the current dev version to be experimental
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
short_ver = 1.1.13
last_ver = 1.1.12
short_ver = 1.1.14
last_ver = 1.1.13
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 \
Expand All @@ -23,7 +23,7 @@ EXTRA_CLEAN = aiven_extras.control aiven-extras-rpm-src.tar

include $(PGXS)

rpm: rpm-96 rpm-10 rpm-11 rpm-12 rpm-13 rpm-14 rpm-15 rpm-16
rpm: rpm-12 rpm-13 rpm-14 rpm-15 rpm-16 rpm-17

aiven_extras.control: aiven_extras.control.in
mkdir -p $(@D)
Expand Down
1 change: 1 addition & 0 deletions sql/aiven_extras--1.1.13--1.1.14.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- NOOP
4 changes: 3 additions & 1 deletion sql/aiven_extras.sql
Original file line number Diff line number Diff line change
Expand Up @@ -597,12 +597,14 @@ END;
$OUTER$;

-- standby slots functions
DROP FUNCTION IF EXISTS aiven_extras.pg_create_logical_replication_slot_on_standby(name, name, boolean, boolean);
DROP FUNCTION IF EXISTS aiven_extras.pg_create_logical_replication_slot_on_standby(name, name, boolean, boolean, boolean, boolean);
CREATE FUNCTION aiven_extras.pg_create_logical_replication_slot_on_standby(
slot_name name,
plugin name,
temporary boolean DEFAULT false,
twophase boolean DEFAULT false,
failover boolean DEFAULT false,
synced boolean DEFAULT false
OUT slot_name name, OUT lsn pg_lsn)
AS 'MODULE_PATHNAME', 'standby_slot_create'
LANGUAGE C;
Expand Down
20 changes: 19 additions & 1 deletion src/aiven_extras.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ standby_slot_create(PG_FUNCTION_ARGS)
Name plugin = PG_GETARG_NAME(1);
bool temporary = PG_GETARG_BOOL(2);
bool two_phase = PG_GETARG_BOOL(3);
bool failover = PG_GETARG_BOOL(4);
bool synced = PG_GETARG_BOOL(5);
Datum result;
TupleDesc tupdesc;
HeapTuple tuple;
Expand Down Expand Up @@ -76,6 +78,16 @@ standby_slot_create(PG_FUNCTION_ARGS)
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("two phase commits are only available on PG >= 14")));
#endif
#if PG_VERSION_NUM < 17000
if (failover)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("failover is only available on PG >= 17")));
if (synced)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("synced is only available on PG >= 17")));

/* Don't bother returning anything else than void for now */
Assert(!MyReplicationSlot);

Expand All @@ -87,10 +99,16 @@ standby_slot_create(PG_FUNCTION_ARGS)
* slots can be created as temporary from beginning as they get dropped on
* error as well.
*/
ReplicationSlotCreate(NameStr(*name), true,
ReplicationSlotCreate(
NameStr(*name),
true,
temporary ? RS_TEMPORARY : RS_EPHEMERAL
#if PG_VERSION_NUM >= 140000
, two_phase
#endif
#if PG_VERSION_NUM >= 170000
, failover
, synced
#endif
);

Expand Down

0 comments on commit 1270874

Please sign in to comment.