psql: Option to use expanded mode for various meta-commands
Dean Rasheed <dean.a.rasheed@gmail.com>
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-12-30T09:10:42Z
Lists: pgsql-hackers
Attachments
- psql-meta-cmds-expanded-mode.patch (text/x-patch) patch
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
Commits
-
psql: Add option to use expanded mode to all list commands.
- 00f4c2959d63 18.0 landed