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 1rawF5-00CDaV-SF for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Feb 2024 11:18:56 +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 1rawF4-001OYb-Jm for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Feb 2024 11:18:54 +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 1rawF4-001OYT-5p for pgsql-hackers@lists.postgresql.org; Fri, 16 Feb 2024 11:18:54 +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 1rawF1-007Uim-HD for pgsql-hackers@postgresql.org; Fri, 16 Feb 2024 11:18:53 +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=1708082331; x=1739618331; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=cZ2k5FEGsu5+R/tC0vUWHVdnsa8YhASYC3Bjd0rczYI=; b=LQ8VvVo5gp1EzY9+InbZgYPZaMCbt4YIyl+GTeVYnupG5kDyWo0Xkddc wUGiRdNEJzTGwjSh/7R52xj128E4zGnAIDIAafyDr6mjhVwXMbiGcWDxg kAIHMRsjSh6II2olL8TZ4GxbcicfNh5UO4qRz4kQkc104hjkpCSKwD3up I+CrSmNk8QFTjt3MdVqZckVyMiUGPyF3m5tcn5G7wldx1eZHSxLLF1Tqx PKzXO+aW5FskW1e93ua3y7Gs9PtMMfPjG6OY+vtsqadbr4MfeFu1b2o4C yjRHCHFa70WJY0P2ZQ7hokl9Hsq2e5bdb4u6kus0LjXbYR0+hYL6Qk/dz w==; X-CSE-ConnectionGUID: Qb1Qlrr9Qr+mOKy5eQs69w== X-CSE-MsgGUID: Mik4cG9STqSkCo/pIBcWAg== X-IronPort-AV: E=Sophos;i="6.06,164,1705359600"; d="scan'208";a="307961252" Received: from secmail.uni-muenster.de ([128.176.118.4]) by UDCM-RELAY2.UNI-MUENSTER.DE with ESMTP; 16 Feb 2024 12:18:48 +0100 Received: from [192.168.178.27] (dynamic-078-049-110-017.78.49.pool.telefonica.de [78.49.110.17]) by SECMAIL.UNI-MUENSTER.DE (Postfix) with ESMTPSA id 17FBE20ADF19; Fri, 16 Feb 2024 12:18:46 +0100 (CET) Message-ID: <8a93f6c0-795f-4260-a5fd-07ccbddbc88f@uni-muenster.de> Date: Fri, 16 Feb 2024 12:18:45 +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: <20240206215022.GA3452@nathanxps13> <852cabef-f596-4826-9a54-d3f75d9a6cc8@postgrespro.ru> <49edac91-d47f-4cac-ae12-d51cabbd87c9@postgrespro.ru> <49635a5b-3d32-4f05-8ce4-c55c70181888@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 15.02.24 23:16, Maiquel Grassi wrote: > > Hi! > > (v16) > > In this version, I made a small adjustment to the indentation > of the \conninfo code and described the columns as returned > by \conninfo+ as suggested by Jim Jones. > > I've performed the following tests with v16: 1) hostaddr=172.19.42.1 $ /usr/local/postgres-dev/bin/psql -x "\     host=server.uni-muenster.de     hostaddr=172.19.42.1     user=jim dbname=postgres     sslrootcert=server-certificates/server.crt     sslcert=jim-certificates/jim.crt     sslkey=jim-certificates/jim.key" -c "\conninfo+" -c "\conninfo" Current Connection Information -[ RECORD 1 ]------+--------------------------------------------------------------------------------------------------------------------------- Database           | postgres Authenticated User | jim System User        | cert:emailAddress=wwwadmin@uni-muenster.de,CN=jim,OU=WWU IT,O=Universitaet Muenster,L=Muenster,ST=Nordrhein-Westfalen,C=DE Current User       | jim Session User       | jim Backend PID        | 386839 Server Address     | 172.19.42.1 Server Port        | 5432 Client Address     | 192.168.178.27 Client Port        | 35602 Socket Directory   | Host               | server.uni-muenster.de Encryption         | SSL Protocol           | TLSv1.3 Cipher             | TLS_AES_256_GCM_SHA384 Compression        | off You are connected to database "postgres" as user "jim" on host "server.uni-muenster.de" (address "172.19.42.1") at port "5432". SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off) The same with non-superusers $ /usr/local/postgres-dev/bin/psql -x "\     host=server.uni-muenster.de     hostaddr=172.19.42.1     user=jim dbname=postgres     sslrootcert=server-certificates/server.crt     sslcert=jim-certificates/jim.crt     sslkey=jim-certificates/jim.key" -c "SET ROLE foo" -c "\conninfo+" -c "\conninfo" SET Current Connection Information -[ RECORD 1 ]------+--------------------------------------------------------------------------------------------------------------------------- Database           | postgres Authenticated User | jim System User        | cert:emailAddress=wwwadmin@uni-muenster.de,CN=jim,OU=WWU IT,O=Universitaet Muenster,L=Muenster,ST=Nordrhein-Westfalen,C=DE Current User       | foo Session User       | jim Backend PID        | 547733 Server Address     | 172.19.42.1 Server Port        | 5432 Client Address     | 192.168.178.27 Client Port        | 58508 Socket Directory   | Host               | server.uni-muenster.de Encryption         | SSL Protocol           | TLSv1.3 Cipher             | TLS_AES_256_GCM_SHA384 Compression        | off You are connected to database "postgres" as user "jim" on host "server.uni-muenster.de" (address "172.19.42.1") at port "5432". SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off) 2) -h 192.168.178.27 $ /usr/local/postgres-dev/bin/psql -x -U postgres -h 192.168.178.27 -c "\conninfo+" -c "\conninfo" Current Connection Information -[ RECORD 1 ]------+----------------------- Database           | postgres Authenticated User | postgres System User        | Current User       | postgres Session User       | postgres Backend PID        | 399670 Server Address     | 192.168.178.27 Server Port        | 5432 Client Address     | 192.168.178.27 Client Port        | 44174 Socket Directory   | Host               | 192.168.178.27 Encryption         | SSL Protocol           | TLSv1.3 Cipher             | TLS_AES_256_GCM_SHA384 Compression        | off You are connected to database "postgres" as user "postgres" on host "192.168.178.27" at port "5432". SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off) 3) via socket $ /usr/local/postgres-dev/bin/psql -x -U postgres -c "\conninfo+" -c "\conninfo" Current Connection Information -[ RECORD 1 ]------+--------- Database           | postgres Authenticated User | postgres System User        | Current User       | postgres Session User       | postgres Backend PID        | 394273 Server Address     | Server Port        | 5432 Client Address     | Client Port        | Socket Directory   | /tmp Host               | You are connected to database "postgres" as user "postgres" via socket in "/tmp" at port "5432". 4) -h 127.0.0.1 $ /usr/local/postgres-dev/bin/psql -x -U postgres -h 127.0.0.1 -c "\conninfo+" -c "\conninfo" Current Connection Information -[ RECORD 1 ]------+----------------------- Database           | postgres Authenticated User | postgres System User        | Current User       | postgres Session User       | postgres Backend PID        | 396070 Server Address     | 127.0.0.1 Server Port        | 5432 Client Address     | 127.0.0.1 Client Port        | 52528 Socket Directory   | Host               | 127.0.0.1 Encryption         | SSL Protocol           | TLSv1.3 Cipher             | TLS_AES_256_GCM_SHA384 Compression        | off You are connected to database "postgres" as user "postgres" on host "127.0.0.1" at port "5432". SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off) 5) -h localhost $ /usr/local/postgres-dev/bin/psql -x -U postgres -h localhost -c "\conninfo+" -c "\conninfo" Current Connection Information -[ RECORD 1 ]------+----------------------- Database           | postgres Authenticated User | postgres System User        | Current User       | postgres Session User       | postgres Backend PID        | 397056 Server Address     | 127.0.0.1 Server Port        | 5432 Client Address     | 127.0.0.1 Client Port        | 53578 Socket Directory   | Host               | localhost Encryption         | SSL Protocol           | TLSv1.3 Cipher             | TLS_AES_256_GCM_SHA384 Compression        | off You are connected to database "postgres" as user "postgres" on host "localhost" (address "127.0.0.1") at port "5432". SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off) 6) -h 0 $ /usr/local/postgres-dev/bin/psql -x -U postgres -h 0 -c "\conninfo+" -c "\conninfo" Current Connection Information -[ RECORD 1 ]------+----------------------- Database           | postgres Authenticated User | postgres System User        | Current User       | postgres Session User       | postgres Backend PID        | 406342 Server Address     | 127.0.0.1 Server Port        | 5432 Client Address     | 127.0.0.1 Client Port        | 38674 Socket Directory   | Host               | 0 Encryption         | SSL Protocol           | TLSv1.3 Cipher             | TLS_AES_256_GCM_SHA384 Compression        | off You are connected to database "postgres" as user "postgres" on host "0" (address "127.0.0.1") at port "5432". SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off) 7) -h 0.0.0.0 - As you mentioned, this is one of the cases where host and "server address" differ.    I am not sure if it is an issue. Perhaps the other reviewers might have an opinion on it $ /usr/local/postgres-dev/bin/psql -x -U postgres -h 0.0.0.0 -c "\conninfo+" -c "\conninfo" Current Connection Information -[ RECORD 1 ]------+----------------------- Database           | postgres Authenticated User | postgres System User        | Current User       | postgres Session User       | postgres Backend PID        | 404395 Server Address     | 127.0.0.1 Server Port        | 5432 Client Address     | 127.0.0.1 Client Port        | 54806 Socket Directory   | Host               | 0.0.0.0 Encryption         | SSL Protocol           | TLSv1.3 Cipher             | TLS_AES_256_GCM_SHA384 Compression        | off You are connected to database "postgres" as user "postgres" on host "0.0.0.0" at port "5432". SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off) > 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". I'm not sure of the impact of this change in the existing \conninfo - at least the cfbot and "make -j check-world" didn't complain. I'll take a closer look at it as soon we have test cases. Docs: +        \conninfo[+]                            Outputs information about the current database connection. +        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. +        To keep it consistent with the other options, we might wanna use "+ is appended" instead of "+ is specified" or "+ is given" +        When + is given, more complete information +        is displayed as a table. +        + +        +        "Database", "Authenticated User", "System User" (only for PostgreSQL 16 or higher), +        "Current User", "Session User", "Backend PID", "Server Address", "Server Port", +        "Client Address", "Client Port", "Socket Directory", and "Host" columns are listed +        by default when \conninfo+ is invoked. The columns "Encryption", +        "Protocol", "Cipher", and "Compression" are added to this output when TLS (SSL) +        authentication is used. The same applies to GSS authentication is used, where the +        "GSSAPI" column is also added to the \conninfo+ output. I think that a list with a brief description of all columns would be more interesting in this case (it is just a suggestion based on personal taste, so feel to ignore it) I had something along these lines in mind: Outputs a string containing information about the current database connection. When + is appended, it outputs a table containing the following columns: * Database: lorem ipsum * Authenticated User:lorem ipsum * System User: lorem ipsum * Current User: lorem ipsum * Session User: lorem ipsum * Backend PID: lorem ipsum * Server Address: lorem ipsum * Server Port: lorem ipsum * Client Address:lorem ipsum * Client Port: lorem ipsum * Socket Directory: lorem ipsum * Host: lorem ipsum TLS (SSL) authentication These columns are added to the table TLS (SSL) authentication is used * Encryption:lorem ipsum * Cipher:lorem ipsum * Protocol:lorem ipsum GSS authentication ... ... Thanks -- Jim