This patch fixes an obvious bug in the "should I print the duration of this query?" logic in postgres.c
I also don't particularly like the format of the log message (for one thing, the "duration_statement" prefix in the log message shouldn't include an underscore, it's not a variable or anything -- and the case can be made that if we printed the duration because log_duration is set, we don't need to print it again if the duration of the query exceeded log_min_duration_statement), but I haven't changed it. -Neil
Index: src/backend/tcop/postgres.c =================================================================== RCS file: /var/lib/cvs/pgsql-server/src/backend/tcop/postgres.c,v retrieving revision 1.363 diff -c -r1.363 postgres.c *** src/backend/tcop/postgres.c 14 Sep 2003 00:03:32 -0000 1.363 --- src/backend/tcop/postgres.c 22 Sep 2003 16:14:37 -0000 *************** *** 955,964 **** usecs = (long) (stop_t.tv_sec - start_t.tv_sec) * 1000000 + (long) (stop_t.tv_usec - start_t.tv_usec); /* ! * Output a duration_query to the log if the query has exceeded * the min duration. */ ! if (usecs >= save_log_min_duration_statement * 1000) ereport(LOG, (errmsg("duration_statement: %ld.%06ld %s", (long) (stop_t.tv_sec - start_t.tv_sec), --- 955,965 ---- usecs = (long) (stop_t.tv_sec - start_t.tv_sec) * 1000000 + (long) (stop_t.tv_usec - start_t.tv_usec); /* ! * Output a duration_statement to the log if the query has exceeded * the min duration. */ ! if (save_log_min_duration_statement > 0 && ! usecs >= save_log_min_duration_statement * 1000) ereport(LOG, (errmsg("duration_statement: %ld.%06ld %s", (long) (stop_t.tv_sec - start_t.tv_sec),
---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster