mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-25 16:16:29 +00:00
do not exit in guc_setted and guc_setted_typed
This commit is contained in:
30
dbutils.c
30
dbutils.c
@@ -213,12 +213,13 @@ pg_version(PGconn *conn, char* major_version)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
int
|
||||||
guc_setted(PGconn *conn, const char *parameter, const char *op,
|
guc_setted(PGconn *conn, const char *parameter, const char *op,
|
||||||
const char *value)
|
const char *value)
|
||||||
{
|
{
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
char sqlquery[QUERY_STR_LEN];
|
char sqlquery[QUERY_STR_LEN];
|
||||||
|
int retval = 1;
|
||||||
|
|
||||||
sqlquery_snprintf(sqlquery, "SELECT true FROM pg_settings "
|
sqlquery_snprintf(sqlquery, "SELECT true FROM pg_settings "
|
||||||
" WHERE name = '%s' AND setting %s '%s'",
|
" WHERE name = '%s' AND setting %s '%s'",
|
||||||
@@ -229,30 +230,29 @@ guc_setted(PGconn *conn, const char *parameter, const char *op,
|
|||||||
{
|
{
|
||||||
log_err(_("GUC setting check PQexec failed: %s"),
|
log_err(_("GUC setting check PQexec failed: %s"),
|
||||||
PQerrorMessage(conn));
|
PQerrorMessage(conn));
|
||||||
PQclear(res);
|
retval = -1;
|
||||||
PQfinish(conn);
|
|
||||||
exit(ERR_DB_QUERY);
|
|
||||||
}
|
}
|
||||||
if (PQntuples(res) == 0)
|
else if (PQntuples(res) == 0)
|
||||||
{
|
{
|
||||||
PQclear(res);
|
retval = 0;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
return true;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Just like guc_setted except with an extra parameter containing the name of
|
* Just like guc_setted except with an extra parameter containing the name of
|
||||||
* the pg datatype so that the comparison can be done properly.
|
* the pg datatype so that the comparison can be done properly.
|
||||||
*/
|
*/
|
||||||
bool
|
int
|
||||||
guc_setted_typed(PGconn *conn, const char *parameter, const char *op,
|
guc_setted_typed(PGconn *conn, const char *parameter, const char *op,
|
||||||
const char *value, const char *datatype)
|
const char *value, const char *datatype)
|
||||||
{
|
{
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
char sqlquery[QUERY_STR_LEN];
|
char sqlquery[QUERY_STR_LEN];
|
||||||
|
int retval = 1;
|
||||||
|
|
||||||
sqlquery_snprintf(sqlquery, "SELECT true FROM pg_settings "
|
sqlquery_snprintf(sqlquery, "SELECT true FROM pg_settings "
|
||||||
" WHERE name = '%s' AND setting::%s %s '%s'::%s",
|
" WHERE name = '%s' AND setting::%s %s '%s'::%s",
|
||||||
@@ -263,18 +263,16 @@ guc_setted_typed(PGconn *conn, const char *parameter, const char *op,
|
|||||||
{
|
{
|
||||||
log_err(_("GUC setting check PQexec failed: %s"),
|
log_err(_("GUC setting check PQexec failed: %s"),
|
||||||
PQerrorMessage(conn));
|
PQerrorMessage(conn));
|
||||||
PQclear(res);
|
retval = -1;
|
||||||
PQfinish(conn);
|
|
||||||
exit(ERR_DB_QUERY);
|
|
||||||
}
|
}
|
||||||
if (PQntuples(res) == 0)
|
else if (PQntuples(res) == 0)
|
||||||
{
|
{
|
||||||
PQclear(res);
|
retval = 0;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
|
|
||||||
return true;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ int is_standby(PGconn *conn);
|
|||||||
int is_witness(PGconn *conn, char *schema, char *cluster, int node_id);
|
int is_witness(PGconn *conn, char *schema, char *cluster, int node_id);
|
||||||
bool is_pgup(PGconn *conn, int timeout);
|
bool is_pgup(PGconn *conn, int timeout);
|
||||||
char *pg_version(PGconn *conn, char* major_version);
|
char *pg_version(PGconn *conn, char* major_version);
|
||||||
bool guc_setted(PGconn *conn, const char *parameter, const char *op,
|
int guc_setted(PGconn *conn, const char *parameter, const char *op,
|
||||||
const char *value);
|
const char *value);
|
||||||
bool guc_setted_typed(PGconn *conn, const char *parameter, const char *op,
|
int guc_setted_typed(PGconn *conn, const char *parameter, const char *op,
|
||||||
const char *value, const char *datatype);
|
const char *value, const char *datatype);
|
||||||
|
|
||||||
const char *get_cluster_size(PGconn *conn);
|
const char *get_cluster_size(PGconn *conn);
|
||||||
|
|||||||
27
repmgr.c
27
repmgr.c
@@ -853,28 +853,39 @@ do_standby_clone(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* And check if it is well configured */
|
/* And check if it is well configured */
|
||||||
if (!guc_setted(conn, "wal_level", "=", "hot_standby"))
|
i = guc_setted(conn, "wal_level", "=", "hot_standby");
|
||||||
|
if (i == 0 || i == -1)
|
||||||
{
|
{
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
log_err(_("%s needs parameter 'wal_level' to be set to 'hot_standby'\n"), progname);
|
if (i == 0)
|
||||||
|
log_err(_("%s needs parameter 'wal_level' to be set to 'hot_standby'\n"), progname);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
if (!guc_setted_typed(conn, "wal_keep_segments", ">=", runtime_options.wal_keep_segments, "integer"))
|
|
||||||
|
i = guc_setted_typed(conn, "wal_keep_segments", ">=", runtime_options.wal_keep_segments, "integer");
|
||||||
|
if (i == 0 || i == -1)
|
||||||
{
|
{
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
log_err(_("%s needs parameter 'wal_keep_segments' to be set to %s or greater (see the '-w' option or edit the postgresql.conf of the PostgreSQL master.)\n"), progname, runtime_options.wal_keep_segments);
|
if (i == 0)
|
||||||
|
log_err(_("%s needs parameter 'wal_keep_segments' to be set to %s or greater (see the '-w' option or edit the postgresql.conf of the PostgreSQL master.)\n"), progname, runtime_options.wal_keep_segments);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
if (!guc_setted(conn, "archive_mode", "=", "on"))
|
|
||||||
|
i = guc_setted(conn, "archive_mode", "=", "on");
|
||||||
|
if (i == 0 || i == -1)
|
||||||
{
|
{
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
log_err(_("%s needs parameter 'archive_mode' to be set to 'on'\n"), progname);
|
if (i == 0)
|
||||||
|
log_err(_("%s needs parameter 'archive_mode' to be set to 'on'\n"), progname);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
if (!guc_setted(conn, "hot_standby", "=", "on"))
|
|
||||||
|
i = guc_setted(conn, "hot_standby", "=", "on");
|
||||||
|
if (i == 0 || i == -1)
|
||||||
{
|
{
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
log_err(_("%s needs parameter 'hot_standby' to be set to 'on'\n"), progname);
|
if (i == 0)
|
||||||
|
log_err(_("%s needs parameter 'hot_standby' to be set to 'on'\n"), progname);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user