Allow 'primary' as synonym for 'master'.

"Primary" is the term preferred in the PostgreSQL documentation, so
we should at least support it.

Practically this means it's possible to write "rempgr primary register"
in place of "repmgr master register".

The next feature-release should replace "master" with "primary" in
the documentation and log messages.

Per gripe in Github #112.
This commit is contained in:
Ian Barwick
2015-10-01 16:01:12 +09:00
parent 6184cc57be
commit 870b0a53b6
2 changed files with 6 additions and 2 deletions

View File

@@ -453,6 +453,8 @@ its port if is different from the default one.
Registers a master in a cluster. This command needs to be executed before any
standby nodes are registered.
`primary register` can be used as an alias for `master register`.
* `standby register`
Registers a standby with `repmgr`. This command needs to be executed to enable

View File

@@ -7,7 +7,7 @@
*
* Commands implemented are:
*
* MASTER REGISTER
* [ MASTER | PRIMARY ] REGISTER
*
* STANDBY REGISTER
* STANDBY UNREGISTER
@@ -316,6 +316,8 @@ main(int argc, char **argv)
server_mode = argv[optind++];
if (strcasecmp(server_mode, "STANDBY") != 0 &&
strcasecmp(server_mode, "MASTER") != 0 &&
/* allow PRIMARY as synonym for MASTER */
strcasecmp(server_mode, "PRIMARY") != 0 &&
strcasecmp(server_mode, "WITNESS") != 0 &&
strcasecmp(server_mode, "CLUSTER") != 0)
{
@@ -330,7 +332,7 @@ main(int argc, char **argv)
{
server_cmd = argv[optind++];
/* check posibilities for all server modes */
if (strcasecmp(server_mode, "MASTER") == 0)
if (strcasecmp(server_mode, "MASTER") == 0 || strcasecmp(server_mode, "PRIMARY") == 0 )
{
if (strcasecmp(server_cmd, "REGISTER") == 0)
action = MASTER_REGISTER;