Making sure \timing is on

Started by Francisco Reyesalmost 18 years ago20 messagesgeneral
Jump to latest
#1Francisco Reyes
lists@stringsutils.com

Is there a way to make certain \timing is on?

I am looking for something simmilar to what one can do with the pager
\pset pager always

Most scripts I am working with (inheritted) don't have \timing in them so I
can put timing on/off as needed. However some scripts already have it. So if
I set \timing before the script and the script calls it again then it gets
turned off.

As I go over all the scripts it will be less of an issue, but I still would
like a way to make sure timing is on, before I run some scripts without
having to first check the script to see if I had put \timing in the script
or not.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Francisco Reyes (#1)
Re: Making sure \timing is on

Francisco Reyes <lists@stringsutils.com> writes:

Is there a way to make certain \timing is on?

Not that I know of :-(. There's been discussion of fixing all of psql's
"toggle" commands to offer "\foo on" and "\foo off" variants, which
would be far more scripting-friendly ... but nobody's stepped up to do it.

regards, tom lane

#3Francisco Reyes
lists@stringsutils.com
In reply to: Francisco Reyes (#1)
Re: Making sure \timing is on

Tom Lane writes:

Not that I know of :-(. There's been discussion of fixing all of psql's
"toggle" commands to offer "\foo on" and "\foo off"

What would be a good starting point for someone interesting in looking into
working on that?

Started a job recently as PostgresSQL DBA.. so sooner or later I will want
to start looking at the code. This may be one way to get my feet wet with
the code.

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Francisco Reyes (#3)
Re: Making sure \timing is on

Francisco Reyes <lists@stringsutils.com> writes:

Tom Lane writes:

Not that I know of :-(. There's been discussion of fixing all of psql's
"toggle" commands to offer "\foo on" and "\foo off"

What would be a good starting point for someone interesting in looking into
working on that?

This'd be a fine starting project IMHO, if you can read/code C at all.
The rubber meets the road in exec_command() in src/bin/psql/command.c
--- look around in that area.  In particular note that ParseVariableBool
in variables.c probably ought to be what you use to interpret the
meaning of the argument.

regards, tom lane

#5Scott Marlowe
scott.marlowe@gmail.com
In reply to: Tom Lane (#4)
Re: Making sure \timing is on

On Sun, May 11, 2008 at 9:04 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Francisco Reyes <lists@stringsutils.com> writes:

Tom Lane writes:

Not that I know of :-(. There's been discussion of fixing all of psql's
"toggle" commands to offer "\foo on" and "\foo off"

What would be a good starting point for someone interesting in looking into
working on that?

This'd be a fine starting project IMHO, if you can read/code C at all.
The rubber meets the road in exec_command() in src/bin/psql/command.c
--- look around in that area.  In particular note that ParseVariableBool
in variables.c probably ought to be what you use to interpret the
meaning of the argument.

Is it reasonable behavior to have \timing along toggle and \timing on
/ \timing off be a forced switch? Just thinking of other scripts
where this isn't a problem and having to update them.

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Scott Marlowe (#5)
Re: Making sure \timing is on

"Scott Marlowe" <scott.marlowe@gmail.com> writes:

Is it reasonable behavior to have \timing along toggle and \timing on
/ \timing off be a forced switch? Just thinking of other scripts
where this isn't a problem and having to update them.

The command without an argument should certainly keep the old toggle
behavior, for backwards compatibility.

regards, tom lane

#7David Fetter
david@fetter.org
In reply to: Tom Lane (#6)
Re: Making sure \timing is on

On Sun, May 11, 2008 at 11:48:29PM -0400, Tom Lane wrote:

"Scott Marlowe" <scott.marlowe@gmail.com> writes:

Is it reasonable behavior to have \timing along toggle and \timing on
/ \timing off be a forced switch? Just thinking of other scripts
where this isn't a problem and having to update them.

The command without an argument should certainly keep the old toggle
behavior, for backwards compatibility.

Attached patch does some of the right thing, but doesn't yet handle
error cases. How liberal should we be about capitalization, spelling,
etc.?

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

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

Attachments:

psql_set_timing.patchtext/plain; charset=us-asciiDownload+11-1
#8Bruce Momjian
bruce@momjian.us
In reply to: David Fetter (#7)
Re: Making sure \timing is on

David Fetter wrote:

On Sun, May 11, 2008 at 11:48:29PM -0400, Tom Lane wrote:

"Scott Marlowe" <scott.marlowe@gmail.com> writes:

Is it reasonable behavior to have \timing along toggle and \timing on
/ \timing off be a forced switch? Just thinking of other scripts
where this isn't a problem and having to update them.

The command without an argument should certainly keep the old toggle
behavior, for backwards compatibility.

Attached patch does some of the right thing, but doesn't yet handle
error cases. How liberal should we be about capitalization, spelling,
etc.?

Please try ParseVariableBool() in psql/variables.c, and use diff -c.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#9Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: David Fetter (#7)
Re: Making sure \timing is on

David Fetter escribi�:

On Sun, May 11, 2008 at 11:48:29PM -0400, Tom Lane wrote:

"Scott Marlowe" <scott.marlowe@gmail.com> writes:

Is it reasonable behavior to have \timing along toggle and \timing on
/ \timing off be a forced switch? Just thinking of other scripts
where this isn't a problem and having to update them.

The command without an argument should certainly keep the old toggle
behavior, for backwards compatibility.

Attached patch does some of the right thing, but doesn't yet handle
error cases. How liberal should we be about capitalization, spelling,

Hmm, there's already code for parsing boolean variables in psql, see
ParseVariableBool.

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

#10David Fetter
david@fetter.org
In reply to: Bruce Momjian (#8)
Re: Making sure \timing is on

On Mon, May 12, 2008 at 05:30:48PM -0400, Bruce Momjian wrote:

David Fetter wrote:

On Sun, May 11, 2008 at 11:48:29PM -0400, Tom Lane wrote:

"Scott Marlowe" <scott.marlowe@gmail.com> writes:

Is it reasonable behavior to have \timing along toggle and \timing on
/ \timing off be a forced switch? Just thinking of other scripts
where this isn't a problem and having to update them.

The command without an argument should certainly keep the old toggle
behavior, for backwards compatibility.

Attached patch does some of the right thing, but doesn't yet handle
error cases. How liberal should we be about capitalization, spelling,
etc.?

Please try ParseVariableBool() in psql/variables.c, and use diff -c.

Thanks for the heads-up :)

Second patch attached, this time with some docs.

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

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

Attachments:

psql_set_timing.patchtext/plain; charset=us-asciiDownload+14-14
#11Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: David Fetter (#10)
Re: Making sure \timing is on

David Fetter escribi�:

Thanks for the heads-up :)

Second patch attached, this time with some docs.

Added to July commitfest.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#12Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#11)
Re: Making sure \timing is on

Alvaro Herrera <alvherre@commandprompt.com> 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.

regards, tom lane

#13Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Tom Lane (#12)
Re: Making sure \timing is on

Tom Lane escribió:

Alvaro Herrera <alvherre@commandprompt.com> 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 :-)

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

#14David Fetter
david@fetter.org
In reply to: Alvaro Herrera (#13)
Re: Making sure \timing is on

On Tue, May 13, 2008 at 10:47:40AM -0400, Alvaro Herrera wrote:

Tom Lane escribi�:

Alvaro Herrera <alvherre@commandprompt.com> 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 <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

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

#15David Fetter
david@fetter.org
In reply to: David Fetter (#14)
Re: Making sure \timing is on

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 <alvherre@commandprompt.com> 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 <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

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

Attachments:

psql_set_timing.patchtext/plain; charset=us-asciiDownload+15-14
#16Tom Lane
tgl@sss.pgh.pa.us
In reply to: David Fetter (#15)
Re: Making sure \timing is on

David Fetter <david@fetter.org> 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

#17David Fetter
david@fetter.org
In reply to: Tom Lane (#16)
Re: Making sure \timing is on

On Tue, May 13, 2008 at 11:36:57AM -0400, Tom Lane wrote:

David Fetter <david@fetter.org> 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 <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

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

Attachments:

psql_enum-2.patchtext/plain; charset=us-asciiDownload+14-14
#18David Fetter
david@fetter.org
In reply to: David Fetter (#17)
Re: Making sure \timing is on

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@fetter.org> 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@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

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

Attachments:

psql_toggles.patchtext/plain; charset=us-asciiDownload+72-71
#19Tom Lane
tgl@sss.pgh.pa.us
In reply to: David Fetter (#18)
Re: Making sure \timing is on

David Fetter <david@fetter.org> 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

#20Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Tom Lane (#19)
Re: Making sure \timing is on

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 Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.