From 35b6178e078144f9830ce2630345d086465823a7 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 27 Jun 2017 09:50:47 +0900 Subject: [PATCH] placeholder code for function --- dbutils.h | 1 + repmgr--4.0.sql | 3 +++ repmgr.c | 14 ++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/dbutils.h b/dbutils.h index 03979121..bc8d5366 100644 --- a/dbutils.h +++ b/dbutils.h @@ -59,6 +59,7 @@ typedef struct s_node_info char slot_name[MAXLEN]; int priority; bool active; + /* used during failover to track node status */ bool is_ready; bool is_visible; XLogRecPtr xlog_location; diff --git a/repmgr--4.0.sql b/repmgr--4.0.sql index a1d755c4..48489b60 100644 --- a/repmgr--4.0.sql +++ b/repmgr--4.0.sql @@ -34,3 +34,6 @@ CREATE VIEW show_nodes AS LEFT JOIN nodes un ON un.node_id = n.upstream_node_id; +CREATE FUNCTION request_vote(int) RETURNS boolean +AS '$libdir/repmgr', 'request_vote' +LANGUAGE C STRICT; diff --git a/repmgr.c b/repmgr.c index 14a92305..84097917 100644 --- a/repmgr.c +++ b/repmgr.c @@ -28,6 +28,9 @@ PG_MODULE_MAGIC; void _PG_init(void); void _PG_fini(void); +Datum request_vote(PG_FUNCTION_ARGS); +PG_FUNCTION_INFO_V1(request_vote); + /* * Module load callback */ @@ -44,3 +47,14 @@ _PG_fini(void) { elog(INFO, "repmgr fini"); } + + +Datum +request_vote(PG_FUNCTION_ARGS) +{ + uint32 node_id = PG_GETARG_INT32(0); + + elog(INFO, "id is %i", node_id); + + PG_RETURN_BOOL(true); +}