File tree 3 files changed +47
-28
lines changed
3 files changed +47
-28
lines changed Original file line number Diff line number Diff line change 3
3
*
4
4
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
5
5
*
6
- * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.174 2006/10/06 17:14:00 petere Exp $
6
+ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.175 2006/12/16 00:38:43 adunstan Exp $
7
7
*/
8
8
#include "postgres_fe.h"
9
9
#include "command.h"
@@ -303,10 +303,26 @@ exec_command(const char *cmd,
303
303
/* \copy */
304
304
else if (pg_strcasecmp (cmd , "copy" ) == 0 )
305
305
{
306
+ /* Default fetch-it-all-and-print mode */
307
+ TimevalStruct before ,
308
+ after ;
309
+ double elapsed_msec = 0 ;
310
+
306
311
char * opt = psql_scan_slash_option (scan_state ,
307
312
OT_WHOLE_LINE , NULL , false);
308
-
313
+ if (pset .timing )
314
+ GETTIMEOFDAY (& before );
315
+
309
316
success = do_copy (opt );
317
+
318
+ if (pset .timing && success )
319
+ {
320
+ GETTIMEOFDAY (& after );
321
+ elapsed_msec = DIFF_MSEC (& after , & before );
322
+ printf (_ ("Time: %.3f ms\n" ), elapsed_msec );
323
+
324
+ }
325
+
310
326
free (opt );
311
327
}
312
328
Original file line number Diff line number Diff line change 3
3
*
4
4
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
5
5
*
6
- * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.130 2006/10/04 00:30:05 momjian Exp $
6
+ * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.131 2006/12/16 00:38:43 adunstan Exp $
7
7
*/
8
8
#include "postgres_fe.h"
9
9
#include "common.h"
10
10
11
11
#include <ctype.h>
12
12
#include <signal.h>
13
13
#ifndef WIN32
14
- #include <sys/time.h>
15
14
#include <unistd.h> /* for write() */
16
15
#else
17
16
#include <io.h> /* for _write() */
18
17
#include <win32.h>
19
- #include <sys/timeb.h> /* for _ftime() */
20
18
#endif
21
19
22
20
#include "pqsignal.h"
28
26
#include "mbprint.h"
29
27
30
28
31
- /* Workarounds for Windows */
32
- /* Probably to be moved up the source tree in the future, perhaps to be replaced by
33
- * more specific checks like configure-style HAVE_GETTIMEOFDAY macros.
34
- */
35
- #ifndef WIN32
36
-
37
- typedef struct timeval TimevalStruct ;
38
-
39
- #define GETTIMEOFDAY (T ) gettimeofday(T, NULL)
40
- #define DIFF_MSEC (T , U ) \
41
- ((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \
42
- ((int) ((T)->tv_usec - (U)->tv_usec))) / 1000.0)
43
- #else
44
-
45
- typedef struct _timeb TimevalStruct ;
46
-
47
- #define GETTIMEOFDAY (T ) _ftime(T)
48
- #define DIFF_MSEC (T , U ) \
49
- (((T)->time - (U)->time) * 1000.0 + \
50
- ((T)->millitm - (U)->millitm))
51
- #endif
52
-
53
29
54
30
static bool ExecQueryUsingCursor (const char * query , double * elapsed_msec );
55
31
static bool command_no_begin (const char * query );
Original file line number Diff line number Diff line change 3
3
*
4
4
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
5
5
*
6
- * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.51 2006/10/04 00:30:05 momjian Exp $
6
+ * $PostgreSQL: pgsql/src/bin/psql/common.h,v 1.52 2006/12/16 00:38:43 adunstan Exp $
7
7
*/
8
8
#ifndef COMMON_H
9
9
#define COMMON_H
@@ -63,4 +63,31 @@ extern const char *session_username(void);
63
63
64
64
extern char * expand_tilde (char * * filename );
65
65
66
+ /* Workarounds for Windows */
67
+ /* Probably to be moved up the source tree in the future, perhaps to be replaced by
68
+ * more specific checks like configure-style HAVE_GETTIMEOFDAY macros.
69
+ */
70
+ #ifndef WIN32
71
+
72
+ #include <sys/time.h>
73
+
74
+ typedef struct timeval TimevalStruct ;
75
+
76
+ #define GETTIMEOFDAY (T ) gettimeofday(T, NULL)
77
+ #define DIFF_MSEC (T , U ) \
78
+ ((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \
79
+ ((int) ((T)->tv_usec - (U)->tv_usec))) / 1000.0)
80
+ #else
81
+
82
+ typedef struct _timeb TimevalStruct ;
83
+
84
+ #include <sys/types.h>
85
+ #include <sys/timeb.h>
86
+
87
+ #define GETTIMEOFDAY (T ) _ftime(T)
88
+ #define DIFF_MSEC (T , U ) \
89
+ (((T)->time - (U)->time) * 1000.0 + \
90
+ ((T)->millitm - (U)->millitm))
91
+ #endif
92
+
66
93
#endif /* COMMON_H */
You can’t perform that action at this time.
0 commit comments