One-shot expanded output in psql using \G
Christoph Berg <christoph.berg@credativ.de>
From: Christoph Berg <christoph.berg@credativ.de>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2017-01-27T13:27:37Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
psql: Fix \gx when FETCH_COUNT is used
- 0cdc3e47bea4 11.0 landed
- 51d0fa8ed93f 10.0 landed
-
psql: Add \gx command
- b2678efd43f1 10.0 landed
Attachments
- expanded-mode-G.patch (text/x-diff) patch
- (unnamed) (text/plain)
I frequently find myself in the situation that I want the "\x" expanded output mode activated just for one query. There's little wrong with typing "\x" and re-executing the query in that case, but then I'm always annoyed that the expanded output is still active for the next query after that. "\x auto" is not a fix for the problem; I have set up the pager to use "less -S" (non-wrapping) by default so I can scroll right/left through the query result instead of having it spread over several terminal lines. A workaround is to submit queries using "\x\g\x", but that's ugly, clutters the output with toggle messages, and will forget that "\x auto" was set. Mysql's CLI client is using \G for this purpose, and adding the very same functionality to psql fits nicely into the set of existing backslash commands: \g sends the query buffer, \G will do exactly the same as \g (including parameters), but forces expanded output just for this query. The same idea was discussed back in 2008. Back then the outcome was that "\x auto" was implemented, but I still think that \G is a useful feature to have on its own, and several people in the thread seem to have agreed back then. Patch attached, I'll add it to the next commit fest. Mit freundlichen Grüßen, Christoph Berg -- Senior Berater, Tel.: +49 2166 9901 187 credativ GmbH, HRB Mönchengladbach 12080, USt-ID-Nummer: DE204566209 Trompeterallee 108, 41189 Mönchengladbach Geschäftsführung: Dr. Michael Meskes, Jörg Folz, Sascha Heuer pgp fingerprint: 5C48 FE61 57F4 9179 5970 87C6 4C5A 6BAB 12D2 A7AE