mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Add log_duration to GUC/postgresql.conf.
Rename debug_print_query to log_statement and rename show_query_stats to show_statement_stats.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.287 2002/08/30 22:18:06 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.288 2002/09/01 23:26:06 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* this is the "main" module of the postgres backend and
|
||||
@ -220,7 +220,7 @@ InteractiveBackend(StringInfo inBuf)
|
||||
* if the query echo flag was given, print the query..
|
||||
*/
|
||||
if (EchoQuery)
|
||||
printf("query: %s\n", inBuf->data);
|
||||
printf("statement: %s\n", inBuf->data);
|
||||
fflush(stdout);
|
||||
|
||||
return 'Q';
|
||||
@ -372,7 +372,7 @@ pg_parse_query(StringInfo query_string, Oid *typev, int nargs)
|
||||
{
|
||||
List *raw_parsetree_list;
|
||||
|
||||
if (Debug_print_query)
|
||||
if (Log_statement)
|
||||
elog(LOG, "query: %s", query_string->data);
|
||||
|
||||
if (Show_parser_stats)
|
||||
@ -561,9 +561,19 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */
|
||||
MemoryContext oldcontext;
|
||||
List *parsetree_list,
|
||||
*parsetree_item;
|
||||
|
||||
struct timezone tz;
|
||||
struct timeval start_t, stop_t;
|
||||
bool save_Log_duration = Log_duration;
|
||||
|
||||
debug_query_string = query_string->data; /* used by pgmonitor */
|
||||
|
||||
/*
|
||||
* We use save_Log_duration so setting Log_duration to true doesn't
|
||||
* report incorrect time because gettimeofday() wasn't called.
|
||||
*/
|
||||
if (save_Log_duration)
|
||||
gettimeofday(&start_t, &tz);
|
||||
|
||||
/*
|
||||
* Start up a transaction command. All queries generated by the
|
||||
* 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 */
|
||||
if (xact_started)
|
||||
finish_xact_command();
|
||||
|
||||
if (save_Log_duration)
|
||||
{
|
||||
gettimeofday(&stop_t, &tz);
|
||||
if (stop_t.tv_usec < start_t.tv_usec)
|
||||
{
|
||||
stop_t.tv_sec--;
|
||||
stop_t.tv_usec += 1000000;
|
||||
}
|
||||
elog(LOG, "duration: %ld.%06ld sec",
|
||||
(long int) stop_t.tv_sec - start_t.tv_sec,
|
||||
(long int) stop_t.tv_usec - start_t.tv_usec);
|
||||
}
|
||||
|
||||
debug_query_string = NULL; /* used by pgmonitor */
|
||||
}
|
||||
|
||||
@ -1234,7 +1257,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
if (atoi(optarg) >= 1)
|
||||
SetConfigOption("log_connections", "true", ctx, gucsource);
|
||||
if (atoi(optarg) >= 2)
|
||||
SetConfigOption("debug_print_query", "true", ctx, gucsource);
|
||||
SetConfigOption("log_statement", "true", ctx, gucsource);
|
||||
if (atoi(optarg) >= 3)
|
||||
SetConfigOption("debug_print_parse", "true", ctx, gucsource);
|
||||
if (atoi(optarg) >= 4)
|
||||
@ -1377,7 +1400,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
/*
|
||||
* s - report usage statistics (timings) after each query
|
||||
*/
|
||||
SetConfigOption("show_query_stats", "true", ctx, gucsource);
|
||||
SetConfigOption("show_statement_stats", "true", ctx, gucsource);
|
||||
break;
|
||||
|
||||
case 't':
|
||||
@ -1489,11 +1512,11 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
/*
|
||||
* Post-processing for command line options.
|
||||
*/
|
||||
if (Show_query_stats &&
|
||||
if (Show_statement_stats &&
|
||||
(Show_parser_stats || Show_planner_stats || Show_executor_stats))
|
||||
{
|
||||
elog(WARNING, "Query statistics are disabled because parser, planner, or executor statistics are on.");
|
||||
SetConfigOption("show_query_stats", "false", ctx, gucsource);
|
||||
SetConfigOption("show_statement_stats", "false", ctx, gucsource);
|
||||
}
|
||||
|
||||
if (!IsUnderPostmaster)
|
||||
@ -1664,7 +1687,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
if (!IsUnderPostmaster)
|
||||
{
|
||||
puts("\nPOSTGRES backend interactive interface ");
|
||||
puts("$Revision: 1.287 $ $Date: 2002/08/30 22:18:06 $\n");
|
||||
puts("$Revision: 1.288 $ $Date: 2002/09/01 23:26:06 $\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1887,7 +1910,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
* Note: transaction command start/end is now done within
|
||||
* pg_exec_query_string(), not here.
|
||||
*/
|
||||
if (Show_query_stats)
|
||||
if (Show_statement_stats)
|
||||
ResetUsage();
|
||||
|
||||
pgstat_report_activity(parser_input->data);
|
||||
@ -1896,7 +1919,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
whereToSendOutput,
|
||||
QueryContext);
|
||||
|
||||
if (Show_query_stats)
|
||||
if (Show_statement_stats)
|
||||
ShowUsage("QUERY STATISTICS");
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user