Thread
Commits
-
psql: Add option to use expanded mode to all list commands.
- 00f4c2959d63 18.0 landed
-
psql: Option to use expanded mode for various meta-commands
Dean Rasheed <dean.a.rasheed@gmail.com> — 2024-12-30T09:10:42Z
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 [1] https://www.postgresql.org/message-id/flat/20240701220817.483f9b645b95611f8b1f65da@sranhm.sraoss.co.jp
-
Re: psql: Option to use expanded mode for various meta-commands
Greg Sabino Mullane <htamfids@gmail.com> — 2024-12-30T15:48:13Z
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
-
Re: psql: Option to use expanded mode for various meta-commands
Dean Rasheed <dean.a.rasheed@gmail.com> — 2025-01-08T13:43:57Z
On Mon, 30 Dec 2024 at 15:48, Greg Sabino Mullane <htamfids@gmail.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
-
Re: psql: Option to use expanded mode for various meta-commands
Greg Sabino Mullane <htamfids@gmail.com> — 2025-01-09T03:18:20Z
On Wed, Jan 8, 2025 at 8:44 AM Dean Rasheed <dean.a.rasheed@gmail.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
-
Re: psql: Option to use expanded mode for various meta-commands
Dean Rasheed <dean.a.rasheed@gmail.com> — 2025-01-14T17:10:02Z
On Thu, 9 Jan 2025 at 03:18, Greg Sabino Mullane <htamfids@gmail.com> wrote: > > On Wed, Jan 8, 2025 at 8:44 AM Dean Rasheed <dean.a.rasheed@gmail.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