Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit87e0b74

Browse files
committed
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.
1 parent7be8946 commit87e0b74

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

‎src/bin/psql/command.c

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.223 2010/07/20 14:14:30 rhaas Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.224 2010/07/23 14:56:54 rhaas Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"command.h"
@@ -300,14 +300,23 @@ exec_command(const char *cmd,
300300
char*db=PQdb(pset.db);
301301
char*host=PQhost(pset.db);
302302

303-
if (!db)
303+
if (db==NULL)
304304
printf("You are not connected.\n");
305-
elseif (host)
306-
printf("You are connected to database \"%s\" on host \"%s\" at port \"%s\" as user \"%s\".\n",
307-
db,host,PQport(pset.db),PQuser(pset.db));
308305
else
309-
printf("You are connected to database \"%s\" via local socket at port \"%s\" as user \"%s\".\n",
310-
db,PQport(pset.db),PQuser(pset.db));
306+
{
307+
if (host==NULL)
308+
host=DEFAULT_PGSOCKET_DIR;
309+
/*
310+
* If the host is an absolute path, the connection is via local
311+
* socket.
312+
*/
313+
if (is_absolute_path(host))
314+
printf("You are connected to database \"%s\" via local socket in \"%s\" at port \"%s\" as user \"%s\".\n",
315+
db,host,PQport(pset.db),PQuser(pset.db));
316+
else
317+
printf("You are connected to database \"%s\" on host \"%s\" at port \"%s\" as user \"%s\".\n",
318+
db,host,PQport(pset.db),PQuser(pset.db));
319+
}
311320
}
312321

313322
/* \copy */
@@ -1366,7 +1375,15 @@ do_connect(char *dbname, char *user, char *host, char *port)
13661375
printf(_("You are now connected to database \"%s\""),PQdb(pset.db));
13671376

13681377
if (param_is_newly_set(PQhost(o_conn),PQhost(pset.db)))
1369-
printf(_(" on host \"%s\""),PQhost(pset.db));
1378+
{
1379+
char*host=PQhost(pset.db);
1380+
1381+
/* If the host is an absolute path, the connection is via local socket */
1382+
if (is_absolute_path(host))
1383+
printf(_(" via local socket in \"%s\""),host);
1384+
else
1385+
printf(_(" on host \"%s\""),host);
1386+
}
13701387

13711388
if (param_is_newly_set(PQport(o_conn),PQport(pset.db)))
13721389
printf(_(" at port \"%s\""),PQport(pset.db));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp