mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 16:46:28 +00:00
Add more information in "cluster show"
- Add display of current node name. - Add display of upstream node name.
This commit is contained in:
14
repmgr.c
14
repmgr.c
@@ -588,9 +588,13 @@ do_cluster_show(void)
|
|||||||
conn = establish_db_connection(options.conninfo, true);
|
conn = establish_db_connection(options.conninfo, true);
|
||||||
|
|
||||||
sqlquery_snprintf(sqlquery,
|
sqlquery_snprintf(sqlquery,
|
||||||
"SELECT conninfo, type "
|
"SELECT rn.conninfo, rn.type, rn.name, sq.name"
|
||||||
" FROM %s.repl_nodes ",
|
" FROM %s.repl_nodes as rn"
|
||||||
get_repmgr_schema_quoted(conn));
|
" LEFT JOIN %s.repl_nodes AS sq"
|
||||||
|
" ON sq.id=rn.upstream_node_id",
|
||||||
|
get_repmgr_schema_quoted(conn),
|
||||||
|
get_repmgr_schema_quoted(conn));
|
||||||
|
|
||||||
res = PQexec(conn, sqlquery);
|
res = PQexec(conn, sqlquery);
|
||||||
|
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||||
@@ -605,7 +609,7 @@ do_cluster_show(void)
|
|||||||
}
|
}
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
|
|
||||||
printf("Role | Connection String\n");
|
printf("Role | Name | Upstream | Connection String\n");
|
||||||
for (i = 0; i < PQntuples(res); i++)
|
for (i = 0; i < PQntuples(res); i++)
|
||||||
{
|
{
|
||||||
conn = establish_db_connection(PQgetvalue(res, i, 0), false);
|
conn = establish_db_connection(PQgetvalue(res, i, 0), false);
|
||||||
@@ -619,6 +623,8 @@ do_cluster_show(void)
|
|||||||
strcpy(node_role, "* master");
|
strcpy(node_role, "* master");
|
||||||
|
|
||||||
printf("%-10s", node_role);
|
printf("%-10s", node_role);
|
||||||
|
printf("| %-14s", PQgetvalue(res, i, 2));
|
||||||
|
printf("| %-14s", PQgetvalue(res, i, 3));
|
||||||
printf("| %s\n", PQgetvalue(res, i, 0));
|
printf("| %s\n", PQgetvalue(res, i, 0));
|
||||||
|
|
||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
|
|||||||
Reference in New Issue
Block a user