MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:He Zhenxing Date:May 1 2010 12:03pm
Subject:bzr commit into mysql-5.1-bugteam branch (zhenxing.he:3453) Bug#52704
View as plain text  
#At file:///media/sda3/work/mysql/bzrwork/b52704/5.1-bugteam/ based on revid:svoj@stripped

 3453 He Zhenxing	2010-05-01
      Bug#52704 exec_time=4294967295
      
      thd->start_time was used to calculate the exec_time of the query,
      since thd->start_time can be affected by TIMESTAMP session variable,
      this would result in a very big value when TIMESTAMP is set to a
      future time before execution a query.
      
      Fixed by adding a new varialbe thd->real_start_time, which will
      not be affected by TIMESTAMP, and use this to calculate the
      execution time of the query.
     @ sql/log_event.cc
        use real_start_time to calculate the execution time of the query, which is not affected by the TIMESTAMP session variable
     @ sql/sql_class.h
        add real_start_time to record the real system start time of the query, which is not affected by the TIMESTAMP session variable

    modified:
      sql/log_event.cc
      sql/sql_class.h
=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2010-03-28 11:57:33 +0000
+++ b/sql/log_event.cc	2010-05-01 12:03:34 +0000
@@ -2394,7 +2394,8 @@ Query_log_event::Query_log_event(THD* th
   error_code= errcode;
 
   time(&end_time);
-  exec_time = (ulong) (end_time  - thd_arg->start_time);
+  DBUG_ASSERT(end_time >= thd_arg->real_start_time);
+  exec_time = (ulong) (end_time  - thd_arg->real_start_time);
   /**
     @todo this means that if we have no catalog, then it is replicated
     as an existing catalog of length zero. is that safe? /sven
@@ -4241,7 +4242,8 @@ Load_log_event::Load_log_event(THD *thd_
 {
   time_t end_time;
   time(&end_time);
-  exec_time = (ulong) (end_time  - thd_arg->start_time);
+  DBUG_ASSERT(end_time >= thd_arg->real_start_time);
+  exec_time = (ulong) (end_time  - thd_arg->real_start_time);
   /* db can never be a zero pointer in 4.0 */
   db_len = (uint32) strlen(db);
   table_name_len = (uint32) strlen(table_name);

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2010-04-14 09:53:59 +0000
+++ b/sql/sql_class.h	2010-05-01 12:03:34 +0000
@@ -1414,6 +1414,9 @@ public:
   /* remote (peer) port */
   uint16 peer_port;
   time_t     start_time, user_time;
+  time_t     real_start_time;        /* The real start time of the
+                                      * query, not affected by
+                                      * TIMESTAMP session variable */
   // track down slow pthread_create
   ulonglong  prior_thr_create_utime, thr_create_utime;
   ulonglong  start_utime, utime_after_lock;
@@ -2008,19 +2011,14 @@ public:
   inline time_t query_start() { query_start_used=1; return start_time; }
   inline void set_time()
   {
-    if (user_time)
-    {
-      start_time= user_time;
-      start_utime= utime_after_lock= my_micro_time();
-    }
-    else
-      start_utime= utime_after_lock= my_micro_time_and_time(&start_time);
+    start_utime= utime_after_lock= my_micro_time_and_time(&real_start_time);
+    start_time = user_time ? user_time : real_start_time;
   }
-  inline void	set_current_time()    { start_time= my_time(MY_WME); }
+  inline void	set_current_time() { real_start_time= start_time= my_time(MY_WME); }
   inline void	set_time(time_t t)
   {
     start_time= user_time= t;
-    start_utime= utime_after_lock= my_micro_time();
+    set_time();
   }
   void set_time_after_lock()  { utime_after_lock= my_micro_time(); }
   ulonglong current_utime()  { return my_micro_time(); }


Attachment: [text/bzr-bundle] bzr/zhenxing.he@sun.com-20100501120334-2i7j6g0nswhc2k3g.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (zhenxing.he:3453) Bug#52704He Zhenxing1 May
  • Re: bzr commit into mysql-5.1-bugteam branch (zhenxing.he:3453)Bug#52704Luís Soares4 May
    • Re: bzr commit into mysql-5.1-bugteam branch (zhenxing.he:3453)Bug#52704He Zhenxing12 May
  • Re: bzr commit into mysql-5.1-bugteam branch (zhenxing.he:3453)Bug#52704Libing Song12 May
    • Re: bzr commit into mysql-5.1-bugteam branch (zhenxing.he:3453)Bug#52704Libing Song13 May