mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-25 16:16:29 +00:00
Fix tabulation
This commit is contained in:
34
dbutils.c
34
dbutils.c
@@ -29,7 +29,7 @@ static bool _set_config(PGconn *conn, const char *config_param, const char *sqlq
|
|||||||
* Connect to a database using a conninfo string.
|
* Connect to a database using a conninfo string.
|
||||||
*
|
*
|
||||||
* NOTE: *do not* use this for replication connections; instead use:
|
* NOTE: *do not* use this for replication connections; instead use:
|
||||||
* establish_db_connection_by_params()
|
* establish_db_connection_by_params()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static PGconn *
|
static PGconn *
|
||||||
@@ -112,7 +112,7 @@ establish_db_connection_as_user(const char *conninfo,
|
|||||||
{
|
{
|
||||||
PGconn *conn = NULL;
|
PGconn *conn = NULL;
|
||||||
t_conninfo_param_list conninfo_params;
|
t_conninfo_param_list conninfo_params;
|
||||||
bool parse_success;
|
bool parse_success;
|
||||||
char *errmsg = NULL;
|
char *errmsg = NULL;
|
||||||
|
|
||||||
initialize_conninfo_params(&conninfo_params, false);
|
initialize_conninfo_params(&conninfo_params, false);
|
||||||
@@ -121,7 +121,7 @@ establish_db_connection_as_user(const char *conninfo,
|
|||||||
|
|
||||||
if (parse_success == false)
|
if (parse_success == false)
|
||||||
{
|
{
|
||||||
log_error(_("unable to pass provided conninfo string:\n %s"), errmsg);
|
log_error(_("unable to pass provided conninfo string:\n %s"), errmsg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,8 +140,8 @@ establish_db_connection_by_params(const char *keywords[], const char *values[],
|
|||||||
const bool exit_on_error)
|
const bool exit_on_error)
|
||||||
{
|
{
|
||||||
PGconn *conn;
|
PGconn *conn;
|
||||||
bool replication_connection = false;
|
bool replication_connection = false;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Connect to the database using the provided parameters */
|
/* Connect to the database using the provided parameters */
|
||||||
conn = PQconnectdbParams(keywords, values, true);
|
conn = PQconnectdbParams(keywords, values, true);
|
||||||
@@ -149,7 +149,7 @@ establish_db_connection_by_params(const char *keywords[], const char *values[],
|
|||||||
/* Check to see that the backend connection was successfully made */
|
/* Check to see that the backend connection was successfully made */
|
||||||
if ((PQstatus(conn) != CONNECTION_OK))
|
if ((PQstatus(conn) != CONNECTION_OK))
|
||||||
{
|
{
|
||||||
log_error(_("connection to database failed:\n %s"),
|
log_error(_("connection to database failed:\n %s"),
|
||||||
PQerrorMessage(conn));
|
PQerrorMessage(conn));
|
||||||
if (exit_on_error)
|
if (exit_on_error)
|
||||||
{
|
{
|
||||||
@@ -295,8 +295,8 @@ param_get(t_conninfo_param_list *param_list, const char *param)
|
|||||||
{
|
{
|
||||||
if (param_list->values[c] != NULL && param_list->values[c][0] != '\0')
|
if (param_list->values[c] != NULL && param_list->values[c][0] != '\0')
|
||||||
return param_list->values[c];
|
return param_list->values[c];
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,7 +376,7 @@ begin_transaction(PGconn *conn)
|
|||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
{
|
{
|
||||||
log_error(_("Unable to begin transaction:\n %s"),
|
log_error(_("Unable to begin transaction:\n %s"),
|
||||||
PQerrorMessage(conn));
|
PQerrorMessage(conn));
|
||||||
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
@@ -424,7 +424,7 @@ rollback_transaction(PGconn *conn)
|
|||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
{
|
{
|
||||||
log_error(_("Unable to rollback transaction:\n %s"),
|
log_error(_("Unable to rollback transaction:\n %s"),
|
||||||
PQerrorMessage(conn));
|
PQerrorMessage(conn));
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
@@ -461,7 +461,7 @@ _set_config(PGconn *conn, const char *config_param, const char *sqlquery)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
set_config(PGconn *conn, const char *config_param, const char *config_value)
|
set_config(PGconn *conn, const char *config_param, const char *config_value)
|
||||||
{
|
{
|
||||||
char sqlquery[MAX_QUERY_LEN];
|
char sqlquery[MAX_QUERY_LEN];
|
||||||
|
|
||||||
@@ -589,8 +589,8 @@ get_master_connection(PGconn *conn,
|
|||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT node_id, conninfo, "
|
" SELECT node_id, conninfo, "
|
||||||
" CASE WHEN type = 'master' THEN 1 ELSE 2 END AS type_priority"
|
" CASE WHEN type = 'master' THEN 1 ELSE 2 END AS type_priority"
|
||||||
" FROM repmgr.nodes "
|
" FROM repmgr.nodes "
|
||||||
" WHERE type != 'witness' "
|
" WHERE type != 'witness' "
|
||||||
"ORDER BY active DESC, type_priority, priority, node_id");
|
"ORDER BY active DESC, type_priority, priority, node_id");
|
||||||
|
|
||||||
@@ -599,7 +599,7 @@ get_master_connection(PGconn *conn,
|
|||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
log_error(_("unable to retrieve node records:\n %s"),
|
log_error(_("unable to retrieve node records:\n %s"),
|
||||||
PQerrorMessage(conn));
|
PQerrorMessage(conn));
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -626,7 +626,7 @@ get_master_connection(PGconn *conn,
|
|||||||
|
|
||||||
if (is_node_standby == -1)
|
if (is_node_standby == -1)
|
||||||
{
|
{
|
||||||
log_error(_("unable to retrieve recovery state from node %i:\n %s"),
|
log_error(_("unable to retrieve recovery state from node %i:\n %s"),
|
||||||
node_id,
|
node_id,
|
||||||
PQerrorMessage(remote_conn));
|
PQerrorMessage(remote_conn));
|
||||||
PQfinish(remote_conn);
|
PQfinish(remote_conn);
|
||||||
@@ -672,8 +672,8 @@ get_master_node_id(PGconn *conn)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBuffer(&query,
|
||||||
"SELECT node_id "
|
"SELECT node_id "
|
||||||
" FROM repmgr.nodes "
|
" FROM repmgr.nodes "
|
||||||
" WHERE type = 'master' "
|
" WHERE type = 'master' "
|
||||||
" AND active IS TRUE ");
|
" AND active IS TRUE ");
|
||||||
|
|
||||||
|
|||||||
10
dbutils.h
10
dbutils.h
@@ -75,7 +75,7 @@ typedef struct s_event_info
|
|||||||
{
|
{
|
||||||
char *node_name;
|
char *node_name;
|
||||||
char *conninfo_str;
|
char *conninfo_str;
|
||||||
} t_event_info;
|
} t_event_info;
|
||||||
|
|
||||||
#define T_EVENT_INFO_INITIALIZER { \
|
#define T_EVENT_INFO_INITIALIZER { \
|
||||||
NULL, \
|
NULL, \
|
||||||
@@ -88,7 +88,7 @@ typedef struct s_event_info
|
|||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
char **keywords;
|
char **keywords;
|
||||||
char **values;
|
char **values;
|
||||||
} t_conninfo_param_list;
|
} t_conninfo_param_list;
|
||||||
@@ -100,9 +100,9 @@ typedef struct
|
|||||||
typedef struct s_replication_slot
|
typedef struct s_replication_slot
|
||||||
{
|
{
|
||||||
char slot_name[MAXLEN];
|
char slot_name[MAXLEN];
|
||||||
char slot_type[MAXLEN];
|
char slot_type[MAXLEN];
|
||||||
bool active;
|
bool active;
|
||||||
} t_replication_slot;
|
} t_replication_slot;
|
||||||
|
|
||||||
|
|
||||||
/* connection functions */
|
/* connection functions */
|
||||||
@@ -133,7 +133,7 @@ bool rollback_transaction(PGconn *conn);
|
|||||||
bool check_cluster_schema(PGconn *conn);
|
bool check_cluster_schema(PGconn *conn);
|
||||||
|
|
||||||
/* GUC manipulation functions */
|
/* GUC manipulation functions */
|
||||||
bool set_config(PGconn *conn, const char *config_param, const char *config_value);
|
bool set_config(PGconn *conn, const char *config_param, const char *config_value);
|
||||||
bool set_config_bool(PGconn *conn, const char *config_param, bool state);
|
bool set_config_bool(PGconn *conn, const char *config_param, bool state);
|
||||||
|
|
||||||
/* Server information functions */
|
/* Server information functions */
|
||||||
|
|||||||
@@ -27,5 +27,5 @@
|
|||||||
#define ERR_BARMAN 19
|
#define ERR_BARMAN 19
|
||||||
#define ERR_REGISTRATION_SYNC 20
|
#define ERR_REGISTRATION_SYNC 20
|
||||||
|
|
||||||
#endif /* _ERRCODE_H_ */
|
#endif /* _ERRCODE_H_ */
|
||||||
|
|
||||||
|
|||||||
2
log.c
2
log.c
@@ -78,7 +78,7 @@ _stderr_log_with_level(const char *level_name, int level, const char *fmt, va_li
|
|||||||
}
|
}
|
||||||
|
|
||||||
vfprintf(stderr, fmt, ap);
|
vfprintf(stderr, fmt, ap);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
log.h
2
log.h
@@ -12,7 +12,7 @@
|
|||||||
#define REPMGR_STDERR 2
|
#define REPMGR_STDERR 2
|
||||||
|
|
||||||
#define OM_COMMAND_LINE 1
|
#define OM_COMMAND_LINE 1
|
||||||
#define OM_DAEMON 2
|
#define OM_DAEMON 2
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
stderr_log_with_level(const char *level_name, int level, const char *fmt,...)
|
stderr_log_with_level(const char *level_name, int level, const char *fmt,...)
|
||||||
|
|||||||
187
repmgr-client.c
187
repmgr-client.c
@@ -27,9 +27,9 @@ ItemList cli_errors = { NULL, NULL };
|
|||||||
ItemList cli_warnings = { NULL, NULL };
|
ItemList cli_warnings = { NULL, NULL };
|
||||||
|
|
||||||
static bool config_file_required = true;
|
static bool config_file_required = true;
|
||||||
static char pg_bindir[MAXLEN] = "";
|
static char pg_bindir[MAXLEN] = "";
|
||||||
|
|
||||||
static char repmgr_slot_name[MAXLEN] = "";
|
static char repmgr_slot_name[MAXLEN] = "";
|
||||||
static char *repmgr_slot_name_ptr = NULL;
|
static char *repmgr_slot_name_ptr = NULL;
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -38,13 +38,13 @@ main(int argc, char **argv)
|
|||||||
int optindex;
|
int optindex;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
char *repmgr_node_type = NULL;
|
char *repmgr_node_type = NULL;
|
||||||
char *repmgr_action = NULL;
|
char *repmgr_action = NULL;
|
||||||
bool valid_repmgr_node_type_found = true;
|
bool valid_repmgr_node_type_found = true;
|
||||||
int action = NO_ACTION;
|
int action = NO_ACTION;
|
||||||
char *dummy_action = "";
|
char *dummy_action = "";
|
||||||
|
|
||||||
bool config_file_parsed = false;
|
bool config_file_parsed = false;
|
||||||
|
|
||||||
|
|
||||||
set_progname(argv[0]);
|
set_progname(argv[0]);
|
||||||
@@ -68,10 +68,10 @@ main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Options which cause repmgr to exit in this block;
|
* Options which cause repmgr to exit in this block;
|
||||||
* these are the only ones which can be executed as root user
|
* these are the only ones which can be executed as root user
|
||||||
*/
|
*/
|
||||||
case OPT_HELP: /* --help */
|
case OPT_HELP: /* --help */
|
||||||
do_help();
|
do_help();
|
||||||
exit(SUCCESS);
|
exit(SUCCESS);
|
||||||
@@ -88,7 +88,7 @@ main(int argc, char **argv)
|
|||||||
exit(SUCCESS);
|
exit(SUCCESS);
|
||||||
|
|
||||||
/* general configuration options
|
/* general configuration options
|
||||||
* ----------------------------- */
|
* ----------------------------- */
|
||||||
|
|
||||||
/* -f/--config-file */
|
/* -f/--config-file */
|
||||||
case 'f':
|
case 'f':
|
||||||
@@ -112,7 +112,7 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/* logging options
|
/* logging options
|
||||||
* --------------- */
|
* --------------- */
|
||||||
|
|
||||||
/* -L/--log-level */
|
/* -L/--log-level */
|
||||||
case 'L':
|
case 'L':
|
||||||
@@ -143,7 +143,7 @@ main(int argc, char **argv)
|
|||||||
runtime_options.terse = true;
|
runtime_options.terse = true;
|
||||||
break;
|
break;
|
||||||
/* --verbose */
|
/* --verbose */
|
||||||
case 'v':
|
case 'v':
|
||||||
runtime_options.verbose = true;
|
runtime_options.verbose = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -152,10 +152,10 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disallow further running as root to prevent directory ownership problems.
|
* Disallow further running as root to prevent directory ownership problems.
|
||||||
* We check this here to give the root user a chance to execute --help/--version
|
* We check this here to give the root user a chance to execute --help/--version
|
||||||
* options.
|
* options.
|
||||||
*/
|
*/
|
||||||
if (geteuid() == 0)
|
if (geteuid() == 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@@ -176,73 +176,73 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Determine the node type and action; following are valid:
|
* Determine the node type and action; following are valid:
|
||||||
*
|
*
|
||||||
* { MASTER | PRIMARY } REGISTER |
|
* { MASTER | PRIMARY } REGISTER |
|
||||||
* STANDBY {REGISTER | UNREGISTER | CLONE [node] | PROMOTE | FOLLOW [node] | SWITCHOVER | REWIND} |
|
* STANDBY {REGISTER | UNREGISTER | CLONE [node] | PROMOTE | FOLLOW [node] | SWITCHOVER | REWIND} |
|
||||||
* WITNESS { CREATE | REGISTER | UNREGISTER } |
|
* WITNESS { CREATE | REGISTER | UNREGISTER } |
|
||||||
* BDR { REGISTER | UNREGISTER } |
|
* BDR { REGISTER | UNREGISTER } |
|
||||||
* CLUSTER { CROSSCHECK | MATRIX | SHOW | CLEANUP }
|
* CLUSTER { CROSSCHECK | MATRIX | SHOW | CLEANUP }
|
||||||
*
|
*
|
||||||
* [node] is an optional hostname, provided instead of the -h/--host optipn
|
* [node] is an optional hostname, provided instead of the -h/--host optipn
|
||||||
*/
|
*/
|
||||||
if (optind < argc)
|
if (optind < argc)
|
||||||
{
|
{
|
||||||
repmgr_node_type = argv[optind++];
|
repmgr_node_type = argv[optind++];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind < argc)
|
if (optind < argc)
|
||||||
{
|
{
|
||||||
repmgr_action = argv[optind++];
|
repmgr_action = argv[optind++];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
repmgr_action = dummy_action;
|
repmgr_action = dummy_action;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (repmgr_node_type != NULL)
|
if (repmgr_node_type != NULL)
|
||||||
{
|
{
|
||||||
if (strcasecmp(repmgr_node_type, "MASTER") == 0 || strcasecmp(repmgr_node_type, "PRIMARY") == 0 )
|
if (strcasecmp(repmgr_node_type, "MASTER") == 0 || strcasecmp(repmgr_node_type, "PRIMARY") == 0 )
|
||||||
{
|
{
|
||||||
if (strcasecmp(repmgr_action, "REGISTER") == 0)
|
if (strcasecmp(repmgr_action, "REGISTER") == 0)
|
||||||
action = MASTER_REGISTER;
|
action = MASTER_REGISTER;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
valid_repmgr_node_type_found = false;
|
valid_repmgr_node_type_found = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == NO_ACTION)
|
if (action == NO_ACTION)
|
||||||
{
|
{
|
||||||
PQExpBufferData command_error;
|
PQExpBufferData command_error;
|
||||||
initPQExpBuffer(&command_error);
|
initPQExpBuffer(&command_error);
|
||||||
|
|
||||||
if (repmgr_node_type == NULL)
|
if (repmgr_node_type == NULL)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&command_error,
|
appendPQExpBuffer(&command_error,
|
||||||
_("no repmgr command provided"));
|
_("no repmgr command provided"));
|
||||||
}
|
}
|
||||||
else if (valid_repmgr_node_type_found == false && repmgr_action[0] == '\0')
|
else if (valid_repmgr_node_type_found == false && repmgr_action[0] == '\0')
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&command_error,
|
appendPQExpBuffer(&command_error,
|
||||||
_("unknown repmgr node type '%s'"),
|
_("unknown repmgr node type '%s'"),
|
||||||
repmgr_node_type);
|
repmgr_node_type);
|
||||||
}
|
}
|
||||||
else if (repmgr_action[0] == '\0')
|
else if (repmgr_action[0] == '\0')
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&command_error,
|
appendPQExpBuffer(&command_error,
|
||||||
_("no action provided for node type '%s'"),
|
_("no action provided for node type '%s'"),
|
||||||
repmgr_node_type);
|
repmgr_node_type);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&command_error,
|
appendPQExpBuffer(&command_error,
|
||||||
_("unknown repmgr action '%s %s'"),
|
_("unknown repmgr action '%s %s'"),
|
||||||
repmgr_node_type,
|
repmgr_node_type,
|
||||||
repmgr_action);
|
repmgr_action);
|
||||||
}
|
}
|
||||||
|
|
||||||
item_list_append(&cli_errors, command_error.data);
|
item_list_append(&cli_errors, command_error.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -297,11 +297,11 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the logger. We've previously requested STDERR logging only
|
* Initialize the logger. We've previously requested STDERR logging only
|
||||||
* to ensure the repmgr command doesn't have its output diverted to a logging
|
* to ensure the repmgr command doesn't have its output diverted to a logging
|
||||||
* facility (which usually doesn't make sense for a command line program).
|
* facility (which usually doesn't make sense for a command line program).
|
||||||
*
|
*
|
||||||
* If required (e.g. when calling repmgr from repmgrd), this behaviour can be
|
* If required (e.g. when calling repmgr from repmgrd), this behaviour can be
|
||||||
* overridden with "--log-to-file".
|
* overridden with "--log-to-file".
|
||||||
*/
|
*/
|
||||||
|
|
||||||
logger_init(&config_file_options, progname());
|
logger_init(&config_file_options, progname());
|
||||||
@@ -380,11 +380,11 @@ print_error_list(ItemList *error_list, int log_level)
|
|||||||
|
|
||||||
for (cell = error_list->head; cell; cell = cell->next)
|
for (cell = error_list->head; cell; cell = cell->next)
|
||||||
{
|
{
|
||||||
fprintf(stderr, " ");
|
fprintf(stderr, " ");
|
||||||
switch(log_level)
|
switch(log_level)
|
||||||
{
|
{
|
||||||
/* Currently we only need errors and warnings */
|
/* Currently we only need errors and warnings */
|
||||||
case LOG_ERROR:
|
case LOG_ERROR:
|
||||||
log_error("%s", cell->string);
|
log_error("%s", cell->string);
|
||||||
break;
|
break;
|
||||||
case LOG_WARNING:
|
case LOG_WARNING:
|
||||||
@@ -399,36 +399,36 @@ static void
|
|||||||
do_help(void)
|
do_help(void)
|
||||||
{
|
{
|
||||||
printf(_("%s: replication management tool for PostgreSQL\n"), progname());
|
printf(_("%s: replication management tool for PostgreSQL\n"), progname());
|
||||||
puts("");
|
puts("");
|
||||||
|
|
||||||
/* add a big friendly warning if root is executing "repmgr --help" */
|
/* add a big friendly warning if root is executing "repmgr --help" */
|
||||||
if (geteuid() == 0)
|
if (geteuid() == 0)
|
||||||
{
|
{
|
||||||
printf(_(" **************************************************\n"));
|
printf(_(" **************************************************\n"));
|
||||||
printf(_(" *** repmgr must be executed by a non-superuser ***\n"));
|
printf(_(" *** repmgr must be executed by a non-superuser ***\n"));
|
||||||
printf(_(" **************************************************\n"));
|
printf(_(" **************************************************\n"));
|
||||||
puts("");
|
puts("");
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(_("Usage:\n"));
|
printf(_("Usage:\n"));
|
||||||
printf(_(" %s [OPTIONS] master register\n"), progname());
|
printf(_(" %s [OPTIONS] master register\n"), progname());
|
||||||
puts("");
|
puts("");
|
||||||
printf(_("General options:\n"));
|
printf(_("General options:\n"));
|
||||||
printf(_(" -?, --help show this help, then exit\n"));
|
printf(_(" -?, --help show this help, then exit\n"));
|
||||||
printf(_(" -V, --version output version information, then exit\n"));
|
printf(_(" -V, --version output version information, then exit\n"));
|
||||||
puts("");
|
puts("");
|
||||||
printf(_("General configuration options:\n"));
|
printf(_("General configuration options:\n"));
|
||||||
printf(_(" -b, --pg_bindir=PATH path to PostgreSQL binaries (optional)\n"));
|
printf(_(" -b, --pg_bindir=PATH path to PostgreSQL binaries (optional)\n"));
|
||||||
printf(_(" -f, --config-file=PATH path to the configuration file\n"));
|
printf(_(" -f, --config-file=PATH path to the configuration file\n"));
|
||||||
printf(_(" -F, --force force potentially dangerous operations to happen\n"));
|
printf(_(" -F, --force force potentially dangerous operations to happen\n"));
|
||||||
puts("");
|
puts("");
|
||||||
printf(_("Logging options:\n"));
|
printf(_("Logging options:\n"));
|
||||||
printf(_(" -L, --log-level set log level (overrides configuration file; default: NOTICE)\n"));
|
printf(_(" -L, --log-level set log level (overrides configuration file; default: NOTICE)\n"));
|
||||||
printf(_(" --log-to-file log to file (or logging facility) defined in repmgr.conf\n"));
|
printf(_(" --log-to-file log to file (or logging facility) defined in repmgr.conf\n"));
|
||||||
printf(_(" -t, --terse don't display hints and other non-critical output\n"));
|
printf(_(" -t, --terse don't display hints and other non-critical output\n"));
|
||||||
printf(_(" -v, --verbose display additional log output (useful for debugging)\n"));
|
printf(_(" -v, --verbose display additional log output (useful for debugging)\n"));
|
||||||
|
|
||||||
puts("");
|
puts("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -506,6 +506,7 @@ do_master_register(void)
|
|||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -519,22 +520,22 @@ bool create_repmgr_extension(PGconn *conn)
|
|||||||
char *current_user;
|
char *current_user;
|
||||||
const char *superuser_status;
|
const char *superuser_status;
|
||||||
bool is_superuser;
|
bool is_superuser;
|
||||||
PGconn *superuser_conn = NULL;
|
PGconn *superuser_conn = NULL;
|
||||||
PGconn *schema_create_conn = NULL;
|
PGconn *schema_create_conn = NULL;
|
||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBuffer(&query,
|
||||||
" SELECT ae.name, e.extname "
|
" SELECT ae.name, e.extname "
|
||||||
" FROM pg_catalog.pg_available_extensions ae "
|
" FROM pg_catalog.pg_available_extensions ae "
|
||||||
"LEFT JOIN pg_catalog.pg_extension e "
|
"LEFT JOIN pg_catalog.pg_extension e "
|
||||||
" ON e.extname=ae.name "
|
" ON e.extname=ae.name "
|
||||||
" WHERE ae.name='repmgr' ");
|
" WHERE ae.name='repmgr' ");
|
||||||
|
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
log_error(_("unable to execute extension query:\n %s"),
|
log_error(_("unable to execute extension query:\n %s"),
|
||||||
PQerrorMessage(conn));
|
PQerrorMessage(conn));
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
@@ -639,7 +640,7 @@ bool create_repmgr_extension(PGconn *conn)
|
|||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
{
|
{
|
||||||
log_error(_("unable to grant usage on \"repmgr\" extension to %s:\n %s"),
|
log_error(_("unable to grant usage on \"repmgr\" extension to %s:\n %s"),
|
||||||
current_user,
|
current_user,
|
||||||
PQerrorMessage(schema_create_conn));
|
PQerrorMessage(schema_create_conn));
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
@@ -666,18 +667,18 @@ bool create_repmgr_extension(PGconn *conn)
|
|||||||
* Verify that the server is MIN_SUPPORTED_VERSION_NUM or later
|
* Verify that the server is MIN_SUPPORTED_VERSION_NUM or later
|
||||||
*
|
*
|
||||||
* PGconn *conn:
|
* PGconn *conn:
|
||||||
* the connection to check
|
* the connection to check
|
||||||
*
|
*
|
||||||
* char *server_type:
|
* char *server_type:
|
||||||
* either "master" or "standby"; used to format error message
|
* either "master" or "standby"; used to format error message
|
||||||
*
|
*
|
||||||
* bool exit_on_error:
|
* bool exit_on_error:
|
||||||
* exit if reported server version is too low; optional to enable some callers
|
* exit if reported server version is too low; optional to enable some callers
|
||||||
* to perform additional cleanup
|
* to perform additional cleanup
|
||||||
*
|
*
|
||||||
* char *server_version_string
|
* char *server_version_string
|
||||||
* passed to get_server_version(), which will place the human-readable
|
* passed to get_server_version(), which will place the human-readable
|
||||||
* server version string there (e.g. "9.4.0")
|
* server version string there (e.g. "9.4.0")
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
check_server_version(PGconn *conn, char *server_type, bool exit_on_error, char *server_version_string)
|
check_server_version(PGconn *conn, char *server_type, bool exit_on_error, char *server_version_string)
|
||||||
|
|||||||
@@ -27,37 +27,37 @@
|
|||||||
#define STANDBY_CLONE 4
|
#define STANDBY_CLONE 4
|
||||||
#define STANDBY_PROMOTE 5
|
#define STANDBY_PROMOTE 5
|
||||||
#define STANDBY_FOLLOW 6
|
#define STANDBY_FOLLOW 6
|
||||||
#define STANDBY_SWITCHOVER 7
|
#define STANDBY_SWITCHOVER 7
|
||||||
#define STANDBY_ARCHIVE_CONFIG 8
|
#define STANDBY_ARCHIVE_CONFIG 8
|
||||||
#define STANDBY_RESTORE_CONFIG 9
|
#define STANDBY_RESTORE_CONFIG 9
|
||||||
#define WITNESS_CREATE 10
|
#define WITNESS_CREATE 10
|
||||||
#define WITNESS_REGISTER 11
|
#define WITNESS_REGISTER 11
|
||||||
#define WITNESS_UNREGISTER 12
|
#define WITNESS_UNREGISTER 12
|
||||||
#define CLUSTER_SHOW 13
|
#define CLUSTER_SHOW 13
|
||||||
#define CLUSTER_CLEANUP 14
|
#define CLUSTER_CLEANUP 14
|
||||||
#define CLUSTER_MATRIX 15
|
#define CLUSTER_MATRIX 15
|
||||||
#define CLUSTER_CROSSCHECK 16
|
#define CLUSTER_CROSSCHECK 16
|
||||||
#define BDR_REGISTER 17
|
#define BDR_REGISTER 17
|
||||||
#define BDR_UNREGISTER 18
|
#define BDR_UNREGISTER 18
|
||||||
|
|
||||||
/* command line options without short versions */
|
/* command line options without short versions */
|
||||||
#define OPT_HELP 1
|
#define OPT_HELP 1
|
||||||
#define OPT_CHECK_UPSTREAM_CONFIG 2
|
#define OPT_CHECK_UPSTREAM_CONFIG 2
|
||||||
#define OPT_RECOVERY_MIN_APPLY_DELAY 3
|
#define OPT_RECOVERY_MIN_APPLY_DELAY 3
|
||||||
#define OPT_COPY_EXTERNAL_CONFIG_FILES 4
|
#define OPT_COPY_EXTERNAL_CONFIG_FILES 4
|
||||||
#define OPT_CONFIG_ARCHIVE_DIR 5
|
#define OPT_CONFIG_ARCHIVE_DIR 5
|
||||||
#define OPT_PG_REWIND 6
|
#define OPT_PG_REWIND 6
|
||||||
#define OPT_PWPROMPT 7
|
#define OPT_PWPROMPT 7
|
||||||
#define OPT_CSV 8
|
#define OPT_CSV 8
|
||||||
#define OPT_NODE 9
|
#define OPT_NODE 9
|
||||||
#define OPT_WITHOUT_BARMAN 10
|
#define OPT_WITHOUT_BARMAN 10
|
||||||
#define OPT_NO_UPSTREAM_CONNECTION 11
|
#define OPT_NO_UPSTREAM_CONNECTION 11
|
||||||
#define OPT_REGISTER_WAIT 12
|
#define OPT_REGISTER_WAIT 12
|
||||||
#define OPT_CLUSTER 13
|
#define OPT_CLUSTER 13
|
||||||
#define OPT_LOG_TO_FILE 14
|
#define OPT_LOG_TO_FILE 14
|
||||||
#define OPT_UPSTREAM_CONNINFO 15
|
#define OPT_UPSTREAM_CONNINFO 15
|
||||||
#define OPT_NO_CONNINFO_PASSWORD 16
|
#define OPT_NO_CONNINFO_PASSWORD 16
|
||||||
#define OPT_REPLICATION_USER 17
|
#define OPT_REPLICATION_USER 17
|
||||||
|
|
||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
{
|
{
|
||||||
@@ -120,7 +120,7 @@ typedef struct
|
|||||||
bool force;
|
bool force;
|
||||||
char pg_bindir[MAXLEN]; /* overrides setting in repmgr.conf */
|
char pg_bindir[MAXLEN]; /* overrides setting in repmgr.conf */
|
||||||
|
|
||||||
/* logging options */
|
/* logging options */
|
||||||
char loglevel[MAXLEN]; /* overrides setting in repmgr.conf */
|
char loglevel[MAXLEN]; /* overrides setting in repmgr.conf */
|
||||||
bool log_to_file;
|
bool log_to_file;
|
||||||
bool terse;
|
bool terse;
|
||||||
@@ -130,7 +130,7 @@ typedef struct
|
|||||||
char superuser[MAXLEN];
|
char superuser[MAXLEN];
|
||||||
|
|
||||||
|
|
||||||
} t_runtime_options;
|
} t_runtime_options;
|
||||||
|
|
||||||
#define T_RUNTIME_OPTIONS_INITIALIZER { \
|
#define T_RUNTIME_OPTIONS_INITIALIZER { \
|
||||||
/* general configuration options */ \
|
/* general configuration options */ \
|
||||||
|
|||||||
8
repmgr.h
8
repmgr.h
@@ -22,14 +22,14 @@
|
|||||||
#define MIN_SUPPORTED_VERSION "9.3"
|
#define MIN_SUPPORTED_VERSION "9.3"
|
||||||
#define MIN_SUPPORTED_VERSION_NUM 90300
|
#define MIN_SUPPORTED_VERSION_NUM 90300
|
||||||
|
|
||||||
#define NODE_NOT_FOUND -1
|
#define NODE_NOT_FOUND -1
|
||||||
#define NO_UPSTREAM_NODE -1
|
#define NO_UPSTREAM_NODE -1
|
||||||
#define UNKNOWN_NODE_ID -1
|
#define UNKNOWN_NODE_ID -1
|
||||||
|
|
||||||
#define REPLICATION_TYPE_PHYSICAL 1
|
#define REPLICATION_TYPE_PHYSICAL 1
|
||||||
#define REPLICATION_TYPE_BDR 2
|
#define REPLICATION_TYPE_BDR 2
|
||||||
|
|
||||||
#define BDR_MONITORING_LOCAL 1
|
#define BDR_MONITORING_LOCAL 1
|
||||||
#define BDR_MONITORING_PRIORITY 2
|
#define BDR_MONITORING_PRIORITY 2
|
||||||
|
|
||||||
#define MANUAL_FAILOVER 0
|
#define MANUAL_FAILOVER 0
|
||||||
|
|||||||
Reference in New Issue
Block a user