pgsql: Add \conninfo command to psql, to show current connection info.

Lists: pgsql-committerspgsql-hackers
From: rhaas(at)postgresql(dot)org (Robert Haas)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Add \conninfo command to psql, to show current connection info.
Date: 2010-07-20 03:54:19
Message-ID: 20100720035419.B00F77541D5@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Log Message:
-----------
Add \conninfo command to psql, to show current connection info.

David Christensen. Reviewed by Steve Singer. Some further changes by me.

Modified Files:
--------------
pgsql/doc/src/sgml/ref:
psql-ref.sgml (r1.245 -> r1.246)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/ref/psql-ref.sgml?r1=1.245&r2=1.246)
pgsql/src/bin/psql:
command.c (r1.221 -> r1.222)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/bin/psql/command.c?r1=1.221&r2=1.222)
help.c (r1.159 -> r1.160)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/bin/psql/help.c?r1=1.159&r2=1.160)
tab-complete.c (r1.200 -> r1.201)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/bin/psql/tab-complete.c?r1=1.200&r2=1.201)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>, David Christensen <david(at)endpoint(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [COMMITTERS] pgsql: Add \conninfo command to psql, to show current connection info.
Date: 2010-08-03 17:46:06
Message-ID: 23611.1280857566@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

rhaas(at)postgresql(dot)org (Robert Haas) writes:
> Add \conninfo command to psql, to show current connection info.
> David Christensen. Reviewed by Steve Singer. Some further changes by me.

Looking at the output from this command:

regression=# \conninfo
You are connected to database "regression" via local socket in "/tmp" at port "5432" as user "postgres".

This seems a bit awkwardly phrased. I think it would read better if the
ordering was changed to

You are connected to database "regression" as user "postgres" via local socket in "/tmp" at port "5432".

I can't put my finger on the reason why the current ordering seems like
awkward English, but I can give a couple of concrete arguments for
changing it:

1. This way would match the argument ordering for \connect,
which in case you've forgotten is dbname user host port.

2. At least to me, this seems closer to the relative importance of the
items.

Comments, objections?

regards, tom lane


From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "David Christensen" <david(at)endpoint(dot)com>, "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [COMMITTERS] pgsql: Add \conninfo command to psql, to show current connection info.
Date: 2010-08-03 17:50:23
Message-ID: 4C58108F0200002500034182@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> You are connected to database "regression" as user "postgres"
> via local socket in "/tmp" at port "5432".

+1

-Kevin


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: "David Christensen" <david(at)endpoint(dot)com>, "Robert Haas" <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [COMMITTERS] pgsql: Add \conninfo command to psql, to show current connection info.
Date: 2010-08-03 18:04:50
Message-ID: 24071.1280858690@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

"Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov> writes:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> You are connected to database "regression" as user "postgres"
>> via local socket in "/tmp" at port "5432".

> +1

Looking at the code, I notice another problem, which is that it's a
rather egregious violation of the rule against assembling messages
out of small phrases that would have to be translated separately.
I realize that this is a pre-existing problem in \connect and the
\conninfo patch just copied it, but that doesn't make it OK.

The problem in \connect is that somebody made an arbitrary decision to
print only the parameters that changed, which they weren't even too
consistent about since the database name is always printed. Maintaining
that behavior exactly would require quite a large number of variant
messages. What I suggest we do in \connect is always print the database
and user names, plus print all of the addressing info if any of it
changed. This would mean three translatable messages there:

You are now connected to database "%s" as user "%s".
You are now connected to database "%s" as user "%s" on host "%s" at port "%s".
You are now connected to database "%s" as user "%s" via local socket in "%s" at port "%s".

while \conninfo would have two translatable messages corresponding
to the last two cases.

BTW, the word "local" seems to be useless extra verbiage; any
objections to making it just read "via socket in"?

regards, tom lane


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: David Christensen <david(at)endpoint(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Add \conninfo command to psql, to show current connection info.
Date: 2010-08-03 18:49:24
Message-ID: AANLkTim-yYqj3GXyxn4yYVnRUvNZb3JAUDq4Am5EbkFx@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-committers pgsql-hackers

On Tue, Aug 3, 2010 at 1:46 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> 1. This way would match the argument ordering for \connect,
> which in case you've forgotten is dbname user host port.

I noticed that discrepancy when reviewing, but felt it was a problem
for another day. Today is fine, though. :-)

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company