Re: psql \conninfo command (was: Patch: psql \whoami option) - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: psql \conninfo command (was: Patch: psql \whoami option)
Date
Msg-id AANLkTinsurkhZsZkRi_EpS+CaE4m9+fRZrSDfLwVqhXW@mail.gmail.com
Whole thread Raw
In response to Re: psql \conninfo command (was: Patch: psql \whoami option)  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: psql \conninfo command (was: Patch: psql \whoami option)
Re: psql \conninfo command (was: Patch: psql \whoami option)
List pgsql-hackers
On Wed, Jul 21, 2010 at 7:29 PM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Wed, Jul 21, 2010 at 1:07 AM, Fujii Masao <masao.fujii@gmail.com> wrote:
>> On Tue, Jul 20, 2010 at 11:14 PM, Robert Haas <robertmhaas@gmail.com> wrote:
>>> OK, committed.
>>
>> When I specify the path of the directory for the Unix-domain socket
>> as the host, \conninfo doesn't mention that this connection is based
>> on the Unix-domain socket. Is this intentional?
>>
>> $ psql -h"/tmp" -c"\conninfo"
>> You are connected to database "postgres" on host "/tmp" at port "5432"
>> as user "postgres".
>>
>> I expected that something like
>>
>>    You are connected to database "postgres" via local socket on
>> "/tmp" at port "5432" as user "postgres".
>
> :-(
>
> No, I didn't realize the host field could be used that way.  It's true
> that you get a fairly similar message from \c, but that's not exactly
> intuitive either.
>
> rhaas=# \c - - /tmp -
> You are now connected to database "rhaas" on host "/tmp".

OK. The attached patch makes \conninfo command emit the following
message if the host begins with a slash:

    $ psql -h/tmp -c"\conninfo"
    You are connected to database "postgres" via local socket on
"/tmp" at port "5432" as user "postgres".

Similarly, it makes \c command emit the following message in that
case:

    $ psql -hlocalhost -c"\c - - /tmp -"
    You are now connected to database "postgres" via local socket on "/tmp".

Comments?

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: pg_dump(all) --quote-all-identifiers
Next
From: David Christensen
Date:
Subject: Re: psql \conninfo command (was: Patch: psql \whoami option)