Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbTwL-0003Cv-2I for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Feb 2017 15:13:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cbTwK-0002b8-CX for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Feb 2017 15:13:48 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cbTut-0000xb-De for pgsql-hackers@postgresql.org; Wed, 08 Feb 2017 15:12:19 +0000 Received: from 173-164-140-181-sfba.hfc.comcastbusiness.net ([173.164.140.181] helo=fetter.org) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbTuq-0006vH-3X for pgsql-hackers@postgresql.org; Wed, 08 Feb 2017 15:12:18 +0000 Received: by fetter.org (Postfix, from userid 1000) id 771F7E07E9; Wed, 8 Feb 2017 07:12:14 -0800 (PST) Date: Wed, 8 Feb 2017 07:12:14 -0800 From: David Fetter To: Christoph Berg , PostgreSQL Hackers Subject: Re: One-shot expanded output in psql using \gx Message-ID: <20170208151214.GA8118@fetter.org> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170208145240.corb3zkmypn6snj2@msg.credativ.de> User-Agent: Mutt/1.7.1 (2016-10-04) X-Pg-Spam-Score: -0.9 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org 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 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