mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +00:00
do not exit in pg_version
This commit is contained in:
@@ -192,8 +192,7 @@ pg_version(PGconn *conn, char* major_version)
|
|||||||
log_err(_("Version check PQexec failed: %s"),
|
log_err(_("Version check PQexec failed: %s"),
|
||||||
PQerrorMessage(conn));
|
PQerrorMessage(conn));
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
PQfinish(conn);
|
return NULL;
|
||||||
exit(ERR_DB_QUERY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
major_version1 = atoi(PQgetvalue(res, 0, 0));
|
major_version1 = atoi(PQgetvalue(res, 0, 0));
|
||||||
|
|||||||
68
repmgr.c
68
repmgr.c
@@ -486,7 +486,7 @@ do_master_register(void)
|
|||||||
{
|
{
|
||||||
PGconn *conn;
|
PGconn *conn;
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
char sqlquery[QUERY_STR_LEN];
|
char sqlquery[QUERY_STR_LEN], *ret_ver;
|
||||||
|
|
||||||
bool schema_exists = false;
|
bool schema_exists = false;
|
||||||
char schema_quoted[MAXLEN];
|
char schema_quoted[MAXLEN];
|
||||||
@@ -497,11 +497,12 @@ do_master_register(void)
|
|||||||
|
|
||||||
/* master should be v9 or better */
|
/* master should be v9 or better */
|
||||||
log_info(_("%s connecting to master database\n"), progname);
|
log_info(_("%s connecting to master database\n"), progname);
|
||||||
pg_version(conn, master_version);
|
ret_ver = pg_version(conn, master_version);
|
||||||
if (strcmp(master_version, "") == 0)
|
if (ret_ver == NULL || strcmp(master_version, "") == 0)
|
||||||
{
|
{
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
log_err( _("%s needs master to be PostgreSQL 9.0 or better\n"), progname);
|
if (ret_ver != NULL)
|
||||||
|
log_err( _("%s needs master to be PostgreSQL 9.0 or better\n"), progname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -628,7 +629,7 @@ do_standby_register(void)
|
|||||||
int master_id, ret;
|
int master_id, ret;
|
||||||
|
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
char sqlquery[QUERY_STR_LEN];
|
char sqlquery[QUERY_STR_LEN], *ret_ver;
|
||||||
char schema_quoted[MAXLEN];
|
char schema_quoted[MAXLEN];
|
||||||
|
|
||||||
char master_version[MAXVERSIONSTR];
|
char master_version[MAXVERSIONSTR];
|
||||||
@@ -641,11 +642,12 @@ do_standby_register(void)
|
|||||||
|
|
||||||
/* should be v9 or better */
|
/* should be v9 or better */
|
||||||
log_info(_("%s connected to standby, checking its state\n"), progname);
|
log_info(_("%s connected to standby, checking its state\n"), progname);
|
||||||
pg_version(conn, standby_version);
|
ret_ver = pg_version(conn, standby_version);
|
||||||
if (strcmp(standby_version, "") == 0)
|
if (ret_ver == NULL || strcmp(standby_version, "") == 0)
|
||||||
{
|
{
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
log_err(_("%s needs standby to be PostgreSQL 9.0 or better\n"), progname);
|
if (ret_ver != NULL)
|
||||||
|
log_err(_("%s needs standby to be PostgreSQL 9.0 or better\n"), progname);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -706,12 +708,13 @@ do_standby_register(void)
|
|||||||
|
|
||||||
/* master should be v9 or better */
|
/* master should be v9 or better */
|
||||||
log_info(_("%s connected to master, checking its state\n"), progname);
|
log_info(_("%s connected to master, checking its state\n"), progname);
|
||||||
pg_version(master_conn, master_version);
|
ret_ver = pg_version(master_conn, master_version);
|
||||||
if (strcmp(master_version, "") == 0)
|
if (ret_ver == NULL || strcmp(master_version, "") == 0)
|
||||||
{
|
{
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
PQfinish(master_conn);
|
PQfinish(master_conn);
|
||||||
log_err(_("%s needs master to be PostgreSQL 9.0 or better\n"), progname);
|
if (ret_ver != NULL)
|
||||||
|
log_err(_("%s needs master to be PostgreSQL 9.0 or better\n"), progname);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -775,7 +778,7 @@ do_standby_clone(void)
|
|||||||
{
|
{
|
||||||
PGconn *conn;
|
PGconn *conn;
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
char sqlquery[QUERY_STR_LEN];
|
char sqlquery[QUERY_STR_LEN], *ret;
|
||||||
|
|
||||||
int r = 0, retval = SUCCESS;
|
int r = 0, retval = SUCCESS;
|
||||||
int i, is_standby_retval;
|
int i, is_standby_retval;
|
||||||
@@ -829,11 +832,12 @@ do_standby_clone(void)
|
|||||||
|
|
||||||
/* primary should be v9 or better */
|
/* primary should be v9 or better */
|
||||||
log_info(_("%s connected to master, checking its state\n"), progname);
|
log_info(_("%s connected to master, checking its state\n"), progname);
|
||||||
pg_version(conn, master_version);
|
ret = pg_version(conn, master_version);
|
||||||
if (strcmp(master_version, "") == 0)
|
if (ret == NULL || strcmp(master_version, "") == 0)
|
||||||
{
|
{
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
log_err(_("%s needs master to be PostgreSQL 9.0 or better\n"), progname);
|
if (ret != NULL)
|
||||||
|
log_err(_("%s needs master to be PostgreSQL 9.0 or better\n"), progname);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1258,7 +1262,7 @@ do_standby_promote(void)
|
|||||||
{
|
{
|
||||||
PGconn *conn;
|
PGconn *conn;
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
char sqlquery[QUERY_STR_LEN];
|
char sqlquery[QUERY_STR_LEN], *ret;
|
||||||
char script[MAXLEN];
|
char script[MAXLEN];
|
||||||
|
|
||||||
PGconn *old_master_conn;
|
PGconn *old_master_conn;
|
||||||
@@ -1277,10 +1281,11 @@ do_standby_promote(void)
|
|||||||
|
|
||||||
/* we need v9 or better */
|
/* we need v9 or better */
|
||||||
log_info(_("%s connected to master, checking its state\n"), progname);
|
log_info(_("%s connected to master, checking its state\n"), progname);
|
||||||
pg_version(conn, standby_version);
|
ret = pg_version(conn, standby_version);
|
||||||
if (strcmp(standby_version, "") == 0)
|
if (ret == NULL || strcmp(standby_version, "") == 0)
|
||||||
{
|
{
|
||||||
log_err(_("%s needs standby to be PostgreSQL 9.0 or better\n"), progname);
|
if (ret != NULL)
|
||||||
|
log_err(_("%s needs standby to be PostgreSQL 9.0 or better\n"), progname);
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
@@ -1367,7 +1372,7 @@ do_standby_follow(void)
|
|||||||
{
|
{
|
||||||
PGconn *conn;
|
PGconn *conn;
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
char sqlquery[QUERY_STR_LEN];
|
char sqlquery[QUERY_STR_LEN], *ret;
|
||||||
char script[MAXLEN];
|
char script[MAXLEN];
|
||||||
char master_conninfo[MAXLEN];
|
char master_conninfo[MAXLEN];
|
||||||
PGconn *master_conn;
|
PGconn *master_conn;
|
||||||
@@ -1396,10 +1401,11 @@ do_standby_follow(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* should be v9 or better */
|
/* should be v9 or better */
|
||||||
pg_version(conn, standby_version);
|
ret = pg_version(conn, standby_version);
|
||||||
if (strcmp(standby_version, "") == 0)
|
if (ret == NULL || strcmp(standby_version, "") == 0)
|
||||||
{
|
{
|
||||||
log_err(_("\n%s needs standby to be PostgreSQL 9.0 or better\n"), progname);
|
if (ret != NULL)
|
||||||
|
log_err(_("\n%s needs standby to be PostgreSQL 9.0 or better\n"), progname);
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
@@ -1438,10 +1444,11 @@ do_standby_follow(void)
|
|||||||
|
|
||||||
/* should be v9 or better */
|
/* should be v9 or better */
|
||||||
log_info(_("%s connected to master, checking its state\n"), progname);
|
log_info(_("%s connected to master, checking its state\n"), progname);
|
||||||
pg_version(master_conn, master_version);
|
ret = pg_version(master_conn, master_version);
|
||||||
if (strcmp(master_version, "") == 0)
|
if (ret == NULL || strcmp(master_version, "") == 0)
|
||||||
{
|
{
|
||||||
log_err(_("%s needs master to be PostgreSQL 9.0 or better\n"), progname);
|
if (ret != NULL)
|
||||||
|
log_err(_("%s needs master to be PostgreSQL 9.0 or better\n"), progname);
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
PQfinish(master_conn);
|
PQfinish(master_conn);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
@@ -1507,7 +1514,7 @@ do_witness_create(void)
|
|||||||
PGconn *masterconn;
|
PGconn *masterconn;
|
||||||
PGconn *witnessconn;
|
PGconn *witnessconn;
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
char sqlquery[QUERY_STR_LEN];
|
char sqlquery[QUERY_STR_LEN], *ret;
|
||||||
|
|
||||||
char script[MAXLEN];
|
char script[MAXLEN];
|
||||||
char buf[MAXLEN];
|
char buf[MAXLEN];
|
||||||
@@ -1535,10 +1542,11 @@ do_witness_create(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* primary should be v9 or better */
|
/* primary should be v9 or better */
|
||||||
pg_version(masterconn, master_version);
|
ret = pg_version(masterconn, master_version);
|
||||||
if (strcmp(master_version, "") == 0)
|
if (ret == NULL || strcmp(master_version, "") == 0)
|
||||||
{
|
{
|
||||||
log_err(_("%s needs master to be PostgreSQL 9.0 or better\n"), progname);
|
if (ret != NULL)
|
||||||
|
log_err(_("%s needs master to be PostgreSQL 9.0 or better\n"), progname);
|
||||||
PQfinish(masterconn);
|
PQfinish(masterconn);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|||||||
11
repmgrd.c
11
repmgrd.c
@@ -168,7 +168,7 @@ main(int argc, char **argv)
|
|||||||
int c, ret;
|
int c, ret;
|
||||||
bool daemonize = false;
|
bool daemonize = false;
|
||||||
|
|
||||||
char standby_version[MAXVERSIONSTR];
|
char standby_version[MAXVERSIONSTR], *ret_ver;
|
||||||
|
|
||||||
progname = get_progname(argv[0]);
|
progname = get_progname(argv[0]);
|
||||||
|
|
||||||
@@ -283,10 +283,11 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
/* should be v9 or better */
|
/* should be v9 or better */
|
||||||
log_info(_("%s Connected to database, checking its state\n"), progname);
|
log_info(_("%s Connected to database, checking its state\n"), progname);
|
||||||
pg_version(myLocalConn, standby_version);
|
ret_ver = pg_version(myLocalConn, standby_version);
|
||||||
if (strcmp(standby_version, "") == 0)
|
if (ret_ver == NULL || strcmp(standby_version, "") == 0)
|
||||||
{
|
{
|
||||||
log_err(_("%s needs standby to be PostgreSQL 9.0 or better\n"), progname);
|
if(ret_ver != NULL)
|
||||||
|
log_err(_("%s needs standby to be PostgreSQL 9.0 or better\n"), progname);
|
||||||
PQfinish(myLocalConn);
|
PQfinish(myLocalConn);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
}
|
}
|
||||||
@@ -323,9 +324,7 @@ main(int argc, char **argv)
|
|||||||
* should not exit at this point, but for now we do until we have a
|
* should not exit at this point, but for now we do until we have a
|
||||||
* better strategy */
|
* better strategy */
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
{
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
|
||||||
|
|
||||||
switch (myLocalMode)
|
switch (myLocalMode)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user