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

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: "Christoph Berg" <christoph(dot)berg(at)credativ(dot)de>
Cc: "David Fetter" <david(at)fetter(dot)org>,"PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: One-shot expanded output in psql using \gx
Date: 2017-03-03 19:11:49
Message-ID: 4d84079e-325b-48c5-83e6-bb54bb567bb1@manitou-mail.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Christoph Berg wrote:

> The new version tests \g and \gx with a new query, and
> re-running it on the last query buffer.

Thanks, here's a review:

The patch compiles and works as expected.

The code follows the same pattern as other one-shot command
modifiers, setting a flag in the global "pset" struct
in exec_command() and resetting it at the end of SendQuery().

- make installcheck-world: ok

- sgml doc: ok

- help text: ok

- includes regression tests: ok

- tab-completion: works but the list in tab-complete.c:backslash_commands[]
is sorted alphabetically so "\\gx" should come after "\\gset"

- another nitpick: in PrintQueryTuples() it assigns a bool:
+ /* one-shot expanded output requested via \gx */
+ if (pset.g_expanded)
+ my_popt.topt.expanded = true;
+

"expanded" is defined as a tri-valued short int (print.h:98):
typedef struct printTableOpt
{
//....
unsigned short int expanded; /* expanded/vertical output (if supported
by
* output format); 0=no, 1=yes, 2=auto */
Although there is still code that puts true/false in this variable
(probably because it was a bool before?), I assume that for new
code, assigning 0/1/2 should be preferred.

Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2017-03-03 19:15:06 Re: Provide list of subscriptions and publications in psql's completion
Previous Message Michael Meskes 2017-03-03 19:11:32 Re: [HACKERS] Two phase commit in ECPG