Re: One-shot expanded output in psql using \gx

From: David Fetter <david(at)fetter(dot)org>
To: Christoph Berg <christoph(dot)berg(at)credativ(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: One-shot expanded output in psql using \gx
Date: 2017-02-08 15:12:14
Message-ID: 20170208151214.GA8118@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Feb 08, 2017 at 03:52:40PM +0100, Christoph Berg wrote:
> Re: David Fetter 2017-02-07 <20170207051659(dot)GC3552(at)fetter(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2017-02-08 15:23:25 Re: multivariate statistics (v19)
Previous Message Christoph Berg 2017-02-08 14:52:40 Re: One-shot expanded output in psql using \gx