pg.ddx.io pgsql-patches@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Simon Riggs <simon@2ndquadrant.com>
To: List pgsql-patches <pgsql-patches@postgresql.org>
Subject: psql command setting
Date: Sat, 05 Jul 2008 13:36:07 +0100
Message-ID: <1215261367.4051.286.camel@ebony.site> (raw )
Recent patch allowed \timing [on|off]
This patch allows same option on all remaining toggles, so every option
works in the same way. We now have the ability to do
\a [on|off]
\H [on|off]
Patch also corrects help, which didn't show that \x and \t could already
be directly set, even though help said they were toggles.
--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support
Attachments:
psql_toggle_or_set.v1.patch (text/x-patch, 5.5K) download
Index: src/bin/psql/command.c
===================================================================
RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/bin/psql/command.c,v
retrieving revision 1.190
diff -c -r1.190 command.c
*** src/bin/psql/command.c 11 Jun 2008 10:48:17 -0000 1.190
--- src/bin/psql/command.c 5 Jul 2008 12:15:02 -0000
***************
*** 182,191 ****
*/
if (strcmp(cmd, "a") == 0)
{
! if (pset.popt.topt.format != PRINT_ALIGNED)
! success = do_pset("format", "aligned", &pset.popt, pset.quiet);
else
! success = do_pset("format", "unaligned", &pset.popt, pset.quiet);
}
/* \C -- override table title (formerly change HTML caption) */
--- 182,203 ----
*/
if (strcmp(cmd, "a") == 0)
{
! char *opt = psql_scan_slash_option(scan_state,
! OT_NORMAL, NULL, false);
! if (opt)
! {
! if (ParseVariableBool(opt))
! success = do_pset("format", "aligned", &pset.popt, pset.quiet);
! else
! success = do_pset("format", "unaligned", &pset.popt, pset.quiet);
! }
else
! {
! if (pset.popt.topt.format != PRINT_ALIGNED)
! success = do_pset("format", "aligned", &pset.popt, pset.quiet);
! else
! success = do_pset("format", "unaligned", &pset.popt, pset.quiet);
! }
}
/* \C -- override table title (formerly change HTML caption) */
***************
*** 538,547 ****
/* HTML mode */
else if (strcmp(cmd, "H") == 0 || strcmp(cmd, "html") == 0)
{
! if (pset.popt.topt.format != PRINT_HTML)
! success = do_pset("format", "html", &pset.popt, pset.quiet);
else
! success = do_pset("format", "aligned", &pset.popt, pset.quiet);
}
--- 550,571 ----
/* HTML mode */
else if (strcmp(cmd, "H") == 0 || strcmp(cmd, "html") == 0)
{
! char *opt = psql_scan_slash_option(scan_state,
! OT_NORMAL, NULL, false);
! if (opt)
! {
! if (ParseVariableBool(opt))
! success = do_pset("format", "html", &pset.popt, pset.quiet);
! else
! success = do_pset("format", "aligned", &pset.popt, pset.quiet);
! }
else
! {
! if (pset.popt.topt.format != PRINT_HTML)
! success = do_pset("format", "html", &pset.popt, pset.quiet);
! else
! success = do_pset("format", "aligned", &pset.popt, pset.quiet);
! }
}
Index: src/bin/psql/help.c
===================================================================
RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/bin/psql/help.c,v
retrieving revision 1.129
diff -c -r1.129 help.c
*** src/bin/psql/help.c 11 Jun 2008 10:55:43 -0000 1.129
--- src/bin/psql/help.c 5 Jul 2008 12:30:39 -0000
***************
*** 220,237 ****
fprintf(output, "\n");
fprintf(output, _("Formatting\n"));
! fprintf(output, _(" \\a toggle between unaligned and aligned output mode\n"));
fprintf(output, _(" \\C [STRING] set table title, or unset if none\n"));
fprintf(output, _(" \\f [STRING] show or set field separator for unaligned query output\n"));
! fprintf(output, _(" \\H toggle HTML output mode (currently %s)\n"),
ON(pset.popt.topt.format == PRINT_HTML));
fprintf(output, _(" \\pset NAME [VALUE] set table output option\n"
" (NAME := {format|border|expanded|fieldsep|footer|null|\n"
" numericlocale|recordsep|tuples_only|title|tableattr|pager})\n"));
! fprintf(output, _(" \\t show only rows (currently %s)\n"),
ON(pset.popt.topt.tuples_only));
fprintf(output, _(" \\T [STRING] set HTML <table> tag attributes, or unset if none\n"));
! fprintf(output, _(" \\x toggle expanded output (currently %s)\n"),
ON(pset.popt.topt.expanded));
fprintf(output, "\n");
--- 220,237 ----
fprintf(output, "\n");
fprintf(output, _("Formatting\n"));
! fprintf(output, _(" \\a [on|off] toggle between unaligned and aligned output mode\n"));
fprintf(output, _(" \\C [STRING] set table title, or unset if none\n"));
fprintf(output, _(" \\f [STRING] show or set field separator for unaligned query output\n"));
! fprintf(output, _(" \\H [on|off] toggle or set HTML output mode (currently %s)\n"),
ON(pset.popt.topt.format == PRINT_HTML));
fprintf(output, _(" \\pset NAME [VALUE] set table output option\n"
" (NAME := {format|border|expanded|fieldsep|footer|null|\n"
" numericlocale|recordsep|tuples_only|title|tableattr|pager})\n"));
! fprintf(output, _(" \\t [on|off] toggle or set showing rows only (currently %s)\n"),
ON(pset.popt.topt.tuples_only));
fprintf(output, _(" \\T [STRING] set HTML <table> tag attributes, or unset if none\n"));
! fprintf(output, _(" \\x [on|off] toggle or set expanded output (currently %s)\n"),
ON(pset.popt.topt.expanded));
fprintf(output, "\n");
***************
*** 245,251 ****
fprintf(output, _("External\n"));
fprintf(output, _(" \\cd [DIR] change the current working directory\n"));
! fprintf(output, _(" \\timing [on|off] toggle timing of commands (currently %s)\n"),
ON(pset.timing));
fprintf(output, _(" \\! [COMMAND] execute command in shell or start interactive shell\n"));
fprintf(output, "\n");
--- 245,251 ----
fprintf(output, _("External\n"));
fprintf(output, _(" \\cd [DIR] change the current working directory\n"));
! fprintf(output, _(" \\timing [on|off] toggle or set timing of commands (currently %s)\n"),
ON(pset.timing));
fprintf(output, _(" \\! [COMMAND] execute command in shell or start interactive shell\n"));
fprintf(output, "\n");
view thread (4+ messages) latest in thread
Message-ID: <1215261367.4051.286.camel@ebony.site>
Permalink: ../1215261367.4051.286.camel@ebony.site/
Also on: postgresql.org/message-id/1215261367.4051.286.camel@ebony.site
copy link · copy postgr.es · copy git am
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-patches@postgresql.org
Cc: simon@2ndquadrant.com
Subject: Re: psql command setting
In-Reply-To: <1215261367.4051.286.camel@ebony.site>
References: <1215261367.4051.286.camel@ebony.site>
* 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