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 1kLYSP-0000ci-Mp for pgsql-bugs@arkaria.postgresql.org; Thu, 24 Sep 2020 21:07:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kLYSO-0007WG-BC for pgsql-bugs@arkaria.postgresql.org; Thu, 24 Sep 2020 21:07:12 +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 1kLYSO-0007W9-4v for pgsql-bugs@lists.postgresql.org; Thu, 24 Sep 2020 21:07:12 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kLYSH-0007zR-9W for pgsql-bugs@lists.postgresql.org; Thu, 24 Sep 2020 21:07:11 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1kLYSF-0005sy-Pe; Thu, 24 Sep 2020 17:07:03 -0400 Date: Thu, 24 Sep 2020 17:07:03 -0400 From: Bruce Momjian To: anderson.ant.oli@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16628: Hostame and string connection functions Message-ID: <20200924210703.GF22807@momjian.us> References: <16628-30860059aed1dd59@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16628-30860059aed1dd59@postgresql.org> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Sep 22, 2020 at 06:57:13PM +0000, PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 16628 > Logged by: Anderson Antunes > Email address: anderson.ant.oli@gmail.com > PostgreSQL version: 9.5.0 > Operating system: Linux > Description: > > Hi, > > Is there any possibility of developing a function to retrieve hostname and > the connection string? > > Example: > > select get_host_name (); You can get the server IP address, but not the host name: test=> SELECT inet_server_addr(); inet_server_addr ------------------ 127.0.0.1 > select get_string_connection (); Uh, the connection information is parsed by libpq, and visible in psql: test=> \conninfo You are connected to database "test" as user "postgres" on host "localhost" (address "127.0.0.1") at port "5432". but the server only sees the result. You can see the server port number: test=> SELECT inet_server_port(); inet_server_port ------------------ 5432 I can't figure out how to query the SSL mode via SQL. Does this help? -- Bruce Momjian https://momjian.us EnterpriseDB https://enterprisedb.com The usefulness of a cup is in its emptiness, Bruce Lee