Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 52E0D650040 for ; Sat, 5 Jul 2008 09:31:04 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 57175-04 for ; Sat, 5 Jul 2008 09:30:55 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail136191.authsmtp.com (outmail136191.authsmtp.com [62.13.136.191]) by postgresql.org (Postfix) with ESMTP id 19B8A64FD34 for ; Sat, 5 Jul 2008 09:30:59 -0300 (ADT) Received: from mail-c187.authsmtp.com (mail-c187.authsmtp.com [62.13.128.33]) by punt6.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m65CUwHN039025 for ; Sat, 5 Jul 2008 13:30:58 +0100 (BST) Received: from [192.168.0.3] (85-211-229-155.dyn.gotadsl.co.uk [85.211.229.155]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id m65CUoqb001102 for ; Sat, 5 Jul 2008 13:30:50 +0100 (BST) Subject: psql command setting From: Simon Riggs To: List pgsql-patches Content-Type: multipart/mixed; boundary="=-4rSKrGsSNl+FUtPyI2ep" Date: Sat, 05 Jul 2008 13:36:07 +0100 Message-Id: <1215261367.4051.286.camel@ebony.site> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 X-Server-Quench: 3406c588-4a8e-11dd-8155-001185d377ca X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MOFUSTAAU Kk9GJVpeK3UEQkpF VCReGBUITgIzDi11 bhUrKFlCYEpOVxVr U0JKQlhXFEtgBAID Bx8AUBt7aQRDfWFy YERnQXAVAUJ/BiMi AxxUFWwHZWUubmYW VA5bcwNSIwZCdgJB O1gqSXIMNTEabntl QkprZ2lobWhTc3sK SQgbNUkLRQ4AGTs5 ThYOVS4iAVEEQSpb X-Authentic-SMTP: 61633235383639.squirrel.dmpriest.net.uk:1078/Kp X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Status: No virus detected - but ensure you scan with your own anti-virus system! X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200807/81 X-Sequence-Number: 6775 --=-4rSKrGsSNl+FUtPyI2ep Content-Type: text/plain Content-Transfer-Encoding: 7bit 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 --=-4rSKrGsSNl+FUtPyI2ep Content-Disposition: attachment; filename=psql_toggle_or_set.v1.patch Content-Type: text/x-patch; name=psql_toggle_or_set.v1.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 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
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"); --=-4rSKrGsSNl+FUtPyI2ep--