From: Erik Wienhold <ewie@mailbox.org>
To: Dominique Devienne <ddevienne@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Who am I? Where am I connected?
Date: Wed, 18 May 2022 12:29:34 +0200 (CEST)
Message-ID: <541270671.1136671.1652869774367@office.mailbox.org> (raw)
In-Reply-To: <CAFCRh-_BSW8VRPPQU6OrKmLZmk1+-0GvbBObgkMmqWf2_YqMkQ@mail.gmail.com>
References: <CAFCRh-_BSW8VRPPQU6OrKmLZmk1+-0GvbBObgkMmqWf2_YqMkQ@mail.gmail.com>
Hi Dominique,
you can use \conninfo in psql to show the database, user, host (or socket in my example), and port:
ewie@desktop ~ $ psql test
Null display is "".
psql (14.3)
Type "help" for help.
test=# \conninfo
You are connected to database "test" as user "ewie" via socket in "/run/postgresql" at port "5432".
- Erik
> On 18/05/2022 12:07 Dominique Devienne <ddevienne@gmail.com> wrote:
>
>
> LibPQ has various defaults for the host, user, and DB name.
> There's also the password file, the service file and service name.
> In the example below, I can connect with a "naked" psql invocation.
>
> Once connected, can I find out all aspects of the connection string?
> Or where they came from, like a pgpass.conf or service file?
>
> How to get the host, port, db name once connected?
> SHOW and pg_settings does not appear to be it, at first glance.
>
> Thanks, --DD
>
> c:\Users\ddevienne>psql
> psql (12.1, server 14.2)
> WARNING: psql major version 12, server major version 14.
> Some psql features might not work.
> WARNING: Console code page (437) differs from Windows code page (1252)
> 8-bit characters might not work correctly. See psql reference
> page "Notes for Windows users" for details.
> Type "help" for help.
>
> ddevienne=>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ewie@mailbox.org, ddevienne@gmail.com
Subject: Re: Who am I? Where am I connected?
In-Reply-To: <541270671.1136671.1652869774367@office.mailbox.org>
References: <CAFCRh-_BSW8VRPPQU6OrKmLZmk1+-0GvbBObgkMmqWf2_YqMkQ@mail.gmail.com> <541270671.1136671.1652869774367@office.mailbox.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox