Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rYADT-00EfvW-EO for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Feb 2024 19:37:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rYADS-002KtF-8E for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Feb 2024 19:37:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rYADR-002Kt7-QX for pgsql-hackers@lists.postgresql.org; Thu, 08 Feb 2024 19:37:45 +0000 Received: from udcm-wwu2.uni-muenster.de ([128.176.118.28]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rYADP-006Awc-4k for pgsql-hackers@postgresql.org; Thu, 08 Feb 2024 19:37:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uni-muenster.de; i=@uni-muenster.de; q=dns/txt; s=uniout; t=1707421063; x=1738957063; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=0aWj0SECX9jc2q+qemG20yjc1mmEvrrkOR9jUL0KXEY=; b=OUHVXuMRqLVHcYgreXpy3+VnKhUhaN18+inT5qi31hlimLSAHvphtysM 8Ch8JqUI3UvQzqwETQbzKXL3B9T6DirlsTMA2QdYNWBIZig7puH1rhU6Q BnT9/OPULmhXd0PX8kfY4DDoedw6hsMaF8UOt+AoKhkrMTdvJUZNuflAQ C0ha9QSQ638FVz2RwQrhWqv49NyxJTXg3G6BtWC6pWPcoxAzd4OnaT/E+ ws25qH9cPrKT7Vsv+7jktly6HWoba8u8sjNiibt/m3EmeUb3U0Yv7sMn2 OXSII3tFLBdTvlXHS0fCHdI/t7CBt1HVXJHg+qaq3q+Ye/JV06MHOPcKZ g==; X-CSE-ConnectionGUID: PNpAzVLhSda4E5/cQJeprQ== X-CSE-MsgGUID: 0AzeH/kDQLe9f2pRNGPZXw== X-IronPort-AV: E=Sophos;i="6.05,254,1701126000"; d="scan'208";a="306914616" Received: from secmail.uni-muenster.de ([128.176.118.4]) by UDCM-RELAY2.UNI-MUENSTER.DE with ESMTP; 08 Feb 2024 20:37:41 +0100 Received: from [192.168.178.27] (dynamic-078-049-162-196.78.49.pool.telefonica.de [78.49.162.196]) by SECMAIL.UNI-MUENSTER.DE (Postfix) with ESMTPSA id 0703420ADF19; Thu, 8 Feb 2024 20:37:39 +0100 (CET) Message-ID: Date: Thu, 8 Feb 2024 20:37:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Psql meta-command conninfo+ Content-Language: en-US To: Maiquel Grassi , Pavel Luzanov , Nathan Bossart Cc: Erik Wienhold , "pgsql-hackers@postgresql.org" References: <20240206181919.GA3853632@nathanxps13> <20240206210605.GA3903769@nathanxps13> <20240206211205.GA3903996@nathanxps13> <20240206215022.GA3452@nathanxps13> <852cabef-f596-4826-9a54-d3f75d9a6cc8@postgrespro.ru> <47dcfd6f-d1d8-4a13-9bc5-b43ee9bd534f@uni-muenster.de> From: Jim Jones In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 08.02.24 16:50, Maiquel Grassi wrote: > 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 no longer throws a permission denied error for non-superusers - it is IMHO much nicer this way. $ /usr/local/postgres-dev/bin/psql postgres -p 5432 -h 127.0.0.1 -U jim psql (17devel) Type "help" for help. postgres=# \x Expanded display is on. postgres=# \conninfo+ Current Connection Information -[ RECORD 1 ]------+---------- Database           | postgres Authenticated User | jim System User        | Current User       | jim Session User       | jim Session PID        | 1321493 Server Version     | 17devel Server Address     | 127.0.0.1 Server Port        | 5432 Client Address     | 127.0.0.1 Client Port        | 49366 Socket Directory   | Host               | 127.0.0.1 postgres=# SET ROLE foo; SET postgres=> \conninfo+ Current Connection Information -[ RECORD 1 ]------+---------- Database           | postgres Authenticated User | jim System User        | Current User       | foo Session User       | jim Session PID        | 1321493 Server Version     | 17devel Server Address     | 127.0.0.1 Server Port        | 5432 Client Address     | 127.0.0.1 Client Port        | 49366 Socket Directory   | Host               | 127.0.0.1 The patch now applies cleanly. One thing I just noticed. The psql autocomplete feature does not suggest the new + option of \conninfo. For instance, when typing "\connin[TAB]" it automatically autocompletes to "\conninfo ". I guess it should also be included in this patch. I can do a more thorough review of the code when you add the documentation and tests to the patch. Thanks! -- Jim