Re: BUG #16628: Hostame and string connection functions

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: anderson(dot)ant(dot)oli(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16628: Hostame and string connection functions
Date: 2020-09-24 21:07:03
Message-ID: 20200924210703.GF22807@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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(dot)ant(dot)oli(at)gmail(dot)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 <bruce(at)momjian(dot)us> https://momjian.us
EnterpriseDB https://enterprisedb.com

The usefulness of a cup is in its emptiness, Bruce Lee

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Fujii Masao 2020-09-25 00:46:58 Re: PG13 pg_receivewal failing
Previous Message Grigory Smolkin 2020-09-24 20:51:34 PG13 pg_receivewal failing