Re: [PATCHES] psql command setting

2008-08-29 Thread Alvaro Herrera
Simon Riggs wrote:

> At the very least we should document the two toggles that are already
> settable, with the attached patch.

Applied.

-- 
Alvaro Herrerahttp://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


Re: [PATCHES] psql command setting

2008-07-05 Thread Simon Riggs

On Sat, 2008-07-05 at 11:24 -0400, Tom Lane wrote:

> the remaining toggles aren't really toggles.

If it *acts* like a toggle and the help *says* its a toggle, then its
"actual toggleness" seems moot.

At the very least we should document the two toggles that are already
settable, with the attached patch.

-- 
 Simon Riggs   www.2ndQuadrant.com
 PostgreSQL Training, Services and Support
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 -	1.129
--- src/bin/psql/help.c	5 Jul 2008 12:19:00 -
***
*** 228,237 
  	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");
  
--- 228,237 
  	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]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 [on|off]toggle expanded output (currently %s)\n"),
  			ON(pset.popt.topt.expanded));
  	fprintf(output, "\n");
  

-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


Re: [PATCHES] psql command setting

2008-07-05 Thread Tom Lane
Simon Riggs <[EMAIL PROTECTED]> writes:
> Recent patch allowed \timing [on|off]
> This patch allows same option on all remaining toggles, so every option
> works in the same way.

We already discussed that and rejected it, because the remaining toggles
aren't really toggles.

regards, tom lane

-- 
Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-patches


[PATCHES] psql command setting

2008-07-05 Thread Simon Riggs
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
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 -	1.190
--- src/bin/psql/command.c	5 Jul 2008 12:15:02 -
***
*** 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 -	1.129
--- src/bin/psql/help.c	5 Jul 2008 12:30:39 -
***
*** 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_on