mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 17:06:29 +00:00
use appendPQExpBufferStr/-Char() consistently
This commit is contained in:
@@ -88,8 +88,7 @@ load_config(const char *config_file, bool verbose, bool terse, t_configuration_o
|
|||||||
|
|
||||||
if (pwd != NULL)
|
if (pwd != NULL)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&fullpath,
|
appendPQExpBufferStr(&fullpath, pwd);
|
||||||
"%s", pwd);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -105,9 +104,7 @@ load_config(const char *config_file, bool verbose, bool terse, t_configuration_o
|
|||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBuffer(&fullpath,
|
appendPQExpBufferStr(&fullpath, cwd);
|
||||||
"%s",
|
|
||||||
cwd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBuffer(&fullpath,
|
appendPQExpBuffer(&fullpath,
|
||||||
@@ -1111,7 +1108,7 @@ reload_config(t_configuration_options *orig_options, t_server_type server_type)
|
|||||||
|
|
||||||
initPQExpBuffer(&errors);
|
initPQExpBuffer(&errors);
|
||||||
|
|
||||||
appendPQExpBuffer(&errors,
|
appendPQExpBufferStr(&errors,
|
||||||
"following errors were detected:\n");
|
"following errors were detected:\n");
|
||||||
|
|
||||||
for (cell = config_errors.head; cell; cell = cell->next)
|
for (cell = config_errors.head; cell; cell = cell->next)
|
||||||
|
|||||||
90
dbutils.c
90
dbutils.c
@@ -115,20 +115,20 @@ wrap_ddl_query(PQExpBufferData *query_buf, int replication_type, const char *fmt
|
|||||||
if (replication_type == REPLICATION_TYPE_BDR)
|
if (replication_type == REPLICATION_TYPE_BDR)
|
||||||
{
|
{
|
||||||
if (bdr_version_num < 3)
|
if (bdr_version_num < 3)
|
||||||
appendPQExpBuffer(query_buf, "SELECT bdr.bdr_replicate_ddl_command($repmgr$");
|
appendPQExpBufferStr(query_buf, "SELECT bdr.bdr_replicate_ddl_command($repmgr$");
|
||||||
else
|
else
|
||||||
appendPQExpBuffer(query_buf, "SELECT bdr.replicate_ddl_command($repmgr$");
|
appendPQExpBufferStr(query_buf, "SELECT bdr.replicate_ddl_command($repmgr$");
|
||||||
}
|
}
|
||||||
|
|
||||||
va_start(arglist, fmt);
|
va_start(arglist, fmt);
|
||||||
vsnprintf(buf, MAXLEN, fmt, arglist);
|
vsnprintf(buf, MAXLEN, fmt, arglist);
|
||||||
va_end(arglist);
|
va_end(arglist);
|
||||||
|
|
||||||
appendPQExpBuffer(query_buf, "%s", buf);
|
appendPQExpBufferStr(query_buf, buf);
|
||||||
|
|
||||||
if (replication_type == REPLICATION_TYPE_BDR)
|
if (replication_type == REPLICATION_TYPE_BDR)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(query_buf, "$repmgr$)");
|
appendPQExpBufferStr(query_buf, "$repmgr$)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1070,7 +1070,7 @@ get_cluster_size(PGconn *conn, char *size)
|
|||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
"SELECT pg_catalog.pg_size_pretty(pg_catalog.sum(pg_catalog.pg_database_size(oid))::bigint) "
|
"SELECT pg_catalog.pg_size_pretty(pg_catalog.sum(pg_catalog.pg_database_size(oid))::bigint) "
|
||||||
" FROM pg_catalog.pg_database ");
|
" FROM pg_catalog.pg_database ");
|
||||||
|
|
||||||
@@ -1228,7 +1228,7 @@ _get_primary_connection(PGconn *conn,
|
|||||||
log_verbose(LOG_INFO, _("searching for primary node"));
|
log_verbose(LOG_INFO, _("searching for primary node"));
|
||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT node_id, conninfo, "
|
" SELECT node_id, conninfo, "
|
||||||
" CASE WHEN type = 'primary' THEN 1 ELSE 2 END AS type_priority"
|
" CASE WHEN type = 'primary' THEN 1 ELSE 2 END AS type_priority"
|
||||||
" FROM repmgr.nodes "
|
" FROM repmgr.nodes "
|
||||||
@@ -1341,7 +1341,7 @@ get_primary_node_id(PGconn *conn)
|
|||||||
int retval = NODE_NOT_FOUND;
|
int retval = NODE_NOT_FOUND;
|
||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
"SELECT node_id "
|
"SELECT node_id "
|
||||||
" FROM repmgr.nodes "
|
" FROM repmgr.nodes "
|
||||||
" WHERE type = 'primary' "
|
" WHERE type = 'primary' "
|
||||||
@@ -1384,7 +1384,7 @@ get_replication_info(PGconn *conn, ReplInfo *replication_info)
|
|||||||
server_version_num = get_server_version(conn, NULL);
|
server_version_num = get_server_version(conn, NULL);
|
||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT ts, "
|
" SELECT ts, "
|
||||||
" last_wal_receive_lsn, "
|
" last_wal_receive_lsn, "
|
||||||
" last_wal_replay_lsn, "
|
" last_wal_replay_lsn, "
|
||||||
@@ -1399,7 +1399,7 @@ get_replication_info(PGconn *conn, ReplInfo *replication_info)
|
|||||||
|
|
||||||
if (server_version_num >= 100000)
|
if (server_version_num >= 100000)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT CURRENT_TIMESTAMP AS ts, "
|
" SELECT CURRENT_TIMESTAMP AS ts, "
|
||||||
" pg_catalog.pg_last_wal_receive_lsn() AS last_wal_receive_lsn, "
|
" pg_catalog.pg_last_wal_receive_lsn() AS last_wal_receive_lsn, "
|
||||||
" pg_catalog.pg_last_wal_replay_lsn() AS last_wal_replay_lsn, "
|
" pg_catalog.pg_last_wal_replay_lsn() AS last_wal_replay_lsn, "
|
||||||
@@ -1407,14 +1407,14 @@ get_replication_info(PGconn *conn, ReplInfo *replication_info)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT CURRENT_TIMESTAMP AS ts, "
|
" SELECT CURRENT_TIMESTAMP AS ts, "
|
||||||
" pg_catalog.pg_last_xlog_receive_location() AS last_wal_receive_lsn, "
|
" pg_catalog.pg_last_xlog_receive_location() AS last_wal_receive_lsn, "
|
||||||
" pg_catalog.pg_last_xlog_replay_location() AS last_wal_replay_lsn, "
|
" pg_catalog.pg_last_xlog_replay_location() AS last_wal_replay_lsn, "
|
||||||
" pg_catalog.pg_last_xact_replay_timestamp() AS last_xact_replay_timestamp ");
|
" pg_catalog.pg_last_xact_replay_timestamp() AS last_xact_replay_timestamp ");
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" ) q ");
|
" ) q ");
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "get_replication_info():\n%s", query.data);
|
log_verbose(LOG_DEBUG, "get_replication_info():\n%s", query.data);
|
||||||
@@ -1538,17 +1538,17 @@ get_replication_lag_seconds(PGconn *conn)
|
|||||||
|
|
||||||
if (server_version_num >= 100000)
|
if (server_version_num >= 100000)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT CASE WHEN (pg_catalog.pg_last_wal_receive_lsn() = pg_catalog.pg_last_wal_replay_lsn()) ");
|
" SELECT CASE WHEN (pg_catalog.pg_last_wal_receive_lsn() = pg_catalog.pg_last_wal_replay_lsn()) ");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT CASE WHEN (pg_catalog.pg_last_xlog_receive_location() = pg_catalog.pg_last_xlog_replay_location()) ");
|
" SELECT CASE WHEN (pg_catalog.pg_last_xlog_receive_location() = pg_catalog.pg_last_xlog_replay_location()) ");
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" THEN 0 "
|
" THEN 0 "
|
||||||
" ELSE EXTRACT(epoch FROM (pg_catalog.clock_timestamp() - pg_catalog.pg_last_xact_replay_timestamp()))::INT "
|
" ELSE EXTRACT(epoch FROM (pg_catalog.clock_timestamp() - pg_catalog.pg_last_xact_replay_timestamp()))::INT "
|
||||||
" END "
|
" END "
|
||||||
@@ -1842,7 +1842,7 @@ get_repmgr_extension_status(PGconn *conn)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&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 "
|
||||||
@@ -2234,7 +2234,7 @@ get_all_node_records(PGconn *conn, NodeInfoList *node_list)
|
|||||||
bool success = true;
|
bool success = true;
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT " REPMGR_NODES_COLUMNS
|
" SELECT " REPMGR_NODES_COLUMNS
|
||||||
" FROM repmgr.nodes n "
|
" FROM repmgr.nodes n "
|
||||||
"ORDER BY n.node_id ");
|
"ORDER BY n.node_id ");
|
||||||
@@ -2340,7 +2340,7 @@ get_node_records_by_priority(PGconn *conn, NodeInfoList *node_list)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT " REPMGR_NODES_COLUMNS
|
" SELECT " REPMGR_NODES_COLUMNS
|
||||||
" FROM repmgr.nodes n "
|
" FROM repmgr.nodes n "
|
||||||
"ORDER BY n.priority DESC, n.node_name ");
|
"ORDER BY n.priority DESC, n.node_name ");
|
||||||
@@ -2377,7 +2377,7 @@ get_all_node_records_with_upstream(PGconn *conn, NodeInfoList *node_list)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT n.node_id, n.type, n.upstream_node_id, n.node_name, n.conninfo, n.repluser, "
|
" SELECT n.node_id, n.type, n.upstream_node_id, n.node_name, n.conninfo, n.repluser, "
|
||||||
" n.slot_name, n.location, n.priority, n.active, n.config_file, un.node_name AS upstream_node_name "
|
" n.slot_name, n.location, n.priority, n.active, n.config_file, un.node_name AS upstream_node_name "
|
||||||
" FROM repmgr.nodes n "
|
" FROM repmgr.nodes n "
|
||||||
@@ -2526,7 +2526,7 @@ _create_update_node_record(PGconn *conn, char *action, t_node_info *node_info)
|
|||||||
|
|
||||||
if (strcmp(action, "create") == 0)
|
if (strcmp(action, "create") == 0)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
"INSERT INTO repmgr.nodes "
|
"INSERT INTO repmgr.nodes "
|
||||||
" (node_id, type, upstream_node_id, "
|
" (node_id, type, upstream_node_id, "
|
||||||
" node_name, conninfo, repluser, slot_name, "
|
" node_name, conninfo, repluser, slot_name, "
|
||||||
@@ -2535,7 +2535,7 @@ _create_update_node_record(PGconn *conn, char *action, t_node_info *node_info)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
"UPDATE repmgr.nodes SET "
|
"UPDATE repmgr.nodes SET "
|
||||||
" type = $1, "
|
" type = $1, "
|
||||||
" upstream_node_id = $2, "
|
" upstream_node_id = $2, "
|
||||||
@@ -2550,7 +2550,6 @@ _create_update_node_record(PGconn *conn, char *action, t_node_info *node_info)
|
|||||||
" WHERE node_id = $11 ");
|
" WHERE node_id = $11 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
res = PQexecParams(conn,
|
res = PQexecParams(conn,
|
||||||
query.data,
|
query.data,
|
||||||
param_count,
|
param_count,
|
||||||
@@ -2987,14 +2986,14 @@ get_node_replication_stats(PGconn *conn, int server_version_num, t_node_info *no
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT pg_catalog.current_setting('max_wal_senders')::INT AS max_wal_senders, "
|
" SELECT pg_catalog.current_setting('max_wal_senders')::INT AS max_wal_senders, "
|
||||||
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_stat_replication) AS attached_wal_receivers, ");
|
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_stat_replication) AS attached_wal_receivers, ");
|
||||||
|
|
||||||
/* no replication slots in PostgreSQL 9.3 */
|
/* no replication slots in PostgreSQL 9.3 */
|
||||||
if (server_version_num < 90400)
|
if (server_version_num < 90400)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" 0 AS max_replication_slots, "
|
" 0 AS max_replication_slots, "
|
||||||
" 0 AS total_replication_slots, "
|
" 0 AS total_replication_slots, "
|
||||||
" 0 AS active_replication_slots, "
|
" 0 AS active_replication_slots, "
|
||||||
@@ -3002,7 +3001,7 @@ get_node_replication_stats(PGconn *conn, int server_version_num, t_node_info *no
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" current_setting('max_replication_slots')::INT AS max_replication_slots, "
|
" current_setting('max_replication_slots')::INT AS max_replication_slots, "
|
||||||
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_replication_slots) AS total_replication_slots, "
|
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_replication_slots) AS total_replication_slots, "
|
||||||
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_replication_slots WHERE active IS TRUE) AS active_replication_slots, "
|
" (SELECT pg_catalog.count(*) FROM pg_catalog.pg_replication_slots WHERE active IS TRUE) AS active_replication_slots, "
|
||||||
@@ -3010,7 +3009,7 @@ get_node_replication_stats(PGconn *conn, int server_version_num, t_node_info *no
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" pg_catalog.pg_is_in_recovery() AS in_recovery");
|
" pg_catalog.pg_is_in_recovery() AS in_recovery");
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "get_node_replication_stats():\n%s", query.data);
|
log_verbose(LOG_DEBUG, "get_node_replication_stats():\n%s", query.data);
|
||||||
@@ -3152,7 +3151,7 @@ get_datadir_configuration_files(PGconn *conn, KeyValueList *list)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
"WITH files AS ( "
|
"WITH files AS ( "
|
||||||
" WITH dd AS ( "
|
" WITH dd AS ( "
|
||||||
" SELECT setting "
|
" SELECT setting "
|
||||||
@@ -3208,7 +3207,7 @@ get_configuration_file_locations(PGconn *conn, t_configfile_list *list)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" WITH dd AS ( "
|
" WITH dd AS ( "
|
||||||
" SELECT setting AS data_directory"
|
" SELECT setting AS data_directory"
|
||||||
" FROM pg_catalog.pg_settings "
|
" FROM pg_catalog.pg_settings "
|
||||||
@@ -3258,7 +3257,7 @@ get_configuration_file_locations(PGconn *conn, t_configfile_list *list)
|
|||||||
/* Fetch locations of pg_hba.conf and pg_ident.conf */
|
/* Fetch locations of pg_hba.conf and pg_ident.conf */
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" WITH dd AS ( "
|
" WITH dd AS ( "
|
||||||
" SELECT setting AS data_directory"
|
" SELECT setting AS data_directory"
|
||||||
" FROM pg_catalog.pg_settings "
|
" FROM pg_catalog.pg_settings "
|
||||||
@@ -3271,7 +3270,6 @@ get_configuration_file_locations(PGconn *conn, t_configfile_list *list)
|
|||||||
" WHERE ps.name IN ('hba_file', 'ident_file') "
|
" WHERE ps.name IN ('hba_file', 'ident_file') "
|
||||||
" ORDER BY 1 ");
|
" ORDER BY 1 ");
|
||||||
|
|
||||||
|
|
||||||
log_verbose(LOG_DEBUG, "get_configuration_file_locations():\n %s",
|
log_verbose(LOG_DEBUG, "get_configuration_file_locations():\n %s",
|
||||||
query.data);
|
query.data);
|
||||||
|
|
||||||
@@ -3444,7 +3442,7 @@ _create_event(PGconn *conn, t_configuration_options *options, int node_id, char
|
|||||||
int binary[4] = {1, 0, 0, 0};
|
int binary[4] = {1, 0, 0, 0};
|
||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" INSERT INTO repmgr.events ( "
|
" INSERT INTO repmgr.events ( "
|
||||||
" node_id, "
|
" node_id, "
|
||||||
" event, "
|
" event, "
|
||||||
@@ -3683,7 +3681,7 @@ get_event_records(PGconn *conn, int node_id, const char *node_name, const char *
|
|||||||
initPQExpBuffer(&where_clause);
|
initPQExpBuffer(&where_clause);
|
||||||
|
|
||||||
/* LEFT JOIN used here as a node record may have been removed */
|
/* LEFT JOIN used here as a node record may have been removed */
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT e.node_id, n.node_name, e.event, e.successful, "
|
" SELECT e.node_id, n.node_name, e.event, e.successful, "
|
||||||
" pg_catalog.to_char(e.event_timestamp, 'YYYY-MM-DD HH24:MI:SS') AS timestamp, "
|
" pg_catalog.to_char(e.event_timestamp, 'YYYY-MM-DD HH24:MI:SS') AS timestamp, "
|
||||||
" e.details "
|
" e.details "
|
||||||
@@ -3734,7 +3732,7 @@ get_event_records(PGconn *conn, int node_id, const char *node_name, const char *
|
|||||||
appendPQExpBuffer(&query, "\n%s\n",
|
appendPQExpBuffer(&query, "\n%s\n",
|
||||||
where_clause.data);
|
where_clause.data);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" ORDER BY e.event_timestamp DESC");
|
" ORDER BY e.event_timestamp DESC");
|
||||||
|
|
||||||
if (all == false && limit > 0)
|
if (all == false && limit > 0)
|
||||||
@@ -3937,7 +3935,7 @@ get_free_replication_slot_count(PGconn *conn)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT pg_catalog.current_setting('max_replication_slots')::INT - "
|
" SELECT pg_catalog.current_setting('max_replication_slots')::INT - "
|
||||||
" pg_catalog.count(*) AS free_slots"
|
" pg_catalog.count(*) AS free_slots"
|
||||||
" FROM pg_catalog.pg_replication_slots");
|
" FROM pg_catalog.pg_replication_slots");
|
||||||
@@ -3976,7 +3974,7 @@ get_inactive_replication_slots(PGconn *conn, KeyValueList *list)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT slot_name, slot_type "
|
" SELECT slot_name, slot_type "
|
||||||
" FROM pg_catalog.pg_replication_slots "
|
" FROM pg_catalog.pg_replication_slots "
|
||||||
" WHERE active IS FALSE "
|
" WHERE active IS FALSE "
|
||||||
@@ -4360,7 +4358,7 @@ delete_monitoring_records(PGconn *primary_conn, int keep_history, int node_id)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
"TRUNCATE TABLE repmgr.monitoring_history");
|
"TRUNCATE TABLE repmgr.monitoring_history");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4636,7 +4634,7 @@ _is_bdr_db(PGconn *conn, PQExpBufferData *output, bool quiet)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT (pg_catalog.regexp_matches(extversion, '^\\d+'))[1] AS major_version "
|
" SELECT (pg_catalog.regexp_matches(extversion, '^\\d+'))[1] AS major_version "
|
||||||
" FROM pg_catalog.pg_extension "
|
" FROM pg_catalog.pg_extension "
|
||||||
" WHERE extname = 'bdr' ");
|
" WHERE extname = 'bdr' ");
|
||||||
@@ -4664,7 +4662,7 @@ _is_bdr_db(PGconn *conn, PQExpBufferData *output, bool quiet)
|
|||||||
const char *warning = _("BDR extension is not available for this database");
|
const char *warning = _("BDR extension is not available for this database");
|
||||||
|
|
||||||
if (output != NULL)
|
if (output != NULL)
|
||||||
appendPQExpBuffer(output, "%s", warning);
|
appendPQExpBufferStr(output, warning);
|
||||||
else if (quiet == false)
|
else if (quiet == false)
|
||||||
log_warning("%s", warning);
|
log_warning("%s", warning);
|
||||||
|
|
||||||
@@ -4675,7 +4673,7 @@ _is_bdr_db(PGconn *conn, PQExpBufferData *output, bool quiet)
|
|||||||
{
|
{
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
"SELECT bdr.bdr_is_active_in_db()");
|
"SELECT bdr.bdr_is_active_in_db()");
|
||||||
res = PQexec(conn, query.data);
|
res = PQexec(conn, query.data);
|
||||||
termPQExpBuffer(&query);
|
termPQExpBuffer(&query);
|
||||||
@@ -4687,7 +4685,7 @@ _is_bdr_db(PGconn *conn, PQExpBufferData *output, bool quiet)
|
|||||||
const char *warning = _("BDR extension available for this database, but the database is not configured for BDR");
|
const char *warning = _("BDR extension available for this database, but the database is not configured for BDR");
|
||||||
|
|
||||||
if (output != NULL)
|
if (output != NULL)
|
||||||
appendPQExpBuffer(output, "%s", warning);
|
appendPQExpBufferStr(output, warning);
|
||||||
else if (quiet == false)
|
else if (quiet == false)
|
||||||
log_warning("%s", warning);
|
log_warning("%s", warning);
|
||||||
}
|
}
|
||||||
@@ -4782,7 +4780,7 @@ is_bdr_repmgr(PGconn *conn)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
"SELECT pg_catalog.count(*)"
|
"SELECT pg_catalog.count(*)"
|
||||||
" FROM repmgr.nodes n"
|
" FROM repmgr.nodes n"
|
||||||
" WHERE n.type != 'bdr' ");
|
" WHERE n.type != 'bdr' ");
|
||||||
@@ -4830,7 +4828,7 @@ get_default_bdr_replication_set(PGconn *conn)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT rs.set_name "
|
" SELECT rs.set_name "
|
||||||
" FROM pglogical.replication_set rs "
|
" FROM pglogical.replication_set rs "
|
||||||
" INNER JOIN bdr.node_group ng "
|
" INNER JOIN bdr.node_group ng "
|
||||||
@@ -4969,12 +4967,12 @@ bdr_node_name_matches(PGconn *conn, const char *node_name, PQExpBufferData *bdr_
|
|||||||
|
|
||||||
if (bdr_version_num < 3)
|
if (bdr_version_num < 3)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
"SELECT bdr.bdr_get_local_node_name() AS node_name");
|
"SELECT bdr.bdr_get_local_node_name() AS node_name");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
"SELECT node_name FROM bdr.local_node_info()");
|
"SELECT node_name FROM bdr.local_node_info()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5098,7 +5096,7 @@ add_extension_tables_to_bdr_replication_set(PGconn *conn)
|
|||||||
|
|
||||||
initPQExpBuffer(&query);
|
initPQExpBuffer(&query);
|
||||||
|
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT c.relname "
|
" SELECT c.relname "
|
||||||
" FROM pg_class c "
|
" FROM pg_class c "
|
||||||
"INNER JOIN pg_namespace n "
|
"INNER JOIN pg_namespace n "
|
||||||
@@ -5140,14 +5138,14 @@ get_all_bdr_node_records(PGconn *conn, BdrNodeInfoList *node_list)
|
|||||||
|
|
||||||
if (bdr_version_num < 3)
|
if (bdr_version_num < 3)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT " BDR2_NODES_COLUMNS
|
" SELECT " BDR2_NODES_COLUMNS
|
||||||
" FROM bdr.bdr_nodes "
|
" FROM bdr.bdr_nodes "
|
||||||
"ORDER BY node_seq_id ");
|
"ORDER BY node_seq_id ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&query,
|
appendPQExpBufferStr(&query,
|
||||||
" SELECT " BDR3_NODES_COLUMNS
|
" SELECT " BDR3_NODES_COLUMNS
|
||||||
" FROM bdr.node_summary ns "
|
" FROM bdr.node_summary ns "
|
||||||
" ORDER BY node_name");
|
" ORDER BY node_name");
|
||||||
|
|||||||
@@ -174,16 +174,16 @@ do_cluster_show(void)
|
|||||||
switch (cell->node_info->recovery_type)
|
switch (cell->node_info->recovery_type)
|
||||||
{
|
{
|
||||||
case RECTYPE_PRIMARY:
|
case RECTYPE_PRIMARY:
|
||||||
appendPQExpBuffer(&details, "* running");
|
appendPQExpBufferStr(&details, "* running");
|
||||||
break;
|
break;
|
||||||
case RECTYPE_STANDBY:
|
case RECTYPE_STANDBY:
|
||||||
appendPQExpBuffer(&details, "! running as standby");
|
appendPQExpBufferStr(&details, "! running as standby");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) is registered as primary but running as standby",
|
"node \"%s\" (ID: %i) is registered as primary but running as standby",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
break;
|
break;
|
||||||
case RECTYPE_UNKNOWN:
|
case RECTYPE_UNKNOWN:
|
||||||
appendPQExpBuffer(&details, "! unknown");
|
appendPQExpBufferStr(&details, "! unknown");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) has unknown replication status",
|
"node \"%s\" (ID: %i) has unknown replication status",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
@@ -194,14 +194,14 @@ do_cluster_show(void)
|
|||||||
{
|
{
|
||||||
if (cell->node_info->recovery_type == RECTYPE_PRIMARY)
|
if (cell->node_info->recovery_type == RECTYPE_PRIMARY)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&details, "! running");
|
appendPQExpBufferStr(&details, "! running");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) is running but the repmgr node record is inactive",
|
"node \"%s\" (ID: %i) is running but the repmgr node record is inactive",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&details, "! running as standby");
|
appendPQExpBufferStr(&details, "! running as standby");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) is registered as an inactive primary but running as standby",
|
"node \"%s\" (ID: %i) is registered as an inactive primary but running as standby",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
@@ -214,7 +214,7 @@ do_cluster_show(void)
|
|||||||
/* node is unreachable but marked active */
|
/* node is unreachable but marked active */
|
||||||
if (cell->node_info->active == true)
|
if (cell->node_info->active == true)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&details, "? unreachable");
|
appendPQExpBufferStr(&details, "? unreachable");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) is registered as an active primary but is unreachable",
|
"node \"%s\" (ID: %i) is registered as an active primary but is unreachable",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
@@ -222,7 +222,7 @@ do_cluster_show(void)
|
|||||||
/* node is unreachable and marked as inactive */
|
/* node is unreachable and marked as inactive */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&details, "- failed");
|
appendPQExpBufferStr(&details, "- failed");
|
||||||
error_found = true;
|
error_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -238,16 +238,16 @@ do_cluster_show(void)
|
|||||||
switch (cell->node_info->recovery_type)
|
switch (cell->node_info->recovery_type)
|
||||||
{
|
{
|
||||||
case RECTYPE_STANDBY:
|
case RECTYPE_STANDBY:
|
||||||
appendPQExpBuffer(&details, " running");
|
appendPQExpBufferStr(&details, " running");
|
||||||
break;
|
break;
|
||||||
case RECTYPE_PRIMARY:
|
case RECTYPE_PRIMARY:
|
||||||
appendPQExpBuffer(&details, "! running as primary");
|
appendPQExpBufferStr(&details, "! running as primary");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) is registered as standby but running as primary",
|
"node \"%s\" (ID: %i) is registered as standby but running as primary",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
break;
|
break;
|
||||||
case RECTYPE_UNKNOWN:
|
case RECTYPE_UNKNOWN:
|
||||||
appendPQExpBuffer(&details, "! unknown");
|
appendPQExpBufferStr(&details, "! unknown");
|
||||||
item_list_append_format(
|
item_list_append_format(
|
||||||
&warnings,
|
&warnings,
|
||||||
"node \"%s\" (ID: %i) has unknown replication status",
|
"node \"%s\" (ID: %i) has unknown replication status",
|
||||||
@@ -259,14 +259,14 @@ do_cluster_show(void)
|
|||||||
{
|
{
|
||||||
if (cell->node_info->recovery_type == RECTYPE_STANDBY)
|
if (cell->node_info->recovery_type == RECTYPE_STANDBY)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&details, "! running");
|
appendPQExpBufferStr(&details, "! running");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) is running but the repmgr node record is inactive",
|
"node \"%s\" (ID: %i) is running but the repmgr node record is inactive",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&details, "! running as primary");
|
appendPQExpBufferStr(&details, "! running as primary");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) is running as primary but the repmgr node record is inactive",
|
"node \"%s\" (ID: %i) is running as primary but the repmgr node record is inactive",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
@@ -279,14 +279,14 @@ do_cluster_show(void)
|
|||||||
/* node is unreachable but marked active */
|
/* node is unreachable but marked active */
|
||||||
if (cell->node_info->active == true)
|
if (cell->node_info->active == true)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&details, "? unreachable");
|
appendPQExpBufferStr(&details, "? unreachable");
|
||||||
item_list_append_format(&warnings,
|
item_list_append_format(&warnings,
|
||||||
"node \"%s\" (ID: %i) is registered as an active standby but is unreachable",
|
"node \"%s\" (ID: %i) is registered as an active standby but is unreachable",
|
||||||
cell->node_info->node_name, cell->node_info->node_id);
|
cell->node_info->node_name, cell->node_info->node_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&details, "- failed");
|
appendPQExpBufferStr(&details, "- failed");
|
||||||
error_found = true;
|
error_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,11 +300,11 @@ do_cluster_show(void)
|
|||||||
{
|
{
|
||||||
if (cell->node_info->active == true)
|
if (cell->node_info->active == true)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&details, "* running");
|
appendPQExpBufferStr(&details, "* running");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&details, "! running");
|
appendPQExpBufferStr(&details, "! running");
|
||||||
error_found = true;
|
error_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,11 +313,11 @@ do_cluster_show(void)
|
|||||||
{
|
{
|
||||||
if (cell->node_info->active == true)
|
if (cell->node_info->active == true)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&details, "? unreachable");
|
appendPQExpBufferStr(&details, "? unreachable");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&details, "- failed");
|
appendPQExpBufferStr(&details, "- failed");
|
||||||
error_found = true;
|
error_found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -326,7 +326,7 @@ do_cluster_show(void)
|
|||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
{
|
{
|
||||||
/* this should never happen */
|
/* this should never happen */
|
||||||
appendPQExpBuffer(&details, "? unknown node type");
|
appendPQExpBufferStr(&details, "? unknown node type");
|
||||||
error_found = true;
|
error_found = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1410,7 +1410,7 @@ do_cluster_cleanup(void)
|
|||||||
|
|
||||||
if (delete_monitoring_records(primary_conn, runtime_options.keep_history, runtime_options.node_id) == false)
|
if (delete_monitoring_records(primary_conn, runtime_options.keep_history, runtime_options.node_id) == false)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&event_details,
|
appendPQExpBufferStr(&event_details,
|
||||||
_("unable to delete monitoring records"));
|
_("unable to delete monitoring records"));
|
||||||
|
|
||||||
log_error("%s", event_details.data);
|
log_error("%s", event_details.data);
|
||||||
@@ -1436,12 +1436,12 @@ do_cluster_cleanup(void)
|
|||||||
|
|
||||||
if (runtime_options.keep_history == 0)
|
if (runtime_options.keep_history == 0)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&event_details,
|
appendPQExpBufferStr(&event_details,
|
||||||
_("all monitoring records deleted"));
|
_("all monitoring records deleted"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&event_details,
|
appendPQExpBufferStr(&event_details,
|
||||||
_("monitoring records deleted"));
|
_("monitoring records deleted"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ do_primary_register(void)
|
|||||||
&node_info);
|
&node_info);
|
||||||
if (record_created == true)
|
if (record_created == true)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&event_description,
|
appendPQExpBufferStr(&event_description,
|
||||||
"existing primary record updated");
|
"existing primary record updated");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ monitor_streaming_primary(void)
|
|||||||
|
|
||||||
initPQExpBuffer(&event_details);
|
initPQExpBuffer(&event_details);
|
||||||
|
|
||||||
appendPQExpBuffer(&event_details,
|
appendPQExpBufferStr(&event_details,
|
||||||
_("unable to connect to local node"));
|
_("unable to connect to local node"));
|
||||||
|
|
||||||
log_warning("%s", event_details.data);
|
log_warning("%s", event_details.data);
|
||||||
@@ -951,8 +951,8 @@ monitor_streaming_standby(void)
|
|||||||
degraded_monitoring_elapsed);
|
degraded_monitoring_elapsed);
|
||||||
|
|
||||||
initPQExpBuffer(&event_details);
|
initPQExpBuffer(&event_details);
|
||||||
appendPQExpBuffer(&event_details,
|
appendPQExpBufferStr(&event_details,
|
||||||
"promotion command failed but promotion completed successfully");
|
_("promotion command failed but promotion completed successfully"));
|
||||||
create_event_notification(local_conn,
|
create_event_notification(local_conn,
|
||||||
&config_file_options,
|
&config_file_options,
|
||||||
local_node_info.node_id,
|
local_node_info.node_id,
|
||||||
@@ -1069,7 +1069,7 @@ loop:
|
|||||||
|
|
||||||
if (config_file_options.failover == FAILOVER_MANUAL)
|
if (config_file_options.failover == FAILOVER_MANUAL)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(&monitoring_summary,
|
appendPQExpBufferStr(&monitoring_summary,
|
||||||
_(" (automatic failover disabled)"));
|
_(" (automatic failover disabled)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2509,7 +2509,7 @@ follow_new_primary(int new_primary_id)
|
|||||||
if (upstream_recovery_type == RECTYPE_PRIMARY)
|
if (upstream_recovery_type == RECTYPE_PRIMARY)
|
||||||
{
|
{
|
||||||
initPQExpBuffer(&event_details);
|
initPQExpBuffer(&event_details);
|
||||||
appendPQExpBuffer(&event_details,
|
appendPQExpBufferStr(&event_details,
|
||||||
_("original primary reappeared - no action taken"));
|
_("original primary reappeared - no action taken"));
|
||||||
|
|
||||||
log_notice("%s", event_details.data);
|
log_notice("%s", event_details.data);
|
||||||
|
|||||||
@@ -87,17 +87,17 @@ append_where_clause(PQExpBufferData *where_clause, const char *format,...)
|
|||||||
|
|
||||||
if (where_clause->data[0] == '\0')
|
if (where_clause->data[0] == '\0')
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(where_clause,
|
appendPQExpBufferStr(where_clause,
|
||||||
" WHERE ");
|
" WHERE ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(where_clause,
|
appendPQExpBufferStr(where_clause,
|
||||||
" AND ");
|
" AND ");
|
||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBuffer(where_clause,
|
appendPQExpBufferStr(where_clause,
|
||||||
"%s", stringbuf);
|
stringbuf);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user