mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 16:46:28 +00:00
Be consistent in the use of sqlquery_snprintf() for query strings,
which was not used in the new code. Also add a few "newline" characters in some messages, and other minutia.
This commit is contained in:
24
repmgr.c
24
repmgr.c
@@ -1407,9 +1407,9 @@ do_witness_create(void)
|
|||||||
fclose(pg_conf);
|
fclose(pg_conf);
|
||||||
|
|
||||||
/* Get the pg_hba.conf full path */
|
/* Get the pg_hba.conf full path */
|
||||||
sprintf(sqlquery, "SELECT name, setting "
|
sqlquery_snprintf(sqlquery, "SELECT name, setting "
|
||||||
" FROM pg_settings "
|
" FROM pg_settings "
|
||||||
" WHERE name IN ('hba_file')");
|
" WHERE name IN ('hba_file')");
|
||||||
log_debug(_("witness create: %s"), sqlquery);
|
log_debug(_("witness create: %s"), sqlquery);
|
||||||
res = PQexec(masterconn, sqlquery);
|
res = PQexec(masterconn, sqlquery);
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
@@ -1495,7 +1495,7 @@ do_witness_create(void)
|
|||||||
/* establish a connection to the witness, and create the schema */
|
/* establish a connection to the witness, and create the schema */
|
||||||
witnessconn = establishDBConnection(options.conninfo, true);
|
witnessconn = establishDBConnection(options.conninfo, true);
|
||||||
|
|
||||||
log_info(_("Starting copy of configuration from master"));
|
log_info(_("Starting copy of configuration from master...\n"));
|
||||||
|
|
||||||
if (!create_schema(witnessconn))
|
if (!create_schema(witnessconn))
|
||||||
{
|
{
|
||||||
@@ -1517,6 +1517,8 @@ do_witness_create(void)
|
|||||||
log_notice(_("Configuration has been succesfully copied to the witness\n"));
|
log_notice(_("Configuration has been succesfully copied to the witness\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
@@ -1524,6 +1526,8 @@ usage(void)
|
|||||||
log_err(_("Try \"%s --help\" for more information.\n"), progname);
|
log_err(_("Try \"%s --help\" for more information.\n"), progname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
help(const char *progname)
|
help(const char *progname)
|
||||||
{
|
{
|
||||||
@@ -1932,7 +1936,8 @@ create_schema(PGconn *conn)
|
|||||||
|
|
||||||
/* an index to improve performance of the view */
|
/* an index to improve performance of the view */
|
||||||
sqlquery_snprintf(sqlquery, "CREATE INDEX idx_repl_status_sort "
|
sqlquery_snprintf(sqlquery, "CREATE INDEX idx_repl_status_sort "
|
||||||
" ON %s.repl_monitor (last_monitor_time, standby_node) ");
|
" ON %s.repl_monitor (last_monitor_time, standby_node) ",
|
||||||
|
repmgr_schema);
|
||||||
log_debug(_("master register: %s\n"), sqlquery);
|
log_debug(_("master register: %s\n"), sqlquery);
|
||||||
if (!PQexec(conn, sqlquery))
|
if (!PQexec(conn, sqlquery))
|
||||||
{
|
{
|
||||||
@@ -1943,7 +1948,7 @@ create_schema(PGconn *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* XXX Here we MUST try to load the repmgr_function.sql not hardcode it here */
|
/* XXX Here we MUST try to load the repmgr_function.sql not hardcode it here */
|
||||||
sprintf(sqlquery,
|
sqlquery_snprintf(sqlquery,
|
||||||
"CREATE OR REPLACE FUNCTION public.repmgr_update_standby_location(text) RETURNS boolean "
|
"CREATE OR REPLACE FUNCTION public.repmgr_update_standby_location(text) RETURNS boolean "
|
||||||
"AS '$libdir/repmgr_funcs', 'repmgr_update_standby_location' "
|
"AS '$libdir/repmgr_funcs', 'repmgr_update_standby_location' "
|
||||||
"LANGUAGE C STRICT ");
|
"LANGUAGE C STRICT ");
|
||||||
@@ -1954,7 +1959,7 @@ create_schema(PGconn *conn)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(sqlquery,
|
sqlquery_snprintf(sqlquery,
|
||||||
"CREATE OR REPLACE FUNCTION public.repmgr_get_last_standby_location() RETURNS text "
|
"CREATE OR REPLACE FUNCTION public.repmgr_get_last_standby_location() RETURNS text "
|
||||||
"AS '$libdir/repmgr_funcs', 'repmgr_get_last_standby_location' "
|
"AS '$libdir/repmgr_funcs', 'repmgr_get_last_standby_location' "
|
||||||
"LANGUAGE C STRICT ");
|
"LANGUAGE C STRICT ");
|
||||||
@@ -1976,7 +1981,8 @@ copy_configuration(PGconn *masterconn, PGconn *witnessconn)
|
|||||||
PGresult *res;
|
PGresult *res;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
sprintf(sqlquery, "TRUNCATE TABLE repmgr_%s.repl_nodes", options.cluster_name);
|
sqlquery_snprintf(sqlquery, "TRUNCATE TABLE %s.repl_nodes", repmgr_schema);
|
||||||
|
log_debug("copy_configuration: %s\n", sqlquery);
|
||||||
if (!PQexec(witnessconn, sqlquery))
|
if (!PQexec(witnessconn, sqlquery))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Cannot clean node details in the witness, %s\n",
|
fprintf(stderr, "Cannot clean node details in the witness, %s\n",
|
||||||
@@ -1984,7 +1990,7 @@ copy_configuration(PGconn *masterconn, PGconn *witnessconn)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(sqlquery, "SELECT * FROM repmgr_%s.repl_nodes", options.cluster_name);
|
sqlquery_snprintf(sqlquery, "SELECT * FROM %s.repl_nodes", repmgr_schema);
|
||||||
res = PQexec(masterconn, sqlquery);
|
res = PQexec(masterconn, sqlquery);
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user