diff --git a/Makefile.in b/Makefile.in
index f5aeb7ce..55845ff4 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -37,7 +37,8 @@ include Makefile.global
$(info Building against PostgreSQL $(MAJORVERSION))
REPMGR_CLIENT_OBJS = repmgr-client.o \
- repmgr-action-primary.o repmgr-action-standby.o repmgr-action-bdr.o repmgr-action-cluster.o repmgr-action-node.o \
+ repmgr-action-primary.o repmgr-action-standby.o repmgr-action-witness.o \
+ repmgr-action-bdr.o repmgr-action-cluster.o repmgr-action-node.o \
configfile.o log.o strutil.o controldata.o dirutil.o compat.o dbutils.o
REPMGRD_OBJS = repmgrd.o repmgrd-physical.o repmgrd-bdr.o configfile.o log.o dbutils.o strutil.o controldata.o
DATE=$(shell date "+%Y-%m-%d")
@@ -77,6 +78,7 @@ additional-clean:
rm -f repmgr-client.o
rm -f repmgr-action-primary.o
rm -f repmgr-action-standby.o
+ rm -f repmgr-action-witness.o
rm -f repmgr-action-bdr.o
rm -f repmgr-action-node.o
rm -f repmgr-action-cluster.o
diff --git a/repmgr--4.0.sql b/repmgr--4.0.sql
index 5c8e9a80..83b328d9 100644
--- a/repmgr--4.0.sql
+++ b/repmgr--4.0.sql
@@ -6,7 +6,7 @@ CREATE TABLE repmgr.nodes (
upstream_node_id INTEGER NULL REFERENCES nodes (node_id) DEFERRABLE,
active BOOLEAN NOT NULL DEFAULT TRUE,
node_name TEXT NOT NULL,
- type TEXT NOT NULL CHECK (type IN('primary','standby','bdr')),
+ type TEXT NOT NULL CHECK (type IN('primary','standby','witness','bdr')),
location TEXT NOT NULL DEFAULT 'default',
priority INT NOT NULL DEFAULT 100,
conninfo TEXT NOT NULL,
diff --git a/repmgr--unpackaged--4.0.sql b/repmgr--unpackaged--4.0.sql
index cdbc9c08..f40b4e17 100644
--- a/repmgr--unpackaged--4.0.sql
+++ b/repmgr--unpackaged--4.0.sql
@@ -32,7 +32,7 @@ CREATE TABLE repmgr.nodes (
upstream_node_id INTEGER NULL REFERENCES repmgr.nodes (node_id) DEFERRABLE,
active BOOLEAN NOT NULL DEFAULT TRUE,
node_name TEXT NOT NULL,
- type TEXT NOT NULL CHECK (type IN('primary','standby','bdr')),
+ type TEXT NOT NULL CHECK (type IN('primary','standby','witness','bdr')),
location TEXT NOT NULL DEFAULT 'default',
priority INT NOT NULL DEFAULT 100,
conninfo TEXT NOT NULL,
diff --git a/repmgr-action-witness.c b/repmgr-action-witness.c
new file mode 100644
index 00000000..b69ef24b
--- /dev/null
+++ b/repmgr-action-witness.c
@@ -0,0 +1,47 @@
+/*
+ * repmgr-action-witness.c
+ *
+ * Implements witness actions for the repmgr command line utility
+ *
+ * Copyright (c) 2ndQuadrant, 2010-2017
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#include
+
+#include "repmgr.h"
+#include "dirutil.h"
+#include "compat.h"
+#include "controldata.h"
+
+#include "repmgr-client-global.h"
+#include "repmgr-action-witness.h"
+
+void
+do_witness_register(void)
+{
+ return;
+}
+
+void
+do_witness_unregister(void)
+{
+ return;
+}
+
+void do_witness_help(void)
+{
+ return;
+}
+
diff --git a/repmgr-action-witness.h b/repmgr-action-witness.h
new file mode 100644
index 00000000..5ca94bad
--- /dev/null
+++ b/repmgr-action-witness.h
@@ -0,0 +1,27 @@
+/*
+ * repmgr-action-witness.h
+ * Copyright (c) 2ndQuadrant, 2010-2017
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef _REPMGR_ACTION_WITNESS_H_
+#define _REPMGR_ACTION_WITNESS_H_
+
+extern void do_witness_register(void);
+extern void do_witness_unregister(void);
+
+extern void do_witness_help(void);
+
+#endif /* _REPMGR_ACTION_WITNESS_H_ */
diff --git a/repmgr-client.c b/repmgr-client.c
index b2292153..60966769 100644
--- a/repmgr-client.c
+++ b/repmgr-client.c
@@ -57,6 +57,7 @@
#include "repmgr-client-global.h"
#include "repmgr-action-primary.h"
#include "repmgr-action-standby.h"
+#include "repmgr-action-witness.h"
#include "repmgr-action-bdr.h"
#include "repmgr-action-node.h"
@@ -703,6 +704,7 @@ main(int argc, char **argv)
*
* { PRIMARY | MASTER } REGISTER |
* STANDBY { REGISTER | UNREGISTER | CLONE [node] | PROMOTE | FOLLOW [node] | SWITCHOVER } |
+ * WITNESS { CREATE | REGISTER | UNREGISTER }
* BDR { REGISTER | UNREGISTER } |
* NODE { STATUS | CHECK | REJOIN | SERVICE } |
* CLUSTER { CROSSCHECK | MATRIX | SHOW | EVENT | CLEANUP }
@@ -771,6 +773,18 @@ main(int argc, char **argv)
else if (strcasecmp(repmgr_action, "STATUS") == 0)
action = NODE_STATUS;
}
+ else if (strcasecmp(repmgr_command, "WITNESS") == 0)
+ {
+ if (help_option == true)
+ {
+ do_witness_help();
+ exit(SUCCESS);
+ }
+ else if (strcasecmp(repmgr_action, "REGISTER") == 0)
+ action = WITNESS_REGISTER;
+ else if (strcasecmp(repmgr_action, "UNREGISTER") == 0)
+ action = WITNESS_UNREGISTER;
+ }
else if (strcasecmp(repmgr_command, "BDR") == 0)
#else
if (strcasecmp(repmgr_command, "BDR") == 0)
@@ -1164,6 +1178,12 @@ main(int argc, char **argv)
do_standby_switchover();
break;
+ /* WITNESS */
+ case WITNESS_REGISTER:
+ do_witness_register();
+ break;
+ case WITNESS_UNREGISTER:
+ do_witness_unregister();
break;
#else
/* we won't ever reach here, but stop the compiler complaining */
@@ -1175,6 +1195,8 @@ main(int argc, char **argv)
case STANDBY_PROMOTE:
case STANDBY_FOLLOW:
case STANDBY_SWITCHOVER:
+ case WITNESS_REGISTER:
+ case WITNESS_UNREGISTER:
break;
#endif
diff --git a/repmgr-client.h b/repmgr-client.h
index c63a92ad..41de3f60 100644
--- a/repmgr-client.h
+++ b/repmgr-client.h
@@ -23,7 +23,6 @@
#include "log.h"
-
#define NO_ACTION 0 /* Dummy default action */
#define PRIMARY_REGISTER 1
#define PRIMARY_UNREGISTER 2
@@ -33,17 +32,19 @@
#define STANDBY_PROMOTE 6
#define STANDBY_FOLLOW 7
#define STANDBY_SWITCHOVER 8
-#define BDR_REGISTER 9
-#define BDR_UNREGISTER 10
-#define NODE_STATUS 11
-#define NODE_CHECK 12
-#define NODE_SERVICE 13
-#define NODE_REJOIN 14
-#define CLUSTER_SHOW 15
-#define CLUSTER_CLEANUP 16
-#define CLUSTER_MATRIX 17
-#define CLUSTER_CROSSCHECK 18
-#define CLUSTER_EVENT 19
+#define WITNESS_REGISTER 9
+#define WITNESS_UNREGISTER 10
+#define BDR_REGISTER 11
+#define BDR_UNREGISTER 12
+#define NODE_STATUS 13
+#define NODE_CHECK 14
+#define NODE_SERVICE 15
+#define NODE_REJOIN 16
+#define CLUSTER_SHOW 17
+#define CLUSTER_CLEANUP 18
+#define CLUSTER_MATRIX 19
+#define CLUSTER_CROSSCHECK 20
+#define CLUSTER_EVENT 21
/* command line options without short versions */
#define OPT_HELP 1001