Lists: | pgsql-hackers |
---|
From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | psql: Option to use expanded mode for various meta-commands |
Date: | 2024-12-30 09:10:42 |
Message-ID: | CAEZATCVXJk3KsmCncf7PAVbxdDAUDm3QzDgGT7mBYySWikuOYw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
The output from various psql meta-commands such as \df+ can be quite
wide, making it hard to read, and there is another patch [1] that will
make it even wider. The output is much more readable if expanded mode
is used, but it's somewhat inconvenient to keep turning that on and
off, if you don't want all other query output in expanded mode.
Attached is a rough patch that adds 'x' as an option to all \d* psql
meta-commands, which forces the output to be displayed in expanded
mode. So, for example, you can type \dfx or \dfx+ (or equivalently
\df+x) to show a list of functions in expanded mode.
This applies to all \d* meta-commands except a bare \d. That
limitation is necessary because \dx already means something else (list
extensions). In the case of \d with a pattern, this limitation isn't
really new, since that already always uses expanded=off for its output
regardless of the current \x setting. However, it does mean that you
can't use 'x' with \d without a pattern to get an expanded mode list
of all relations. However, the limitation only applies as long as
there isn't another character after the \d, so you can type \d+x and
it will work the same as \dtvmsE+x, listing all relations in expanded
mode. So in practice, this doesn't seem like such a bad limitation,
since you're much less likely to need expanded mode with \d without
'+'.
There are a couple of other similar meta-commands (\l and \z) that I
haven't looked at yet, but they should be easy to make work in the
same way, if people think this is useful.
Regards,
Dean
Attachment | Content-Type | Size |
---|---|---|
psql-meta-cmds-expanded-mode.patch | text/x-patch | 26.8 KB |
From: | Greg Sabino Mullane <htamfids(at)gmail(dot)com> |
---|---|
To: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: psql: Option to use expanded mode for various meta-commands |
Date: | 2024-12-30 15:48:13 |
Message-ID: | CAKAnmmJVHmW1K_A-FcxzcKYJck=jXJ6D80NEcCMnMcc6Y2xLKg@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
I like this, very useful. It's a shame about the conflict with \dx (lesson
for the future: think extra carefully about option namings!). I am
impressed that \dx \d \d+ \d+x and even \dxx all work as one might
intuit with this patch.
Cheers,
Greg
From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
---|---|
To: | Greg Sabino Mullane <htamfids(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: psql: Option to use expanded mode for various meta-commands |
Date: | 2025-01-08 13:43:57 |
Message-ID: | CAEZATCUyLVQ-Ara0=944ubJY3t0qCiGz7e1o0tgftue3g-jLew@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Mon, 30 Dec 2024 at 15:48, Greg Sabino Mullane <htamfids(at)gmail(dot)com> wrote:
>
> I like this, very useful. It's a shame about the conflict with \dx (lesson for the future: think extra carefully about option namings!). I am impressed that \dx \d \d+ \d+x and even \dxx all work as one might intuit with this patch.
>
Thanks for looking.
Attached is a more complete patch, now with
- trivial bug-fix for previous \d code, per cfbot
- expanded mode support for \l and \z
- updated psql help
- a few representative regression test cases
The majority of the patch is doc updates, which are somewhat tedious.
Initially, I resisted documenting the 'x' option in the description of
every command affected, but given the length of the list of commands
in the HTML page, it's a long way from any given command to the top or
bottom where 'x' is described in more detail. So in the end, I decided
to just add a sentence to each command's description, keeping it as
short as possible.
Regards,
Dean
Attachment | Content-Type | Size |
---|---|---|
psql-meta-cmds-expanded-mode-v2.patch | text/x-patch | 63.5 KB |
From: | Greg Sabino Mullane <htamfids(at)gmail(dot)com> |
---|---|
To: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: psql: Option to use expanded mode for various meta-commands |
Date: | 2025-01-09 03:18:20 |
Message-ID: | CAKAnmmJfuCppyvVc1HrEHT67KSfz_uJdDw4frw2k1gDqM2sVTg@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Wed, Jan 8, 2025 at 8:44โฏAM Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
wrote:
> Attached is a more complete patch
+1, looks good
So in the end, I decided to just add a sentence to each command's
> description, keeping it as
> short as possible.
>
Yes, that makes sense.
Cheers,
Greg
From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
---|---|
To: | Greg Sabino Mullane <htamfids(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: psql: Option to use expanded mode for various meta-commands |
Date: | 2025-01-14 17:10:02 |
Message-ID: | CAEZATCVyR=BwVC79G9NQiJLuh-nCn2z6s0B-qsWw5GCKwcC-JA@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, 9 Jan 2025 at 03:18, Greg Sabino Mullane <htamfids(at)gmail(dot)com> wrote:
>
> On Wed, Jan 8, 2025 at 8:44โฏAM Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
>>
>> Attached is a more complete patch
>
> +1, looks good
>
Thanks for looking. I've pushed this now.
(I realised that I had missed \lo_list, so I added support for that
too, since it would have been odd to allow "x" in \dl, but not
\lo_list.)
Regards,
Dean