diff options
author | Bruce Momjian <bruce@momjian.us> | 2004-10-15 16:50:31 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2004-10-15 16:50:31 +0000 |
commit | a1ce88a59c05ac63c92f36c219f714e5552e9ba3 (patch) | |
tree | f9435c20dcf1374c0f1b9d6738c273ccf18784a9 /src/backend/tcop/postgres.c | |
parent | c96c02c7af504a8b9d5051c619fe0e96c47cfe6d (diff) | |
download | postgresql-a1ce88a59c05ac63c92f36c219f714e5552e9ba3.tar.gz postgresql-a1ce88a59c05ac63c92f36c219f714e5552e9ba3.zip |
Have log_duration only output when log_statement has printed the query.
This handles the new multiple log_statement values.
Ed L.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 9f4e8b06bad..b9abf0d6b69 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.435 2004/10/12 21:54:40 petere Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.436 2004/10/15 16:50:31 momjian Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -81,6 +81,9 @@ bool Log_disconnections = false; LogStmtLevel log_statement = LOGSTMT_NONE; +/* flag indicating if the statement satisfies log_statement */ +bool statement_logged; + /* GUC variable for maximum stack depth (measured in kilobytes) */ int max_stack_depth = 2048; @@ -463,9 +466,13 @@ pg_parse_query(const char *query_string) List *raw_parsetree_list; ListCell *parsetree_item; + statement_logged = false; if (log_statement == LOGSTMT_ALL) + { ereport(LOG, (errmsg("statement: %s", query_string))); + statement_logged = true; + } if (log_parser_stats) ResetUsage(); @@ -501,6 +508,7 @@ pg_parse_query(const char *query_string) { ereport(LOG, (errmsg("statement: %s", query_string))); + statement_logged = true; break; } commandTag = CreateCommandTag(parsetree); @@ -512,6 +520,7 @@ pg_parse_query(const char *query_string) { ereport(LOG, (errmsg("statement: %s", query_string))); + statement_logged = true; break; } } @@ -1003,7 +1012,8 @@ exec_simple_query(const char *query_string) } usecs = (long) (stop_t.tv_sec - start_t.tv_sec) * 1000000 + (long) (stop_t.tv_usec - start_t.tv_usec); - if (save_log_duration) + /* Only print duration if we previously printed the statement. */ + if (statement_logged && save_log_duration) ereport(LOG, (errmsg("duration: %ld.%03ld ms", (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 + |