Skip to content

Commit c7a8f78

Browse files
committed
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 1944cdc, 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 1944cdc (just) was. Discussion: https://postgr.es/m/23287.1533227021@sss.pgh.pa.us
1 parent 24986c9 commit c7a8f78

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

src/bin/psql/command.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -595,25 +595,7 @@ exec_command_conninfo(PsqlScanState scan_state, bool active_branch)
595595
printf(_("You are currently not connected to a database.\n"));
596596
else
597597
{
598-
char *host;
599-
PQconninfoOption *connOptions;
600-
PQconninfoOption *option;
601-
602-
host = PQhost(pset.db);
603-
/* A usable "hostaddr" overrides the basic sense of host. */
604-
connOptions = PQconninfo(pset.db);
605-
if (connOptions == NULL)
606-
{
607-
psql_error("out of memory\n");
608-
exit(EXIT_FAILURE);
609-
}
610-
for (option = connOptions; option && option->keyword; option++)
611-
if (strcmp(option->keyword, "hostaddr") == 0)
612-
{
613-
if (option->val != NULL && option->val[0] != '\0')
614-
host = option->val;
615-
break;
616-
}
598+
char *host = PQhost(pset.db);
617599

618600
/* If the host is an absolute path, the connection is via socket */
619601
if (is_absolute_path(host))
@@ -623,8 +605,6 @@ exec_command_conninfo(PsqlScanState scan_state, bool active_branch)
623605
printf(_("You are connected to database \"%s\" as user \"%s\" on host \"%s\" at port \"%s\".\n"),
624606
db, PQuser(pset.db), host, PQport(pset.db));
625607
printSSLInfo();
626-
627-
PQconninfoFree(connOptions);
628608
}
629609
}
630610

0 commit comments

Comments
 (0)