Re: fix log_min_duration_statement logic error - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: fix log_min_duration_statement logic error
Date
Msg-id 200309291851.h8TIpen03137@candle.pha.pa.us
Whole thread Raw
In response to fix log_min_duration_statement logic error  (Neil Conway <neilc@samurai.com>)
List pgsql-patches
Patch applied.  Thanks.

I also marged this test into log_duration and use the same log tag for
both, as suggested.

---------------------------------------------------------------------------


Neil Conway wrote:
> 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
>

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/backend/tcop/postgres.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/tcop/postgres.c,v
retrieving revision 1.367
diff -c -c -r1.367 postgres.c
*** src/backend/tcop/postgres.c    29 Sep 2003 00:05:25 -0000    1.367
--- src/backend/tcop/postgres.c    29 Sep 2003 18:28:27 -0000
***************
*** 955,979 ****
          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),
                              (long) (stop_t.tv_usec - start_t.tv_usec),
                              query_string)));
-
-         /*
-          * If the user is requesting logging of all durations, then log
-          * that as well.
-          */
-         if (save_log_duration)
-             ereport(LOG,
-                     (errmsg("duration: %ld.%06ld sec",
-                             (long) (stop_t.tv_sec - start_t.tv_sec),
-                             (long) (stop_t.tv_usec - start_t.tv_usec))));
      }

      if (save_log_statement_stats)
--- 955,971 ----
          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, or if we are to print all durations.
           */
!         if (save_log_duration ||
!             (save_log_min_duration_statement > 0 &&
!              usecs >= save_log_min_duration_statement * 1000))
              ereport(LOG,
!                     (errmsg("duration: %ld.%06ld %s",
                              (long) (stop_t.tv_sec - start_t.tv_sec),
                              (long) (stop_t.tv_usec - start_t.tv_usec),
                              query_string)));
      }

      if (save_log_statement_stats)

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: bug fix: TupleDescGetAttInMetadata/BuildTupleFromCStrings
Next
From: Bruce Momjian
Date:
Subject: Re: fix log_min_duration_statement logic error