Re: [PATCHES] [GENERAL] Making sure \timing is on

2008-05-13 Thread Alvaro Herrera
Tom Lane escribió:

> Actually, \a and \H are fairly bogus anyway, because they are "toggling"
> a setting that has more than two values.  I wonder whether defining the
> argument as a boolean is really very sane.  Perhaps it would be better to
> take the argument if given as just a regular format setting --- ie,
> with an argument, either of these would just be a shorthand for
> \pset format.

Agreed -- they are bogus.  However, making "\H aligned" be an alias for
"\pset format aligned" does not look very sane either (is that "html
aligned" or what?)

Seeing how these have been deprecated for a very long while, perhaps the
thing to do is leave their behavior alone and throw a warning when they
are used; in a couple more releases, remove them.  However this isn't
very sane either, because we'd break scripts that are using \H for no
good reason.

Another thing we could do is keep them as "toggles", but instead of
aligned/HTML and aligned/unaligned, make them remember the state that
was set at the time they were called, and toggle between HTML (or
aligned) and the last state.

... except that since aligned is the default mode, \a should not toggle
between last state and aligned, but rather between last state and
unaligned.  Which makes it a misnomer.

Or maybe the thing to do is leave them damn well alone and just fix
\timing.

-- 
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] [GENERAL] Making sure \timing is on

2008-05-13 Thread Tom Lane
David Fetter <[EMAIL PROTECTED]> writes:
> On Tue, May 13, 2008 at 11:36:57AM -0400, Tom Lane wrote:
>>> Uh, my point was that the agreement was to do this to *all* of
>>> psql's toggling backslash commands, not only \timing.
>> 
>> Done :)

Hmm, I thought we had a lot more than three that were like this.
But on looking closer, I guess all the other ones are \pset boolean
options that already behave properly.

Actually, \a and \H are fairly bogus anyway, because they are "toggling"
a setting that has more than two values.  I wonder whether defining the
argument as a boolean is really very sane.  Perhaps it would be better to
take the argument if given as just a regular format setting --- ie,
with an argument, either of these would just be a shorthand for
\pset format.

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


Re: [PATCHES] [GENERAL] Making sure \timing is on

2008-05-13 Thread David Fetter
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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter  XMPP: [EMAIL PROTECTED]

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 -   1.203
--- doc/src/sgml/ref/psql-ref.sgml  13 May 2008 20:52:29 -
***
*** 673,685 
  
  

! \a
  
  
! 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 \pset for a
! more general solution.
  
  

--- 673,687 
  
  

!\a  [ ON |
! OFF ] 
  
  
! Without parameter, toggle format between aligned and
! unaligned.  With parameter, set it.  This command is kept for
! backwards compatibility. See \pset for a more
! general solution.
  
  

***
*** 1292,1305 
  
  

! \H
  
  
! Turns on HTML query output format. If the
! HTML format is already on, it is switched
! back to the default aligned text format. This command is for
! compatibility and convenience, but see \pset
! about setting other output options.
  
  

--- 1294,1308 
  
  

!\H  [ ON |
! OFF ] 
  
  
! Without parameter, toggles between HTML and
! aligned query output format.  With paramter, sets it.
! This command is for compatibility and convenience, but see
! \pset about setting other output options.
  
  

***
*** 1867,1876 
  
  

!\timing
  
  
!  Toggles a display of how long each SQL statement takes, in 
milliseconds.
  
 

--- 1870,1882 
  
  

!\timing  [ON | OFF] 
  
  
!  Without parameter, toggles a display of how long each SQL
! statement takes, in milliseconds.  With parameter, sets same.
  
 

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 -   1.188
--- src/bin/psql/command.c  13 May 2008 20:52:29 -
***
*** 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.p

Re: [PATCHES] [GENERAL] Making sure \timing is on

2008-05-13 Thread David Fetter
On Tue, May 13, 2008 at 11:36:57AM -0400, Tom Lane wrote:
> David Fetter <[EMAIL PROTECTED]> 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 :)

Cheers,
David.
-- 
David Fetter <[EMAIL PROTECTED]> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter  XMPP: [EMAIL PROTECTED]

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
Index: src/bin/psql/describe.c
===
RCS file: /projects/cvsroot/pgsql/src/bin/psql/describe.c,v
retrieving revision 1.168
diff -c -c -r1.168 describe.c
*** src/bin/psql/describe.c 2 May 2008 10:16:16 -   1.168
--- src/bin/psql/describe.c 4 May 2008 23:54:53 -
***
*** 307,315 
  "WHEN t.typlen < 0\n"
  "  THEN CAST('var' AS 
pg_catalog.text)\n"
  "ELSE CAST(t.typlen AS 
pg_catalog.text)\n"
! "  END AS \"%s\",\n",
  gettext_noop("Internal name"),
! gettext_noop("Size"));
appendPQExpBuffer(&buf,
"  pg_catalog.obj_description(t.oid, 'pg_type') 
as \"%s\"\n",
  gettext_noop("Description"));
--- 307,325 
  "WHEN t.typlen < 0\n"
  "  THEN CAST('var' AS 
pg_catalog.text)\n"
  "ELSE CAST(t.typlen AS 
pg_catalog.text)\n"
! "  END AS \"%s\",\n"
! "  
pg_catalog.array_to_string(\n"
! "  ARRAY(\n"
! "  SELECT 
e.enumlabel\n"
! "  FROM 
pg_catalog.pg_enum e\n"
! "  WHERE e.enumtypid 
= t.oid\n"
! "  ORDER BY e.oid\n"
! "  ),\n"
! "  E'\\n'\n"
! "  ) AS \"%s\",\n",
  gettext_noop("Internal name"),
! gettext_noop("Size"),
! gettext_noop("Elements"));
appendPQExpBuffer(&buf,
"  pg_catalog.obj_description(t.oid, 'pg_type') 
as \"%s\"\n",
  gettext_noop("Description"));

-- 
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] [GENERAL] Making sure \timing is on

2008-05-13 Thread Tom Lane
David Fetter <[EMAIL PROTECTED]> 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.

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


Re: [PATCHES] [GENERAL] Making sure \timing is on

2008-05-13 Thread David Fetter
On Tue, May 13, 2008 at 08:14:51AM -0700, David Fetter wrote:
> On Tue, May 13, 2008 at 10:47:40AM -0400, Alvaro Herrera wrote:
> > Tom Lane escribió:
> > > Alvaro Herrera <[EMAIL PROTECTED]> writes:
> > > > David Fetter escribi?:
> > > >> Thanks for the heads-up :)
> > > >> 
> > > >> Second patch attached, this time with some docs.
> > > 
> > > > Added to July commitfest.
> > > 
> > > Surely this is merely proof of concept and not a complete patch.
> > 
> > David, ya heard da man :-)
> 
> Next patch attached :)
> 
> Cheers,
> David (free() the malloc()s!)

*Sigh*

This time with the patch actually attached :P

Cheers,
David
-- 
David Fetter <[EMAIL PROTECTED]> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter  XMPP: [EMAIL PROTECTED]

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 -   1.203
--- doc/src/sgml/ref/psql-ref.sgml  13 May 2008 14:41:18 -
***
*** 1867,1876 
  
  

!\timing
  
  
!  Toggles a display of how long each SQL statement takes, in 
milliseconds.
  
 

--- 1867,1879 
  
  

!\timing  [ON | OFF] 
  
  
!  Without parameter, toggles a display of how long each SQL
! statement takes, in milliseconds.  With parameter, sets same.
  
 

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 -   1.188
--- src/bin/psql/command.c  13 May 2008 14:41:21 -
***
*** 884,890 
/* \timing -- toggle timing of queries */
else if (strcmp(cmd, "timing") == 0)
{
!   pset.timing = !pset.timing;
if (!pset.quiet)
{
if (pset.timing)
--- 903,914 
/* \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 
--- 916,922 
else
puts(_("Timing is off."));
}
+   free(opt);
}
  
/* \unset */

-- 
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] [GENERAL] Making sure \timing is on

2008-05-13 Thread David Fetter
On Tue, May 13, 2008 at 10:47:40AM -0400, Alvaro Herrera wrote:
> Tom Lane escribió:
> > Alvaro Herrera <[EMAIL PROTECTED]> writes:
> > > David Fetter escribi?:
> > >> Thanks for the heads-up :)
> > >> 
> > >> Second patch attached, this time with some docs.
> > 
> > > Added to July commitfest.
> > 
> > Surely this is merely proof of concept and not a complete patch.
> 
> David, ya heard da man :-)

Next patch attached :)

Cheers,
David (free() the malloc()s!)
-- 
David Fetter <[EMAIL PROTECTED]> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter  XMPP: [EMAIL PROTECTED]

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

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