summaryrefslogtreecommitdiff
path: root/sql/log.cc
diff options
context:
space:
mode:
authorunknown <tsmith@quadxeon.mysql.com>2007-04-04 21:40:47 +0200
committerunknown <tsmith@quadxeon.mysql.com>2007-04-04 21:40:47 +0200
commit82e1076767aa086cb00f2c8e80afd81e14e8d448 (patch)
tree32d6f39cd3cf886c4be2b7f7ccae5fbd705771bb /sql/log.cc
parent504d42a4ce382762afce0aff1fe1be44c335749e (diff)
downloadmariadb-git-82e1076767aa086cb00f2c8e80afd81e14e8d448.tar.gz
Bug #27638: slow logging to CSV table inserts bad query_time and lock_time values
When MySQL logged slow query information to a CSV table, it stored the query_time and lock_time values with an incorrect formula. If the time was over 59 seconds, this caused incorrect statistics (either the slow query was not logged, or the time was far from correct). This change fixes the method used to store those TIME values in the slow_log table. mysql-test/r/log_tables-big.result: BitKeeper file /benchmarks/ext3/TOSAVE/tsmith/bk/maint/51/mysql-test/r/log_tables-big.result mysql-test/t/log_tables-big-master.opt: BitKeeper file /benchmarks/ext3/TOSAVE/tsmith/bk/maint/51/mysql-test/t/log_tables-big-master.opt mysql-test/t/log_tables-big.test: BitKeeper file /benchmarks/ext3/TOSAVE/tsmith/bk/maint/51/mysql-test/t/log_tables-big.test sql/time.cc: initialize all TIME fields (except neg, which may store a needed value) in calc_time_from_sec() sql/log.cc: Log_to_csv_event_handler::log_slow(): call store_time() instead of store() for query_time and lock_time include/my_time.h: Add TIME_MAX_VALUE_SECONDS definition
Diffstat (limited to 'sql/log.cc')
-rw-r--r--sql/log.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 57f16a1e11e..3cfcabd8363 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -569,11 +569,21 @@ bool Log_to_csv_event_handler::
if (query_start_arg)
{
+ /*
+ A TIME field can not hold the full longlong range; query_time or
+ lock_time may be truncated without warning here, if greater than
+ 839 hours (~35 days)
+ */
+ TIME t;
+ t.neg= 0;
+
/* fill in query_time field */
- if (table->field[2]->store(query_time, TRUE))
+ calc_time_from_sec(&t, (long) min(query_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
+ if (table->field[2]->store_time(&t, MYSQL_TIMESTAMP_TIME))
goto err;
/* lock_time */
- if (table->field[3]->store(lock_time, TRUE))
+ calc_time_from_sec(&t, (long) min(lock_time, (longlong) TIME_MAX_VALUE_SECONDS), 0);
+ if (table->field[3]->store_time(&t, MYSQL_TIMESTAMP_TIME))
goto err;
/* rows_sent */
if (table->field[4]->store((longlong) thd->sent_row_count, TRUE))