Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nrGw3-0006Fv-72 for pgsql-general@arkaria.postgresql.org; Wed, 18 May 2022 10:29:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nrGw1-0001vH-Qe for pgsql-general@arkaria.postgresql.org; Wed, 18 May 2022 10:29:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nrGw1-0001v7-EC for pgsql-general@lists.postgresql.org; Wed, 18 May 2022 10:29:41 +0000 Received: from mout-p-202.mailbox.org ([80.241.56.172]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nrGvz-0001yU-1o for pgsql-general@lists.postgresql.org; Wed, 18 May 2022 10:29:40 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4L38PC3XGYz9snF; Wed, 18 May 2022 12:29:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1652869775; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qVbf4S4ulaWXH2nTkHEOj2prDmPHkA6A1dRAos2cRQU=; b=dcCaflu+hvvQtff9j+eea+4LOJnr+0T6zmSa7nIIye72XX7NVp+SesJycdmmIigGGsDXQ1 PDecsH88n5Q3j0komE+yEsH76ARbZiM15ekP5TTS19OCSFS+GZf4Cs2fsmxtD0FiFK4yGq coj4G6+Xx85/ujKCLENGGwwjj0aaTtrJKYrNJtFrFdlKl72LOG8o9sJI5qcB1xffbeyg4o /qnjsOjopHfclmcNgy2uiA3PxdlMuWGtUl9WJMf8Kr9sKNtFbbBy0TrroZV0kR4q3wcSZh +PomrxwGTDJmNZz5u/GQqlo6vniFz+Du9P1vF1TCH1FvUVFYQTbndfDdbq5+yg== Date: Wed, 18 May 2022 12:29:34 +0200 (CEST) From: Erik Wienhold To: Dominique Devienne , pgsql-general@lists.postgresql.org Message-ID: <541270671.1136671.1652869774367@office.mailbox.org> In-Reply-To: References: Subject: Re: Who am I? Where am I connected? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-MBO-RS-META: qegp5rd8wa15pgxrfppbyu3iwannar1x X-MBO-RS-ID: 18fa600b820b8e8f13e X-Rspamd-Queue-Id: 4L38PC3XGYz9snF List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 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=>