pgsql: Allow psql's \g and \gx commands to transiently change \pset opt

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Allow psql's \g and \gx commands to transiently change \pset opt
Date: 2020-04-07 21:46:34
Message-ID: E1jLw3G-0001QE-Ra@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b63c293bcbd7439f883cd4cf748f6755df0fbb3c

Modified Files
--------------
doc/src/sgml/ref/psql-ref.sgml | 76 ++++++++++---
src/bin/psql/command.c | 218 ++++++++++++++++++++++++++++++++++---
src/bin/psql/command.h | 4 +
src/bin/psql/common.c | 21 ++--
src/bin/psql/help.c | 9 +-
src/bin/psql/settings.h | 5 +-
src/test/regress/expected/psql.out | 22 ++++
src/test/regress/sql/psql.sql | 7 ++
8 files changed, 315 insertions(+), 47 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Anna Akenteva 2020-04-07 22:34:28 Re: pgsql: Implement waiting for given lsn at transaction start
Previous Message David G. Johnston 2020-04-07 21:45:59 Re: pgsql: Implement waiting for given lsn at transaction start