From 9e10987b900a1b0b00a8313c4ca124aa4bc5ebc2 Mon Sep 17 00:00:00 2001 From: Jaime Casanova Date: Fri, 15 Jun 2012 09:40:09 -0500 Subject: [PATCH] Fix a few bugs introduced when merging features --- check_dir.c | 2 +- repmgr.c | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/check_dir.c b/check_dir.c index ab25edde..b1f665f9 100644 --- a/check_dir.c +++ b/check_dir.c @@ -231,7 +231,7 @@ is_pg_dir(char *dir) return true; // test tablespace dir - sprintf(path, "ls %s/PG_9.0_*/ -I*", dir); + sprintf(path, "ls %s/PG_*/ -I*", dir); r = system(path); if (r == 0) return true; diff --git a/repmgr.c b/repmgr.c index b06d2388..6c1b9dd2 100644 --- a/repmgr.c +++ b/repmgr.c @@ -83,7 +83,7 @@ bool need_a_node = true; bool require_password = false; /* Initialization of runtime options */ -t_runtime_options runtime_options = { "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, "", 0 }; +t_runtime_options runtime_options = { "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, "", "", 0 }; t_configuration_options options = { "", -1, "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", -1 }; static char *server_mode = NULL; @@ -423,11 +423,9 @@ do_cluster_show(void) do_cluster_cleanup(void) { int master_id; - PGconn *master_conn; + PGconn *master_conn = NULL; PGresult *res; char sqlquery[QUERY_STR_LEN]; - char node_role[MAXLEN]; - int i; /* check if there is a master in this cluster */ log_info(_("%s connecting to master database\n"), progname); @@ -443,30 +441,30 @@ do_cluster_cleanup(void) { sqlquery_snprintf(sqlquery, "DELETE FROM %s.repl_monitor " " WHERE age(now(), last_monitor_time) >= '%d days'::interval;", - repmgr_schema, keep_history); + repmgr_schema, runtime_options.keep_history); } else { sqlquery_snprintf(sqlquery, "TRUNCATE TABLE %s.repl_monitor;", repmgr_schema); } - res = PQexec(conn, sqlquery); + res = PQexec(master_conn, sqlquery); if (PQresultStatus(res) != PGRES_COMMAND_OK) { - log_err(_("cluster cleanup: Couldn't clean history\n%s\n"), PQerrorMessage(conn)); + log_err(_("cluster cleanup: Couldn't clean history\n%s\n"), PQerrorMessage(master_conn)); PQclear(res); - PQfinish(conn); + PQfinish(master_conn); exit(ERR_BAD_CONFIG); } PQclear(res); /* Let's VACUUM the table to avoid autovacuum to be launched in an unexpected hour */ sqlquery_snprintf(sqlquery, "VACUUM %s.repl_monitor;", repmgr_schema); - res = PQexec(conn, sqlquery); + res = PQexec(master_conn, sqlquery); /* XXX There is any need to check this VACUUM happens without problems? */ PQclear(res); - PQfinish(conn); + PQfinish(master_conn); }