> 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@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@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@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@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.
v8-0001-psql-meta-command-conninfo-plus.patch
Description: v8-0001-psql-meta-command-conninfo-plus.patch