Skip to content

Commit 5b92ef4

Browse files
committed
Kibitzing on \conninfo patch: adjust the order of field output to match
the parameters of \connect, and fix oversight of not enabling translation of the messages. Also, adjust \connect's similar messages to match, and deal with 8.2-era violation of basic translatability guidelines there.
1 parent 83527b1 commit 5b92ef4

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

doc/src/sgml/ref/psql-ref.sgml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.246 2010/07/20 03:54:19 rhaas Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.247 2010/08/03 18:33:09 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -784,8 +784,7 @@ testdb=&gt;
784784
<term><literal>\conninfo</literal></term>
785785
<listitem>
786786
<para>
787-
Outputs connection information about the current database
788-
connection.
787+
Outputs information about the current database connection.
789788
</para>
790789
</listitem>
791790
</varlistentry>

src/bin/psql/command.c

Lines changed: 20 additions & 25 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.224 2010/07/23 14:56:54 rhaas Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.225 2010/08/03 18:33:09 tgl Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "command.h"
@@ -294,28 +294,25 @@ exec_command(const char *cmd,
294294
free(opt);
295295
}
296296

297-
/* \conninfo -- display information about the current connection */
297+
/* \conninfo -- display information about the current connection */
298298
else if (strcmp(cmd, "conninfo") == 0)
299299
{
300300
char *db = PQdb(pset.db);
301301
char *host = PQhost(pset.db);
302302

303303
if (db == NULL)
304-
printf("You are not connected.\n");
304+
printf(_("You are not connected.\n"));
305305
else
306306
{
307307
if (host == NULL)
308308
host = DEFAULT_PGSOCKET_DIR;
309-
/*
310-
* If the host is an absolute path, the connection is via local
311-
* socket.
312-
*/
309+
/* If the host is an absolute path, the connection is via socket */
313310
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));
311+
printf(_("You are connected to database \"%s\" as user \"%s\" via socket in \"%s\" at port \"%s\".\n"),
312+
db, PQuser(pset.db), host, PQport(pset.db));
316313
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));
314+
printf(_("You are connected to database \"%s\" as user \"%s\" on host \"%s\" at port \"%s\".\n"),
315+
db, PQuser(pset.db), host, PQport(pset.db));
319316
}
320317
}
321318

@@ -1372,26 +1369,24 @@ do_connect(char *dbname, char *user, char *host, char *port)
13721369
/* Tell the user about the new connection */
13731370
if (!pset.quiet)
13741371
{
1375-
printf(_("You are now connected to database \"%s\""), PQdb(pset.db));
1376-
1377-
if (param_is_newly_set(PQhost(o_conn), PQhost(pset.db)))
1372+
if (param_is_newly_set(PQhost(o_conn), PQhost(pset.db)) ||
1373+
param_is_newly_set(PQport(o_conn), PQport(pset.db)))
13781374
{
13791375
char *host = PQhost(pset.db);
13801376

1381-
/* If the host is an absolute path, the connection is via local socket */
1377+
if (host == NULL)
1378+
host = DEFAULT_PGSOCKET_DIR;
1379+
/* If the host is an absolute path, the connection is via socket */
13821380
if (is_absolute_path(host))
1383-
printf(_(" via local socket in \"%s\""), host);
1381+
printf(_("You are now connected to database \"%s\" as user \"%s\" via socket in \"%s\" at port \"%s\".\n"),
1382+
PQdb(pset.db), PQuser(pset.db), host, PQport(pset.db));
13841383
else
1385-
printf(_(" on host \"%s\""), host);
1384+
printf(_("You are now connected to database \"%s\" as user \"%s\" on host \"%s\" at port \"%s\".\n"),
1385+
PQdb(pset.db), PQuser(pset.db), host, PQport(pset.db));
13861386
}
1387-
1388-
if (param_is_newly_set(PQport(o_conn), PQport(pset.db)))
1389-
printf(_(" at port \"%s\""), PQport(pset.db));
1390-
1391-
if (param_is_newly_set(PQuser(o_conn), PQuser(pset.db)))
1392-
printf(_(" as user \"%s\""), PQuser(pset.db));
1393-
1394-
printf(".\n");
1387+
else
1388+
printf(_("You are now connected to database \"%s\" as user \"%s\".\n"),
1389+
PQdb(pset.db), PQuser(pset.db));
13951390
}
13961391

13971392
if (o_conn)

0 commit comments

Comments
 (0)