1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-07 19:06:32 +03:00

Allow psql's \g and \gx commands to transiently change \pset options.

We invented \gx to allow the "\pset expanded" flag to be forced on
for the duration of one command output, but that turns out to not
be nearly enough to satisfy the demand for variant output formats.
Hence, make it possible to change any pset option(s) for the duration
of a single command output, by writing "option=value ..." inside
parentheses, for example
	\g (format=csv csv_fieldsep='\t') somefile

\gx can now be understood as a shorthand for including expanded=on
inside the parentheses.

Patch by me, expanding on a proposal by Pavel Stehule

Discussion: https://postgr.es/m/CAFj8pRBx9OnBPRJVtfA5ycUpySge-XootAXAsv_4rrkHxJ8eRg@mail.gmail.com
This commit is contained in:
Tom Lane
2020-04-07 17:46:29 -04:00
parent 0f5ca02f53
commit b63c293bcb
8 changed files with 315 additions and 47 deletions

View File

@@ -38,6 +38,13 @@ SELECT 3 as three, 4 as four \gx
\unset FETCH_COUNT
-- \g/\gx with pset options
SELECT 1 as one, 2 as two \g (format=csv csv_fieldsep='\t')
\g
SELECT 1 as one, 2 as two \gx (title='foo bar')
\g
-- \gset
select 10 as test01, 20 as test02, 'Hello' as test03 \gset pref01_