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

Tom Lane <tgl@sss.pgh.pa.us>

Commit: b63c293bcbd7439f883cd4cf748f6755df0fbb3c
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2020-04-07T21:46:29Z
Releases: 13.0
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

Files

PathChange+/−
doc/src/sgml/ref/psql-ref.sgml modified +62 −14
src/bin/psql/command.c modified +204 −14
src/bin/psql/command.h modified +4 −0
src/bin/psql/common.c modified +8 −13
src/bin/psql/help.c modified +5 −4
src/bin/psql/settings.h modified +3 −2
src/test/regress/expected/psql.out modified +22 −0
src/test/regress/sql/psql.sql modified +7 −0

Documentation touched

Discussion