From: David Fetter <david@fetter.org>
To: Christoph Berg <christoph.berg@credativ.de>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Subject: Re: One-shot expanded output in psql using \gx
Date: Wed, 8 Feb 2017 07:12:14 -0800
Message-ID: <20170208151214.GA8118@fetter.org> (raw)
In-Reply-To: <20170208145240.corb3zkmypn6snj2@msg.credativ.de>
References: <20170127132737.6skslelaf4txs6iw@msg.credativ.de>
<20170127150011.t6oynmocrgn4xd67@msg.credativ.de>
<20170206195412.icfsozuj2fxlbbsa@msg.df7cb.de>
<20170207051659.GC3552@fetter.org>
<20170208145240.corb3zkmypn6snj2@msg.credativ.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
On Wed, Feb 08, 2017 at 03:52:40PM +0100, Christoph Berg wrote:
> Re: David Fetter 2017-02-07 <20170207051659.GC3552@fetter.org>
> > On Mon, Feb 06, 2017 at 08:54:13PM +0100, Christoph Berg wrote:
> > > The majority of voices here was in favor of using \gx, so here is
> > > another version of the same patch which implements that.
> >
> > Patch is useful, and works as documented.
> >
> > Maybe it could get a test or two in src/test/regress/*/psql.*
>
> Good point. The new version tests \g and \gx with a new query, and
> re-running it on the last query buffer.
>
> ! /* \g [filename] -- send query, optionally with output to file/pipe */
> ! else if (strcmp(cmd, "g") == 0)
> {
> char *fname = psql_scan_slash_option(scan_state,
> OT_FILEPIPE, NULL, false);
> --- 910,920 ----
> free(fname);
> }
>
> ! /*
> ! * \g [filename] -- send query, optionally with output to file/pipe
> ! * \gx [filename] -- same as \g, with expanded mode forced
> ! */
> ! else if (strcmp(cmd, "g") == 0 || strcmp(cmd, "gx") == 0)
> {
> char *fname = psql_scan_slash_option(scan_state,
> OT_FILEPIPE, NULL, false);
> *************** exec_command(const char *cmd,
> *** 924,929 ****
> --- 927,934 ----
> pset.gfname = pg_strdup(fname);
> }
> free(fname);
> + if (strcmp(cmd, "gx") == 0)
> + pset.g_expanded = true;
> status = PSQL_CMD_SEND;
> }
Would you be open to saving the next person some work by doing
something similar to how \d is done, namely looking for an 'x'
modifier after g without regard to how far after? As of this writing,
the \d version starts at line 398 in master.
Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: david@fetter.org, christoph.berg@credativ.de
Subject: Re: One-shot expanded output in psql using \gx
In-Reply-To: <20170208151214.GA8118@fetter.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