88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.287 2002/08/30 22:18 :06tgl Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.288 2002/09/01 23:26 :06momjian Exp $
1212 *
1313 * NOTES
1414 * this is the "main" module of the postgres backend and
@@ -220,7 +220,7 @@ InteractiveBackend(StringInfo inBuf)
220220 * if the query echo flag was given, print the query..
221221 */
222222if (EchoQuery )
223- printf ("query : %s\n" ,inBuf -> data );
223+ printf ("statement : %s\n" ,inBuf -> data );
224224fflush (stdout );
225225
226226return 'Q' ;
@@ -372,7 +372,7 @@ pg_parse_query(StringInfo query_string, Oid *typev, int nargs)
372372{
373373List * raw_parsetree_list ;
374374
375- if (Debug_print_query )
375+ if (Log_statement )
376376elog (LOG ,"query: %s" ,query_string -> data );
377377
378378if (Show_parser_stats )
@@ -561,9 +561,19 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
561561MemoryContext oldcontext ;
562562List * parsetree_list ,
563563* parsetree_item ;
564-
564+ struct timezone tz ;
565+ struct timeval start_t ,stop_t ;
566+ bool save_Log_duration = Log_duration ;
567+
565568debug_query_string = query_string -> data ;/* used by pgmonitor */
566569
570+ /*
571+ *We use save_Log_duration so setting Log_duration to true doesn't
572+ * report incorrect time because gettimeofday() wasn't called.
573+ */
574+ if (save_Log_duration )
575+ gettimeofday (& start_t ,& tz );
576+
567577/*
568578 * Start up a transaction command.All queries generated by the
569579 * query_string will be in this same command block, *unless* we find a
@@ -850,6 +860,19 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
850860if (xact_started )
851861finish_xact_command ();
852862
863+ if (save_Log_duration )
864+ {
865+ gettimeofday (& stop_t ,& tz );
866+ if (stop_t .tv_usec < start_t .tv_usec )
867+ {
868+ stop_t .tv_sec -- ;
869+ stop_t .tv_usec += 1000000 ;
870+ }
871+ elog (LOG ,"duration: %ld.%06ld sec" ,
872+ (longint )stop_t .tv_sec - start_t .tv_sec ,
873+ (longint )stop_t .tv_usec - start_t .tv_usec );
874+ }
875+
853876debug_query_string = NULL ;/* used by pgmonitor */
854877}
855878
@@ -1234,7 +1257,7 @@ PostgresMain(int argc, char *argv[], const char *username)
12341257if (atoi (optarg ) >=1 )
12351258SetConfigOption ("log_connections" ,"true" ,ctx ,gucsource );
12361259if (atoi (optarg ) >=2 )
1237- SetConfigOption ("debug_print_query " ,"true" ,ctx ,gucsource );
1260+ SetConfigOption ("log_statement " ,"true" ,ctx ,gucsource );
12381261if (atoi (optarg ) >=3 )
12391262SetConfigOption ("debug_print_parse" ,"true" ,ctx ,gucsource );
12401263if (atoi (optarg ) >=4 )
@@ -1377,7 +1400,7 @@ PostgresMain(int argc, char *argv[], const char *username)
13771400/*
13781401 * s - report usage statistics (timings) after each query
13791402 */
1380- SetConfigOption ("show_query_stats " ,"true" ,ctx ,gucsource );
1403+ SetConfigOption ("show_statement_stats " ,"true" ,ctx ,gucsource );
13811404break ;
13821405
13831406case 't' :
@@ -1489,11 +1512,11 @@ PostgresMain(int argc, char *argv[], const char *username)
14891512/*
14901513 * Post-processing for command line options.
14911514 */
1492- if (Show_query_stats &&
1515+ if (Show_statement_stats &&
14931516(Show_parser_stats || Show_planner_stats || Show_executor_stats ))
14941517{
14951518elog (WARNING ,"Query statistics are disabled because parser, planner, or executor statistics are on." );
1496- SetConfigOption ("show_query_stats " ,"false" ,ctx ,gucsource );
1519+ SetConfigOption ("show_statement_stats " ,"false" ,ctx ,gucsource );
14971520}
14981521
14991522if (!IsUnderPostmaster )
@@ -1664,7 +1687,7 @@ PostgresMain(int argc, char *argv[], const char *username)
16641687if (!IsUnderPostmaster )
16651688{
16661689puts ("\nPOSTGRES backend interactive interface " );
1667- puts ("$Revision: 1.287 $ $Date: 2002/08/30 22:18 :06 $\n" );
1690+ puts ("$Revision: 1.288 $ $Date: 2002/09/01 23:26 :06 $\n" );
16681691}
16691692
16701693/*
@@ -1887,7 +1910,7 @@ PostgresMain(int argc, char *argv[], const char *username)
18871910 * Note: transaction command start/end is now done within
18881911 * pg_exec_query_string(), not here.
18891912 */
1890- if (Show_query_stats )
1913+ if (Show_statement_stats )
18911914ResetUsage ();
18921915
18931916pgstat_report_activity (parser_input -> data );
@@ -1896,7 +1919,7 @@ PostgresMain(int argc, char *argv[], const char *username)
18961919whereToSendOutput ,
18971920QueryContext );
18981921
1899- if (Show_query_stats )
1922+ if (Show_statement_stats )
19001923ShowUsage ("QUERY STATISTICS" );
19011924}
19021925break ;