RE: Psql meta-command conninfo+ - Mailing list pgsql-hackers
From | Maiquel Grassi |
---|---|
Subject | RE: Psql meta-command conninfo+ |
Date | |
Msg-id | CP8P284MB24969B39579E808F9F44CCF8EC4D2@CP8P284MB2496.BRAP284.PROD.OUTLOOK.COM Whole thread Raw |
In response to | Re: Psql meta-command conninfo+ (Jim Jones <jim.jones@uni-muenster.de>) |
Responses |
RE: Psql meta-command conninfo+
|
List | pgsql-hackers |
>A little odd is that "Server Address" of \conninfo+ differs from
>"address" of \conninfo...
----//----
Hi Jim!
Tests performed on CentOS Linux 7.
I made some further observations and concluded that there will
be more cases where the "address" from \conninfo will differ from
the "Server Address" from \conninfo+. Below is a more detailed example.
The input of "hostaddr" or "host" in the psql call can be any pointing to
"loopback local" and the connection will still be established. For example,
all of these are accepted:
Case (inet):
psql -x --host 0
psql -x --host 0.0.0.0
psql -x hostaddr=0
psql -x hostaddr=0.0.0.0
All these examples will have "Server Address" = 127.0.0.1
Case (inet6):
psql -x --host ::
psql -x --host * (this entry is not accepted)
psql -x --host \*
psql -x --host "*"
psql -x hostaddr=::
psql -x hostaddr=*
All these examples will have "Server Address" = ::1
Thus, the inet_server_addr() function will return 127.0.0.1 or ::1 which in some cases will differ from the "address" from \conninfo.
[postgres@localhost bin]$ ./psql -x hostaddr=0
As demonstrated above, "address" = 0.0.0.0 and "Server Address" = 127.0.0.1 are divergent.
In practice, these IPs are the "same", and the ping from the example proves it.
However, we are concerned here with the psql user, and this may seem confusing to them at
first glance. I would like to propose a change in "address" so that it always returns the same as
"Server Address", that is, to use the inet_server_address() function in "address".
Result:
[postgres@localhost bin]$ ./psql -x hostaddr=0
>I think the documentation could add a little more info than just this:
>> When no + is specified, it simply prints a textual description of a
>>few connection options. When + is given, more complete information is
>>displayed as a table.
>Perhaps briefly mentioning the returned columns or simply listing them
>would be IMHO a nice addition. For some users the semantics of
>"Authenticated User", "System User", "Current User" and "Session User"
>can be a little confusing. And yes, I realize the current documentation
>of \conninfo is already a little vague :).
Your suggestion was well received, and I'will made the adjustment to make
the command description more comprehensive.
Here is version v15 where I sought to correct 'Adress' to make it the same
as 'Server Address'.
Could you perform the same test and validate?
Thank you so much!
Maiquel Grassi.
Attachment
pgsql-hackers by date: