mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
General code cleanup
This commit is contained in:
@@ -903,9 +903,9 @@ repmgr_atoi(const char *value, const char *config_item, ItemList *error_list, in
|
||||
}
|
||||
|
||||
item_list_append(error_list, errors.data);
|
||||
termPQExpBuffer(&errors);
|
||||
}
|
||||
|
||||
termPQExpBuffer(&errors);
|
||||
return (int32) longval;
|
||||
}
|
||||
|
||||
@@ -1247,6 +1247,12 @@ parse_pg_basebackup_options(const char *pg_basebackup_options, t_basebackup_opti
|
||||
}
|
||||
|
||||
pfree(options_string);
|
||||
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < argc_item + 2; i ++)
|
||||
pfree(argv_array[i]);
|
||||
}
|
||||
pfree(argv_array);
|
||||
|
||||
return backup_options_ok;
|
||||
|
||||
60
dbutils.c
60
dbutils.c
@@ -407,9 +407,31 @@ initialize_conninfo_params(t_conninfo_param_list *param_list, bool set_defaults)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PQconninfoFree(defs);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
free_conninfo_params(t_conninfo_param_list *param_list)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c < param_list->size; c++)
|
||||
{
|
||||
if (param_list->keywords[c] != NULL)
|
||||
pfree(param_list->keywords[c]);
|
||||
|
||||
if (param_list->values[c] != NULL)
|
||||
pfree(param_list->values[c]);
|
||||
}
|
||||
|
||||
pfree(param_list->keywords);
|
||||
pfree(param_list->values);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
copy_conninfo_params(t_conninfo_param_list *dest_list, t_conninfo_param_list *source_list)
|
||||
{
|
||||
@@ -591,6 +613,8 @@ conn_to_param_list(PGconn *conn, t_conninfo_param_list *param_list)
|
||||
|
||||
param_set(param_list, option->keyword, option->val);
|
||||
}
|
||||
|
||||
PQconninfoFree(connOptions);
|
||||
}
|
||||
|
||||
|
||||
@@ -737,6 +761,7 @@ bool
|
||||
set_config(PGconn *conn, const char *config_param, const char *config_value)
|
||||
{
|
||||
PQExpBufferData query;
|
||||
bool result;
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
appendPQExpBuffer(&query,
|
||||
@@ -746,13 +771,18 @@ set_config(PGconn *conn, const char *config_param, const char *config_value)
|
||||
|
||||
log_verbose(LOG_DEBUG, "set_config():\n %s", query.data);
|
||||
|
||||
return _set_config(conn, config_param, query.data);
|
||||
result = _set_config(conn, config_param, query.data);
|
||||
|
||||
termPQExpBuffer(&query);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
set_config_bool(PGconn *conn, const char *config_param, bool state)
|
||||
{
|
||||
PQExpBufferData query;
|
||||
bool result;
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
appendPQExpBuffer(&query,
|
||||
@@ -762,7 +792,12 @@ set_config_bool(PGconn *conn, const char *config_param, bool state)
|
||||
|
||||
log_verbose(LOG_DEBUG, "set_config_bool():\n %s", query.data);
|
||||
|
||||
return _set_config(conn, config_param, query.data);
|
||||
|
||||
result = _set_config(conn, config_param, query.data);
|
||||
|
||||
termPQExpBuffer(&query);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1485,6 +1520,7 @@ get_repmgr_extension_status(PGconn *conn)
|
||||
{
|
||||
PQExpBufferData query;
|
||||
PGresult *res;
|
||||
ExtensionStatus status = REPMGR_UNKNOWN;
|
||||
|
||||
/* TODO: check version */
|
||||
|
||||
@@ -1505,24 +1541,28 @@ get_repmgr_extension_status(PGconn *conn)
|
||||
{
|
||||
log_error(_("unable to execute extension query:\n %s"),
|
||||
PQerrorMessage(conn));
|
||||
PQclear(res);
|
||||
|
||||
return REPMGR_UNKNOWN;
|
||||
status = REPMGR_UNKNOWN;
|
||||
}
|
||||
|
||||
/* 1. Check extension is actually available */
|
||||
if (PQntuples(res) == 0)
|
||||
else if (PQntuples(res) == 0)
|
||||
{
|
||||
return REPMGR_UNAVAILABLE;
|
||||
status = REPMGR_UNAVAILABLE;
|
||||
}
|
||||
|
||||
/* 2. Check if extension installed */
|
||||
if (PQgetisnull(res, 0, 1) == 0)
|
||||
else if (PQgetisnull(res, 0, 1) == 0)
|
||||
{
|
||||
return REPMGR_INSTALLED;
|
||||
status = REPMGR_INSTALLED;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = REPMGR_AVAILABLE;
|
||||
}
|
||||
PQclear(res);
|
||||
|
||||
return REPMGR_AVAILABLE;
|
||||
return status;
|
||||
}
|
||||
|
||||
/* ========================= */
|
||||
@@ -2566,6 +2606,8 @@ get_configuration_file_locations(PGconn *conn, t_configfile_list *list)
|
||||
strcmp(PQgetvalue(res, i, 2), "t") == 1 ? true : false);
|
||||
}
|
||||
|
||||
PQclear(res);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -314,6 +314,7 @@ bool is_superuser_connection(PGconn *conn, t_connection_user *userinfo);
|
||||
bool get_conninfo_value(const char *conninfo, const char *keyword, char *output);
|
||||
|
||||
void initialize_conninfo_params(t_conninfo_param_list *param_list, bool set_defaults);
|
||||
void free_conninfo_params(t_conninfo_param_list *param_list);
|
||||
void copy_conninfo_params(t_conninfo_param_list *dest_list, t_conninfo_param_list *source_list);
|
||||
void conn_to_param_list(PGconn *conn, t_conninfo_param_list *param_list);
|
||||
void param_set(t_conninfo_param_list *param_list, const char *param, const char *value);
|
||||
|
||||
@@ -113,7 +113,7 @@ do_node_status(void)
|
||||
replication_conn = establish_db_connection_by_params(&repl_conninfo, false);
|
||||
identify_system(replication_conn, &sysid);
|
||||
|
||||
printf("%s\n", sysid.systemid);
|
||||
printf("%lu\n", sysid.system_identifier);
|
||||
exit(0);
|
||||
|
||||
}
|
||||
|
||||
@@ -2268,6 +2268,9 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error)
|
||||
PQfinish(connections[i]);
|
||||
}
|
||||
|
||||
pfree(connections);
|
||||
free_conninfo_params(&repl_conninfo);
|
||||
|
||||
if (possible_replication_connections < min_replication_connections)
|
||||
{
|
||||
config_ok = false;
|
||||
|
||||
Reference in New Issue
Block a user