From: | Maiquel Grassi <grassi(at)hotmail(dot)com(dot)br> |
---|---|
To: | Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>, Pavel Luzanov <p(dot)luzanov(at)postgrespro(dot)ru>, Nathan Bossart <nathandbossart(at)gmail(dot)com> |
Cc: | Erik Wienhold <ewie(at)ewie(dot)name>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | RE: Psql meta-command conninfo+ |
Date: | 2024-02-08 15:50:20 |
Message-ID: | CP8P284MB2496D053FD15C80780B72F46EC442@CP8P284MB2496.BRAP284.PROD.OUTLOOK.COM |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> On 07.02.24 21:13, Maiquel Grassi wrote:
>>
>> I believe in v7 patch we have a quite substantial meta-command feature.
>>
>>
> Thanks for implementing this. I find it very handy.
>
> I was just wondering if a "permission denied" error for non-superusers
> is the best choice for "\conninfo+":
>
> postgres=> \conninfo+
> ERROR: permission denied to examine "unix_socket_directories"
> DETAIL: Only roles with privileges of the "pg_read_all_settings" role
> may examine this parameter.
>
> .. since it is not the case with "\conninfo":
>
> postgres=> \conninfo
> You are connected to database "postgres" as user "jim" via socket in
> "/tmp" at port "5432".
>
> Perhaps excluding the column from the result set or returning NULL in
> the affected columns would be less confusing?
>
> There are also some indentation issues in your patch:
>
> /home/jim/Downloads/v7-0001-psql-meta-command-conninfo-plus.patch:142:
> indent with spaces.
> PGresult *res;
> /home/jim/Downloads/v7-0001-psql-meta-command-conninfo-plus.patch:143:
> indent with spaces.
> PQExpBufferData buf;
> /home/jim/Downloads/v7-0001-psql-meta-command-conninfo-plus.patch:144:
> indent with spaces.
> printQueryOpt myopt = pset.popt;
> /home/jim/Downloads/v7-0001-psql-meta-command-conninfo-plus.patch:146:
> indent with spaces.
> initPQExpBuffer(&buf);
> /home/jim/Downloads/v7-0001-psql-meta-command-conninfo-plus.patch:148:
> indent with spaces.
> printfPQExpBuffer(&buf,
> warning: squelched 34 whitespace errors
> warning: 39 lines add whitespace errors.
>
> Looking forward to see the documentation and tests!
--//--
Hi Jim,
Thank you for your support on this patch!
As I believe in its usability, I have been dedicating efforts to make it really interesting.
I hadn't thought about the permissioning issue for "unix_socket_directories". I appreciate that.
I thought about solving this situation using the same approach as \conninfo. I added the validation if (is_unixsock_path(host) && !(hostaddr && *hostaddr)) in the SQL part along with an "append". In case of a negative result, another "append" adds NULL.
Regarding the whitespace issue, before generating v8 patch file, I used pgindent to adjust each modified file. I believe it should be ok now. If you could verify, I'd be grateful.
Below are the tests after adjusting for the permissioning issues:
[postgres(at)localhost bin]$ ./psql
psql (17devel)
Type "help" for help.
postgres=# \conninfo
You are connected to database "postgres" as user "postgres" via socket in "/tmp" at port "5432".
postgres=# \conninfo+
Current Connection Information
Database | Authenticated User | System User | Current User | Session User | Session PID | Server Version | Server Address | Server Port | Client Address | Client Port | Socket Directory | Host
----------+--------------------+-------------+--------------+--------------+-------------+----------------+----------------+-------------+----------------+-------------+------------------+------
postgres | postgres | | postgres | postgres | 31479 | 17devel | | 5432 | | | /tmp |
(1 row)
postgres=# CREATE USER maiquel;
CREATE ROLE
postgres=# \q
[postgres(at)localhost bin]$ ./psql -U maiquel -d postgres
psql (17devel)
Type "help" for help.
postgres=> \conninfo
You are connected to database "postgres" as user "maiquel" via socket in "/tmp" at port "5432".
postgres=> \conninfo+
Current Connection Information
Database | Authenticated User | System User | Current User | Session User | Session PID | Server Version | Server Address | Server Port | Client Address | Client Port | Socket Directory | Host
----------+--------------------+-------------+--------------+--------------+-------------+----------------+----------------+-------------+----------------+-------------+------------------+------
postgres | maiquel | | maiquel | maiquel | 31482 | 17devel | | 5432 | | | /tmp |
(1 row)
postgres=> \q
[postgres(at)localhost bin]$ ./psql -h localhost -U maiquel -d postgres
psql (17devel)
Type "help" for help.
postgres=> \conninfo
You are connected to database "postgres" as user "maiquel" on host "localhost" (address "::1") at port "5432".
postgres=> \conninfo+
Current Connection Information
Database | Authenticated User | System User | Current User | Session User | Session PID | Server Version | Server Address | Server Port | Client Address | Client Port | Socket Directory | Host
----------+--------------------+-------------+--------------+--------------+-------------+----------------+----------------+-------------+----------------+-------------+------------------+-----------
postgres | maiquel | | maiquel | maiquel | 31485 | 17devel | ::1 | 5432 | ::1 | 47482 | | localhost
(1 row)
postgres=> \q
[postgres(at)localhost bin]$ ./psql -h localhost
psql (17devel)
Type "help" for help.
postgres=# \conninfo
You are connected to database "postgres" as user "postgres" on host "localhost" (address "::1") at port "5432".
postgres=# \conninfo+
Current Connection Information
Database | Authenticated User | System User | Current User | Session User | Session PID | Server Version | Server Address | Server Port | Client Address | Client Port | Socket Directory | Host
----------+--------------------+-------------+--------------+--------------+-------------+----------------+----------------+-------------+----------------+-------------+------------------+-----------
postgres | postgres | | postgres | postgres | 31488 | 17devel | ::1 | 5432 | ::1 | 47484 | | localhost
(1 row)
Regards,
Maiquel.
Attachment | Content-Type | Size |
---|---|---|
v8-0001-psql-meta-command-conninfo-plus.patch | application/octet-stream | 8.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-02-08 15:53:06 | Re: What about Perl autodie? |
Previous Message | Peter Eisentraut | 2024-02-08 15:06:36 | Re: Sequence Access Methods, round two |