On Tue, May 13, 2008 at 01:53:33PM -0700, David Fetter wrote: > On Tue, May 13, 2008 at 11:36:57AM -0400, Tom Lane wrote: > > David Fetter <david@xxxxxxxxxx> writes: > > >>> Surely this is merely proof of concept and not a complete patch. > > >> > > >> Next patch attached :) > > > > Uh, my point was that the agreement was to do this to *all* of > > psql's toggling backslash commands, not only \timing. > > Done :) Ugh. This time with the correct patch attached :P Cheers, David (not having much luck with attachments) -- David Fetter <david@xxxxxxxxxx> http://fetter.org/ Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter Skype: davidfetter XMPP: david.fetter@xxxxxxxxx Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate
Index: doc/src/sgml/ref/psql-ref.sgml =================================================================== RCS file: /projects/cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v retrieving revision 1.203 diff -c -c -r1.203 psql-ref.sgml *** doc/src/sgml/ref/psql-ref.sgml 8 May 2008 17:04:26 -0000 1.203 --- doc/src/sgml/ref/psql-ref.sgml 13 May 2008 20:52:29 -0000 *************** *** 673,685 **** <variablelist> <varlistentry> ! <term><literal>\a</literal></term> <listitem> <para> ! If the current table output format is unaligned, it is switched to aligned. ! If it is not unaligned, it is set to unaligned. This command is ! kept for backwards compatibility. See <command>\pset</command> for a ! more general solution. </para> </listitem> </varlistentry> --- 673,687 ---- <variablelist> <varlistentry> ! <term><literal>\a </literal> [ <replaceable ! class="parameter">ON</replaceable> | ! <replaceable class="parameter">OFF</replaceable> ] </term> <listitem> <para> ! Without parameter, toggle format between aligned and ! unaligned. With parameter, set it. This command is kept for ! backwards compatibility. See <command>\pset</command> for a more ! general solution. </para> </listitem> </varlistentry> *************** *** 1292,1305 **** <varlistentry> ! <term><literal>\H</literal></term> <listitem> <para> ! Turns on <acronym>HTML</acronym> query output format. If the ! <acronym>HTML</acronym> format is already on, it is switched ! back to the default aligned text format. This command is for ! compatibility and convenience, but see <command>\pset</command> ! about setting other output options. </para> </listitem> </varlistentry> --- 1294,1308 ---- <varlistentry> ! <term><literal>\H </literal> [ <replaceable ! class="parameter">ON</replaceable> | ! <replaceable class="parameter">OFF</replaceable> ] </term> <listitem> <para> ! Without parameter, toggles between <acronym>HTML</acronym> and ! aligned query output format. With paramter, sets it. ! This command is for compatibility and convenience, but see ! <command>\pset</command> about setting other output options. </para> </listitem> </varlistentry> *************** *** 1867,1876 **** <varlistentry> ! <term><literal>\timing</literal></term> <listitem> <para> ! Toggles a display of how long each SQL statement takes, in milliseconds. </para> </listitem> </varlistentry> --- 1870,1882 ---- <varlistentry> ! <term><literal>\timing </literal> [<replaceable ! class="parameter">ON</replaceable> | <replaceable ! class="parameter">OFF</replaceable>] </term> <listitem> <para> ! Without parameter, toggles a display of how long each SQL ! statement takes, in milliseconds. With parameter, sets same. </para> </listitem> </varlistentry> Index: src/bin/psql/command.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/psql/command.c,v retrieving revision 1.188 diff -c -c -r1.188 command.c *** src/bin/psql/command.c 8 May 2008 17:04:26 -0000 1.188 --- src/bin/psql/command.c 13 May 2008 20:52:29 -0000 *************** *** 180,189 **** */ 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) */ --- 180,199 ---- */ if (strcmp(cmd, "a") == 0) { ! char *opt = psql_scan_slash_option(scan_state, ! OT_NORMAL, NULL, true); ! if (opt) ! success = do_pset("format", ! ParseVariableBool(opt) ? "aligned" : "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); ! } ! free(opt); } /* \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); } --- 548,567 ---- /* 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) ! success = do_pset("format", ! ParseVariableBool(opt) ? "html" : "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); ! } ! free(opt); } *************** *** 884,890 **** /* \timing -- toggle timing of queries */ else if (strcmp(cmd, "timing") == 0) { ! pset.timing = !pset.timing; if (!pset.quiet) { if (pset.timing) --- 904,915 ---- /* \timing -- toggle timing of queries */ else if (strcmp(cmd, "timing") == 0) { ! char *opt = psql_scan_slash_option(scan_state, ! OT_NORMAL, NULL, false); ! if (opt) ! pset.timing = ParseVariableBool(opt); ! else ! pset.timing = !pset.timing; if (!pset.quiet) { if (pset.timing) *************** *** 892,897 **** --- 917,923 ---- else puts(_("Timing is off.")); } + free(opt); } /* \unset */