pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow psql's \g and \gx commands to transiently change \pset opt
Date: Tue, 07 Apr 2020 21:46:34 +0000
Message-ID: <E1jLw3G-0001QE-Ra@gemulon.postgresql.org> (raw)

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(-)



Message-ID: <E1jLw3G-0001QE-Ra@gemulon.postgresql.org>
Permalink:  ../E1jLw3G-0001QE-Ra@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1jLw3G-0001QE-Ra@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Allow psql's \g and \gx commands to transiently change \pset opt
  In-Reply-To: <E1jLw3G-0001QE-Ra@gemulon.postgresql.org>
  References: <E1jLw3G-0001QE-Ra@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox