Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
25b0b09f
Commit
25b0b09f
authored
Mar 05, 2002
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add \timing patch to psql. Times all queries.
Greg Sabino Mullane
parent
294f0d4b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
8 deletions
+57
-8
doc/src/sgml/ref/psql-ref.sgml
doc/src/sgml/ref/psql-ref.sgml
+11
-1
src/bin/psql/command.c
src/bin/psql/command.c
+19
-1
src/bin/psql/common.c
src/bin/psql/common.c
+19
-1
src/bin/psql/help.c
src/bin/psql/help.c
+3
-1
src/bin/psql/settings.h
src/bin/psql/settings.h
+2
-1
src/bin/psql/tab-complete.c
src/bin/psql/tab-complete.c
+3
-3
No files found.
doc/src/sgml/ref/psql-ref.sgml
View file @
25b0b09f
<!--
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.6
1 2001/12/08 03:24:38 thomas
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.6
2 2002/03/05 00:00:58 momjian
Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -1119,6 +1119,16 @@ lo_import 152801
...
@@ -1119,6 +1119,16 @@ lo_import 152801
</varlistentry>
</varlistentry>
<varlistentry>
<term><literal>\timing</literal>
<listitem>
<para>
Toggles a display of how long each query takes in seconds.
</para>
</listitem>
</varlistentry>
<varlistentry>
<varlistentry>
<term><literal>\w</literal> {<replaceable class="parameter">filename</replaceable> | <replaceable class="parameter">|command</replaceable>}</term>
<term><literal>\w</literal> {<replaceable class="parameter">filename</replaceable> | <replaceable class="parameter">|command</replaceable>}</term>
<listitem>
<listitem>
...
...
src/bin/psql/command.c
View file @
25b0b09f
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright 2000 by PostgreSQL Global Development Group
* Copyright 2000 by PostgreSQL Global Development Group
*
*
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.6
6 2002/02/25 21:37:42 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.6
7 2002/03/05 00:01:00 momjian
Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
#include "command.h"
#include "command.h"
...
@@ -715,6 +715,24 @@ exec_command(const char *cmd,
...
@@ -715,6 +715,24 @@ exec_command(const char *cmd,
free
(
value
);
free
(
value
);
}
}
/* \timing -- toggle timing of queries */
else
if
(
strcmp
(
cmd
,
"timing"
)
==
0
)
{
pset
.
timing
=
!
pset
.
timing
;
if
(
!
quiet
)
{
if
(
pset
.
timing
)
{
puts
(
gettext
((
"Timing is on."
)));
}
else
{
puts
(
gettext
((
"Timing is off."
)));
}
}
}
/* \unset */
/* \unset */
else
if
(
strcmp
(
cmd
,
"unset"
)
==
0
)
else
if
(
strcmp
(
cmd
,
"unset"
)
==
0
)
{
{
...
...
src/bin/psql/common.c
View file @
25b0b09f
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright 2000 by PostgreSQL Global Development Group
* Copyright 2000 by PostgreSQL Global Development Group
*
*
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.3
8 2001/11/05 17:46:3
0 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.3
9 2002/03/05 00:01:0
0 momjian Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#include <errno.h>
#include <errno.h>
#include <stdarg.h>
#include <stdarg.h>
#include <sys/time.h>
#ifdef HAVE_TERMIOS_H
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#include <termios.h>
#endif
#endif
...
@@ -406,6 +407,8 @@ SendQuery(const char *query)
...
@@ -406,6 +407,8 @@ SendQuery(const char *query)
bool
success
=
false
;
bool
success
=
false
;
PGresult
*
results
;
PGresult
*
results
;
PGnotify
*
notify
;
PGnotify
*
notify
;
struct
timeval
before
,
after
;
struct
timezone
tz
;
if
(
!
pset
.
db
)
if
(
!
pset
.
db
)
{
{
...
@@ -435,7 +438,15 @@ SendQuery(const char *query)
...
@@ -435,7 +438,15 @@ SendQuery(const char *query)
}
}
cancelConn
=
pset
.
db
;
cancelConn
=
pset
.
db
;
if
(
pset
.
timing
)
{
gettimeofday
(
&
before
,
&
tz
);
}
results
=
PQexec
(
pset
.
db
,
query
);
results
=
PQexec
(
pset
.
db
,
query
);
if
(
pset
.
timing
)
{
gettimeofday
(
&
after
,
&
tz
);
}
if
(
PQresultStatus
(
results
)
==
PGRES_COPY_IN
)
if
(
PQresultStatus
(
results
)
==
PGRES_COPY_IN
)
copy_in_state
=
true
;
copy_in_state
=
true
;
/* keep cancel connection for copy out state */
/* keep cancel connection for copy out state */
...
@@ -563,6 +574,13 @@ SendQuery(const char *query)
...
@@ -563,6 +574,13 @@ SendQuery(const char *query)
if
(
results
)
if
(
results
)
PQclear
(
results
);
PQclear
(
results
);
}
/* Possible microtiming output */
if
(
pset
.
timing
&&
success
)
{
!
printf
(
gettext
(
"Total time: %.3fs
\n
"
),
((
after
.
tv_sec
-
before
.
tv_sec
)
*
1000000
+
after
.
tv_usec
-
before
.
tv_usec
)
/
1000000
.
0
);
}
}
return
success
;
return
success
;
...
...
src/bin/psql/help.c
View file @
25b0b09f
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright 2000 by PostgreSQL Global Development Group
* Copyright 2000 by PostgreSQL Global Development Group
*
*
* $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.4
2 2001/10/25 05:49:54
momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.4
3 2002/03/05 00:01:01
momjian Exp $
*/
*/
#include "postgres_fe.h"
#include "postgres_fe.h"
#include "help.h"
#include "help.h"
...
@@ -229,6 +229,8 @@ slashUsage(void)
...
@@ -229,6 +229,8 @@ slashUsage(void)
fprintf
(
fout
,
_
(
"
\\
t show only rows (currently %s)
\n
"
),
fprintf
(
fout
,
_
(
"
\\
t show only rows (currently %s)
\n
"
),
ON
(
pset
.
popt
.
topt
.
tuples_only
));
ON
(
pset
.
popt
.
topt
.
tuples_only
));
fprintf
(
fout
,
_
(
"
\\
T TEXT set HTML table tag attributes
\n
"
));
fprintf
(
fout
,
_
(
"
\\
T TEXT set HTML table tag attributes
\n
"
));
fprintf
(
fout
,
_
(
"
\\
timing toggle timing of queries (currently %s)
\n
"
),
ON
(
pset
.
timing
));
fprintf
(
fout
,
_
(
"
\\
unset NAME unset (delete) internal variable
\n
"
));
fprintf
(
fout
,
_
(
"
\\
unset NAME unset (delete) internal variable
\n
"
));
fprintf
(
fout
,
_
(
"
\\
w FILENAME write current query buffer to file
\n
"
));
fprintf
(
fout
,
_
(
"
\\
w FILENAME write current query buffer to file
\n
"
));
fprintf
(
fout
,
_
(
"
\\
x toggle expanded output (currently %s)
\n
"
),
fprintf
(
fout
,
_
(
"
\\
x toggle expanded output (currently %s)
\n
"
),
...
...
src/bin/psql/settings.h
View file @
25b0b09f
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright 2000 by PostgreSQL Global Development Group
* Copyright 2000 by PostgreSQL Global Development Group
*
*
* $Header: /cvsroot/pgsql/src/bin/psql/settings.h,v 1.1
2 2001/10/28 06:25:58
momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/settings.h,v 1.1
3 2002/03/05 00:01:02
momjian Exp $
*/
*/
#ifndef SETTINGS_H
#ifndef SETTINGS_H
#define SETTINGS_H
#define SETTINGS_H
...
@@ -50,6 +50,7 @@ typedef struct _psqlSettings
...
@@ -50,6 +50,7 @@ typedef struct _psqlSettings
bool
issuper
;
/* is the current user a superuser? (used
bool
issuper
;
/* is the current user a superuser? (used
* to form the prompt) */
* to form the prompt) */
bool
timing
;
/* timing of all queries */
}
PsqlSettings
;
}
PsqlSettings
;
extern
PsqlSettings
pset
;
extern
PsqlSettings
pset
;
...
...
src/bin/psql/tab-complete.c
View file @
25b0b09f
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*
*
* Copyright 2000 by PostgreSQL Global Development Group
* Copyright 2000 by PostgreSQL Global Development Group
*
*
* $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.4
2 2002/03/02 21:39:34
momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.4
3 2002/03/05 00:01:03
momjian Exp $
*/
*/
/*----------------------------------------------------------------------
/*----------------------------------------------------------------------
...
@@ -276,8 +276,8 @@ psql_completion(char *text, int start, int end)
...
@@ -276,8 +276,8 @@ psql_completion(char *text, int start, int end)
"
\\
e"
,
"
\\
echo"
,
"
\\
e"
,
"
\\
echo"
,
"
\\
encoding"
,
"
\\
g"
,
"
\\
h"
,
"
\\
i"
,
"
\\
l"
,
"
\\
encoding"
,
"
\\
g"
,
"
\\
h"
,
"
\\
i"
,
"
\\
l"
,
"
\\
lo_import"
,
"
\\
lo_export"
,
"
\\
lo_list"
,
"
\\
lo_unlink"
,
"
\\
lo_import"
,
"
\\
lo_export"
,
"
\\
lo_list"
,
"
\\
lo_unlink"
,
"
\\
o"
,
"
\\
p"
,
"
\\
pset"
,
"
\\
q"
,
"
\\
qecho"
,
"
\\
r"
,
"
\\
set"
,
"
\\
t"
,
"
\\
unset"
,
"
\\
o"
,
"
\\
p"
,
"
\\
pset"
,
"
\\
q"
,
"
\\
qecho"
,
"
\\
r"
,
"
\\
set"
,
"
\\
t"
,
"
\\
x"
,
"
\\
w"
,
"
\\
z"
,
"
\\
!"
,
NULL
"
\\
timing"
,
"
\\
unset"
,
"
\\
x"
,
"
\\
w"
,
"
\\
z"
,
"
\\
!"
,
NULL
};
};
(
void
)
end
;
/* not used */
(
void
)
end
;
/* not used */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment