Remove no-longer-appropriate special case in psql's \conninfo code.
\conninfo prints the results of PQhost() and some other libpq functions. It used to override the PQhost() result with the hostaddr parameter if that'd been given, but that's unhelpful when multiple hosts were listed in the connection string. Furthermore, it seems unnecessary in the wake of commit 1944cdc98, since PQhost does any useful substitution itself. So let's just remove the extra code and print PQhost()'s result without any editorialization. Back-patch to v10, as 1944cdc98 (just) was. Discussion: https://postgr.es/m/23287.1533227021@sss.pgh.pa.us
This commit is contained in:
parent
24986c9552
commit
c7a8f78677
@ -595,25 +595,7 @@ exec_command_conninfo(PsqlScanState scan_state, bool active_branch)
|
|||||||
printf(_("You are currently not connected to a database.\n"));
|
printf(_("You are currently not connected to a database.\n"));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *host;
|
char *host = PQhost(pset.db);
|
||||||
PQconninfoOption *connOptions;
|
|
||||||
PQconninfoOption *option;
|
|
||||||
|
|
||||||
host = PQhost(pset.db);
|
|
||||||
/* A usable "hostaddr" overrides the basic sense of host. */
|
|
||||||
connOptions = PQconninfo(pset.db);
|
|
||||||
if (connOptions == NULL)
|
|
||||||
{
|
|
||||||
psql_error("out of memory\n");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
for (option = connOptions; option && option->keyword; option++)
|
|
||||||
if (strcmp(option->keyword, "hostaddr") == 0)
|
|
||||||
{
|
|
||||||
if (option->val != NULL && option->val[0] != '\0')
|
|
||||||
host = option->val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If the host is an absolute path, the connection is via socket */
|
/* If the host is an absolute path, the connection is via socket */
|
||||||
if (is_absolute_path(host))
|
if (is_absolute_path(host))
|
||||||
@ -623,8 +605,6 @@ exec_command_conninfo(PsqlScanState scan_state, bool active_branch)
|
|||||||
printf(_("You are connected to database \"%s\" as user \"%s\" on host \"%s\" at port \"%s\".\n"),
|
printf(_("You are connected to database \"%s\" as user \"%s\" on host \"%s\" at port \"%s\".\n"),
|
||||||
db, PQuser(pset.db), host, PQport(pset.db));
|
db, PQuser(pset.db), host, PQport(pset.db));
|
||||||
printSSLInfo();
|
printSSLInfo();
|
||||||
|
|
||||||
PQconninfoFree(connOptions);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user