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 1rXQ2Y-00AYxe-AP for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Feb 2024 18:19:26 +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 1rXQ2X-005tH6-Dk for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Feb 2024 18:19:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rXQ2X-005tGw-4Y for pgsql-hackers@lists.postgresql.org; Tue, 06 Feb 2024 18:19:25 +0000 Received: from mail-il1-x134.google.com ([2607:f8b0:4864:20::134]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rXQ2U-005P7P-F9 for pgsql-hackers@postgresql.org; Tue, 06 Feb 2024 18:19:23 +0000 Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-363ad0203c8so18972745ab.2 for ; Tue, 06 Feb 2024 10:19:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707243561; x=1707848361; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=HaF8uXnVffA40ND0C8XjEUNGiT8hJuvwzt5MDGmG/XU=; b=WTphDUmWjGmtg6BRfXFdLxnUZxwj2WHf6KGV9X8MepItgRQodHvFvHLLN/LTCzjF2z pTZA1GTp3yMOoP2KD85oaqFVMotupnnCwU4ZfPwLss4mrcQwhlkwJvKgtP3elTraUECg E4YmHEgCqkdbbKLewSt9ejHBWOzbomWY5Ud5xvzky0/r8mAiSYmEyCKRWYvXJWsE477w jQoGf+bqxRwD+lNF4DC4br62T7xpA4wPg3FADYHfVH+LEBaJyV8/sdrpjANG6wDnQzgd IloAFLZlKqyuv47wLeMdl0mPotJSaisqf5gjAqO6ZpDmKQEoMYhc3ZjYWtjwbhibwe34 hlxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707243561; x=1707848361; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=HaF8uXnVffA40ND0C8XjEUNGiT8hJuvwzt5MDGmG/XU=; b=wyOZ+ARHQ0Lyz2nNh9YI5+OSypYXE9WL4+FNmostrFITxEHMGs3JoZhbJIjnt2wdIT wwsnZo3TkkVGF3rhwuX17cst6hg2a18iIYqmLdUaQwBnlqEf9K6YeGugCA8RMRJxs3wf frl6Cxj4Jzr1JMtHXykG7TV2KggHVJY5fRGKEUXpmKvlHh3aN0jvH/MpSXrjFyIeD5dz WkFdPW7a3FILhNFkV3OgSLYuqVlVLxpCcDG3mYPijqclAiPp5zOw8bDNPLDIrR6S5N+x 3dx/3dcjL9lZP6ci/8s9cnZkkXe9s3mpLq3RqTc+eVjHm+Sx2TdF/b0O4YIm/ahARWZQ d/bQ== X-Gm-Message-State: AOJu0Ywj0Iv4NIcwfnuFer1hqExn9cLHvjCgLiE3hezvoetIPsg3GZTB ZdDZjHbhb7SuEM0ZiATKHyXjHu+D7vx8d6vidvoRzR8tTBv32GBp X-Google-Smtp-Source: AGHT+IG+EFOa783/a7QdQnkn7Y94/GW0R1dtIi6+/VBtp85Yg1sZ/p+ytaqiHtMb6Bc6K2N6mHAUGA== X-Received: by 2002:a05:6e02:164e:b0:363:ccb2:3588 with SMTP id v14-20020a056e02164e00b00363ccb23588mr4583022ilu.6.1707243561481; Tue, 06 Feb 2024 10:19:21 -0800 (PST) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id t10-20020a056e02010a00b003638ac1284esm659858ilm.29.2024.02.06.10.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 10:19:21 -0800 (PST) Date: Tue, 6 Feb 2024 12:19:19 -0600 From: Nathan Bossart To: Maiquel Grassi Cc: "pgsql-hackers@postgresql.org" Subject: Re: Psql meta-command conninfo+ Message-ID: <20240206181919.GA3853632@nathanxps13> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Feb 06, 2024 at 05:27:01PM +0000, Maiquel Grassi wrote: > I'm seeking to improve the \conninfo meta-command in psql. Currently, it > provides limited information about the current connection. I believe that > expanding it using the concept of "plus" [+] could ease the work of DBAs, > SysAdmins, DevOps, etc., who manage a large volume of databases and/or > multiple PostgreSQL servers. The objective of this enhancement is to > obtain quick information about the current connection (session). I > believe that for a PostgreSQL administrator, it is not feasible to write > a plpgsql function and apply it to all databases (for example, imagine > managing over 200 databases). I have an example on GitHub > https://github.com/maiquelgrassi/DBA-toolkit/blob/main/cluster/dba_whoami_function.sql > of a plpgsql function demonstrating exactly what I believe is impractical > for the daily routine of a PostgreSQL professional. I see psql's > meta-commands as significant allies in daily work in productive > environments. This seems like a reasonable idea to me. > postgres=# \conninfo+ > Current Connection Information > Attribute | Value > ----------------+---------------- > Database | postgres > User | postgres > Server Version | 16.1 > Server Address | 192.168.0.5/32 > Server Port | 5433 > Client Address | 192.168.0.5/32 > Client Port | 52716 > Session PID | 21624 > (8 rows) My first reaction is that this should instead return a single row with the same set of columns for any connection type (the not-applicable ones would just be set to NULL). That would match the other meta-commands like \l and \du, and you could still get an expanded display with \x if needed. Also, I think it would simplify the code a bit. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com