Index: doc/src/sgml/runtime.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v
retrieving revision 1.287
diff -c -c -r1.287 runtime.sgml
*** doc/src/sgml/runtime.sgml 9 Oct 2004 23:12:53 -0000 1.287
--- doc/src/sgml/runtime.sgml 15 Oct 2004 16:47:40 -0000
***************
*** 2355,2367 ****
log_duration (boolean)
! Causes the duration of every completed statement to be logged.
! To use this option, it is recommended that you also enable
! log_statement> and if not using syslog>
! log the PID using log_line_prefix> so that you
! can link the statement to the duration using the process
! ID. The default is off. Only superusers can turn off this
! option if it is enabled by the administrator.
--- 2355,2368 ----
log_duration (boolean)
! Causes the duration of every completed statement which satisfies
! log_statement> to be logged. When using this option,
! if you are not using syslog>, it is recommended
! that you log the PID or session ID using log_line_prefix>
! or log the session ID so that you can link the statement to the
! duration using the process ID or session ID. The default is off.
! Only superusers can turn off this option if it is enabled by the
! administrator.
Index: src/backend/tcop/postgres.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/tcop/postgres.c,v
retrieving revision 1.435
diff -c -c -r1.435 postgres.c
*** src/backend/tcop/postgres.c 12 Oct 2004 21:54:40 -0000 1.435
--- src/backend/tcop/postgres.c 15 Oct 2004 16:47:52 -0000
***************
*** 81,86 ****
--- 81,89 ----
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,471 ****
--- 466,478 ----
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,506 ****
--- 508,514 ----
{
ereport(LOG,
(errmsg("statement: %s", query_string)));
+ statement_logged = true;
break;
}
commandTag = CreateCommandTag(parsetree);
***************
*** 512,517 ****
--- 520,526 ----
{
ereport(LOG,
(errmsg("statement: %s", query_string)));
+ statement_logged = true;
break;
}
}
***************
*** 1003,1009 ****
}
usecs = (long) (stop_t.tv_sec - start_t.tv_sec) * 1000000 + (long) (stop_t.tv_usec - start_t.tv_usec);
! if (save_log_duration)
ereport(LOG,
(errmsg("duration: %ld.%03ld ms",
(long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 +
--- 1012,1019 ----
}
usecs = (long) (stop_t.tv_sec - start_t.tv_sec) * 1000000 + (long) (stop_t.tv_usec - start_t.tv_usec);
! /* 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 +