Skip to content

Commit 8b64a26

Browse files
committed
Add optional on/off argument to \timing.
David Fetter.
1 parent 96675bf commit 8b64a26

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

doc/src/sgml/ref/psql-ref.sgml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.207 2008/06/01 16:23:08 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.208 2008/06/11 10:48:16 heikki Exp $
33
PostgreSQL documentation
44
-->
55

@@ -1861,10 +1861,11 @@ lo_import 152801
18611861

18621862

18631863
<varlistentry>
1864-
<term><literal>\timing</literal></term>
1864+
<term><literal>\timing [ <replaceable class="parameter">on</replaceable> | <replaceable class="parameter">off</replaceable> ]</literal></term>
18651865
<listitem>
18661866
<para>
1867-
Toggles a display of how long each SQL statement takes, in milliseconds.
1867+
Without parameter, toggles a display of how long each SQL statement
1868+
takes, in milliseconds. With parameter, sets same.
18681869
</para>
18691870
</listitem>
18701871
</varlistentry>

src/bin/psql/command.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.189 2008/05/14 19:10:29 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.190 2008/06/11 10:48:17 heikki Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "command.h"
@@ -884,14 +884,20 @@ exec_command(const char *cmd,
884884
/* \timing -- toggle timing of queries */
885885
else if (strcmp(cmd, "timing") == 0)
886886
{
887-
pset.timing = !pset.timing;
887+
char *opt = psql_scan_slash_option(scan_state,
888+
OT_NORMAL, NULL, false);
889+
if (opt)
890+
pset.timing = ParseVariableBool(opt);
891+
else
892+
pset.timing = !pset.timing;
888893
if (!pset.quiet)
889894
{
890895
if (pset.timing)
891896
puts(_("Timing is on."));
892897
else
893898
puts(_("Timing is off."));
894899
}
900+
free(opt);
895901
}
896902

897903
/* \unset */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy