summaryrefslogtreecommitdiff
path: root/sql/sql_profile.cc
diff options
context:
space:
mode:
authorcmiller@zippy.cornsilk.net <>2007-07-03 12:20:19 -0400
committercmiller@zippy.cornsilk.net <>2007-07-03 12:20:19 -0400
commitda78d3b7a3a244ea50e294502561bcea7b369101 (patch)
tree0047088e444a1d70a42c9b5ef897efb4af7ee8df /sql/sql_profile.cc
parent0483091a8ce3cb566d495cdbd064d37f25828fed (diff)
downloadmariadb-git-da78d3b7a3a244ea50e294502561bcea7b369101.tar.gz
In 5.0, Field_double::val_str uses "%g" to render floating point
numbers, which uses "X.YeZ" notation when the exponent Z would be less than -4. That behavior at -4 is not exactly what we want, and our Decimal type offers smarter number representation. By changing profiling to use Decimal types, we get more readable output.
Diffstat (limited to 'sql/sql_profile.cc')
-rw-r--r--sql/sql_profile.cc35
1 files changed, 25 insertions, 10 deletions
diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc
index fbb05a988c5..d4e3568f592 100644
--- a/sql/sql_profile.cc
+++ b/sql/sql_profile.cc
@@ -44,9 +44,9 @@ ST_FIELD_INFO query_profile_statistics_info[]=
{"QUERY_ID", 20, MYSQL_TYPE_LONG, 0, false, "Query_id"},
{"SEQ", 20, MYSQL_TYPE_LONG, 0, false, "Seq"},
{"STATE", 30, MYSQL_TYPE_STRING, 0, false, "Status"},
- {"DURATION", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, false, "Duration"},
- {"CPU_USER", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, true, "CPU_user"},
- {"CPU_SYSTEM", TIME_FLOAT_DIGITS, MYSQL_TYPE_DOUBLE, 0, true, "CPU_system"},
+ {"DURATION", TIME_FLOAT_DIGITS, MYSQL_TYPE_DECIMAL, 0, false, "Duration"},
+ {"CPU_USER", TIME_FLOAT_DIGITS, MYSQL_TYPE_DECIMAL, 0, true, "CPU_user"},
+ {"CPU_SYSTEM", TIME_FLOAT_DIGITS, MYSQL_TYPE_DECIMAL, 0, true, "CPU_system"},
{"CONTEXT_VOLUNTARY", 20, MYSQL_TYPE_LONG, 0, true, "Context_voluntary"},
{"CONTEXT_INVOLUNTARY", 20, MYSQL_TYPE_LONG, 0, true, "Context_involuntary"},
{"BLOCK_OPS_IN", 20, MYSQL_TYPE_LONG, 0, true, "Block_ops_in"},
@@ -557,16 +557,31 @@ int PROFILING::fill_statistics_info(THD *thd, struct st_table_list *tables, Item
*/
table->field[2]->store(previous->status, strlen(previous->status),
system_charset_info);
- table->field[3]->store((double)(entry->time_usecs -
- previous->time_usecs)/(1000*1000));
+
+ my_decimal duration;
+ double2my_decimal(E_DEC_FATAL_ERROR,
+ (entry->time_usecs-previous->time_usecs)/(1000.0*1000),
+ &duration);
+ table->field[3]->store_decimal(&duration);
#ifdef HAVE_GETRUSAGE
- table->field[4]->store((double)RUSAGE_DIFF_USEC(entry->rusage.ru_utime,
- previous->rusage.ru_utime)/(1000.0*1000));
- table->field[4]->set_notnull();
- table->field[5]->store((double)RUSAGE_DIFF_USEC(entry->rusage.ru_stime,
- previous->rusage.ru_stime)/(1000.0*1000));
+ my_decimal cpu_utime, cpu_stime;
+ double2my_decimal(E_DEC_FATAL_ERROR,
+ RUSAGE_DIFF_USEC(entry->rusage.ru_utime,
+ previous->rusage.ru_utime) /
+ (1000.0*1000),
+ &cpu_utime);
+
+ double2my_decimal(E_DEC_FATAL_ERROR,
+ RUSAGE_DIFF_USEC(entry->rusage.ru_stime,
+ previous->rusage.ru_stime) /
+ (1000.0*1000),
+ &cpu_stime);
+
+ table->field[4]->store_decimal(&cpu_utime);
+ table->field[5]->store_decimal(&cpu_stime);
+ table->field[4]->set_notnull();
table->field[5]->set_notnull();
#else
/* TODO: Add CPU-usage info for non-BSD systems */