summaryrefslogtreecommitdiff
path: root/src/bin/psql/command.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2010-07-23 14:56:54 +0000
committerRobert Haas <rhaas@postgresql.org>2010-07-23 14:56:54 +0000
commit87e0b7422d70ff4fb69612ef7ba3cbee6ed8d2ae (patch)
tree07c29a641688bfa142dc1c9d67c98d7a03253e04 /src/bin/psql/command.c
parent7be8946c78935f20faf17f8e313c4b86cb773967 (diff)
Have psql avoid describing local sockets as host names.
We now use the phrase 'via local socket in' rather than 'on host' in both \c and \conninfo output, when applicable. Fujii Masao, with some kibitzing by me.
Diffstat (limited to 'src/bin/psql/command.c')
-rw-r--r--src/bin/psql/command.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index c90bf2805ee..5e551455695 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.223 2010/07/20 14:14:30 rhaas Exp $
+ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.224 2010/07/23 14:56:54 rhaas Exp $
*/
#include "postgres_fe.h"
#include "command.h"
@@ -300,14 +300,23 @@ exec_command(const char *cmd,
char *db = PQdb(pset.db);
char *host = PQhost(pset.db);
- if (!db)
+ if (db == NULL)
printf("You are not connected.\n");
- else if (host)
- printf("You are connected to database \"%s\" on host \"%s\" at port \"%s\" as user \"%s\".\n",
- db, host, PQport(pset.db), PQuser(pset.db));
else
- printf("You are connected to database \"%s\" via local socket at port \"%s\" as user \"%s\".\n",
- db, PQport(pset.db), PQuser(pset.db));
+ {
+ if (host == NULL)
+ host = DEFAULT_PGSOCKET_DIR;
+ /*
+ * If the host is an absolute path, the connection is via local
+ * socket.
+ */
+ if (is_absolute_path(host))
+ printf("You are connected to database \"%s\" via local socket in \"%s\" at port \"%s\" as user \"%s\".\n",
+ db, host, PQport(pset.db), PQuser(pset.db));
+ else
+ printf("You are connected to database \"%s\" on host \"%s\" at port \"%s\" as user \"%s\".\n",
+ db, host, PQport(pset.db), PQuser(pset.db));
+ }
}
/* \copy */
@@ -1366,7 +1375,15 @@ do_connect(char *dbname, char *user, char *host, char *port)
printf(_("You are now connected to database \"%s\""), PQdb(pset.db));
if (param_is_newly_set(PQhost(o_conn), PQhost(pset.db)))
- printf(_(" on host \"%s\""), PQhost(pset.db));
+ {
+ char *host = PQhost(pset.db);
+
+ /* If the host is an absolute path, the connection is via local socket */
+ if (is_absolute_path(host))
+ printf(_(" via local socket in \"%s\""), host);
+ else
+ printf(_(" on host \"%s\""), host);
+ }
if (param_is_newly_set(PQport(o_conn), PQport(pset.db)))
printf(_(" at port \"%s\""), PQport(pset.db));