1421
1421
0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100,
1422
1422
1, 100, 0, 1, 0},
1423
- {"long_query_time", OPT_LONG_QUERY_TIME,
1424
- "Log all queries that have taken more than long_query_time seconds to execute to file.",
1425
- (gptr*) &global_system_variables.long_query_time,
1426
- (gptr*) &max_system_variables.long_query_time, 0, GET_ULONG,
1427
- REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0},
1423
1428
+ {"log_slow_filter", OPT_LOG_SLOW_FILTER,
1424
1429
+ "Log only the queries that followed certain execution plan. Multiple flags allowed in a comma-separated string. [qc_miss, full_scan, full_join, tmp_table, tmp_table_on_disk, filesort, filesort_on_disk]",
1425
1430
+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_F_NONE, 0, 0},
1431
1436
+ {"log_slow_verbosity", OPT_LOG_SLOW_VERBOSITY,
1432
1437
+ "Choose how verbose the messages to your slow log will be. Multiple flags allowed in a comma-separated string. [microtime, query_plan, innodb]",
1433
1438
+ 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, SLOG_V_MICROTIME, 0, 0},
1434
{"long_query_time", OPT_LONG_QUERY_TIME,
1435
"Log all queries that have taken more than long_query_time seconds to execute to file.",
1436
(gptr*) &global_system_variables.long_query_time,
1437
(gptr*) &max_system_variables.long_query_time, 0, GET_ULONG,
1438
- REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0},
1439
+ {"long_query_time", OPT_LONG_QUERY_TIME,
1440
+ "Log all queries that have taken more than long_query_time seconds to execute to file.",
1441
+ (gptr*) &global_system_variables.long_query_time,
1442
+ (gptr*) &max_system_variables.long_query_time, 0, GET_STR,
1439
1443
+ REQUIRED_ARG, 10000000, 0, LONG_TIMEOUT * 1000000, 0, 1, 0},
1440
1444
+ {"min_examined_row_limit", OPT_MIN_EXAMINED_ROW_LIMIT,
1441
1445
+ "Don't log queries which examine less than min_examined_row_limit rows to file.",
1445
1449
{"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES,
1446
1450
"If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive. Should be set to 2 if you are using a case insensitive file system",
1447
1451
(gptr*) &lower_case_table_names,
1448
@@ -6826,7 +6854,9 @@ static void mysql_init_variables(void)
1452
@@ -6826,7 +6854,11 @@ static void mysql_init_variables(void)
1449
1453
global_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
1450
1454
max_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
1451
1455
global_system_variables.old_passwords= 0;
1457
+ global_system_variables.long_query_time = 10000000;
1458
+ max_system_variables.long_query_time = LONG_TIMEOUT * 1000000;
1453
1459
+ global_system_variables.log_slow_verbosity= SLOG_V_MICROTIME;
1454
1460
+ global_system_variables.log_slow_filter= SLOG_F_NONE;
1457
1463
Default behavior for 4.1 and 5.0 is to treat NULL values as unequal
1458
1464
when collecting index statistics for MyISAM tables.
1459
@@ -7287,6 +7317,33 @@ get_one_option(int optid, const struct m
1465
@@ -7287,6 +7319,35 @@ get_one_option(int optid, const struct m
1460
1466
case OPT_BOOTSTRAP:
1461
1467
opt_noacl=opt_bootstrap=1;
1474
1480
+ msl_flag_resolve_by_name(slog_verb, argument,
1475
1481
+ SLOG_V_NONE, SLOG_V_INVALID)) == SLOG_V_INVALID)
1477
+ fprintf(stderr,"Invalid argument to log_slow_verbosity\n");
1483
+ fprintf(stderr,"Invalid argument in log_slow_verbosity: %s\n", argument);
1481
1487
+ case OPT_LONG_QUERY_TIME:
1483
+ Fix up low values to ensure backward compatibility in microslow patch:
1484
+ if long_query_time < 600 (10 minutes in old granularity)
1485
+ then we simply adjust it for microseconds.
1487
+ if (global_system_variables.long_query_time < 600)
1488
+ global_system_variables.long_query_time *= 1000000;
1489
+ double doubleslow = strtod(argument,NULL);
1490
+ if (doubleslow < 0 || doubleslow > (LONG_TIMEOUT))
1492
+ fprintf(stderr,"Out of range long_query_time value: %s\n", argument);
1495
+ global_system_variables.long_query_time = (ulonglong) (doubleslow * 1000000);
1490
1498
case OPT_STORAGE_ENGINE:
1492
1500
if ((enum db_type)((global_system_variables.table_type=
1493
@@ -7619,10 +7676,14 @@ static void get_options(int argc,char **
1501
@@ -7619,10 +7680,14 @@ static void get_options(int argc,char **
1495
1503
sql_print_warning("this binary does not contain BDB storage engine");
1517
1525
&opt_log_queries_not_using_indexes);
1518
1526
sys_var_thd_ulong sys_log_warnings("log_warnings", &SV::log_warnings);
1519
1527
-sys_var_thd_ulong sys_long_query_time("long_query_time",
1520
+sys_var_thd_ulonglong sys_long_query_time("long_query_time",
1528
+sys_var_thd_microtime sys_long_query_time("long_query_time",
1521
1529
&SV::long_query_time);
1522
1530
sys_var_bool_const_ptr sys_log_slow("log_slow_queries", &opt_slow_log);
1523
1531
sys_var_thd_bool sys_low_priority_updates("low_priority_updates",
1569
1577
&sys_multi_range_count,
1570
1578
&sys_myisam_data_pointer_size,
1571
1579
&sys_myisam_max_sort_file_size,
1572
@@ -973,6 +993,8 @@ struct show_var_st init_vars[]= {
1580
@@ -973,8 +993,10 @@ struct show_var_st init_vars[]= {
1573
1581
{"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_MY_BOOL},
1575
1583
{sys_log_slow.name, (char*) &sys_log_slow, SHOW_SYS},
1576
1584
+ {sys_log_slow_filter.name, (char*) &sys_log_slow_filter, SHOW_SYS},
1577
1585
+ {sys_log_slow_verbosity.name, (char*) &sys_log_slow_verbosity, SHOW_SYS},
1578
1586
{sys_log_warnings.name, (char*) &sys_log_warnings, SHOW_SYS},
1579
{sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_SYS},
1587
- {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_SYS},
1588
+ {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_MICROTIME},
1580
1589
{sys_low_priority_updates.name, (char*) &sys_low_priority_updates, SHOW_SYS},
1590
{"lower_case_file_system", (char*) &lower_case_file_system, SHOW_MY_BOOL},
1591
{"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT},
1581
1592
@@ -1001,6 +1023,7 @@ struct show_var_st init_vars[]= {
1582
1593
{sys_max_tmp_tables.name, (char*) &sys_max_tmp_tables, SHOW_SYS},
1583
1594
{sys_max_user_connections.name,(char*) &sys_max_user_connections, SHOW_SYS},
1594
1605
{sys_read_buff_size.name, (char*) &sys_read_buff_size, SHOW_SYS},
1595
1606
{sys_readonly.name, (char*) &sys_readonly, SHOW_SYS},
1596
1607
{sys_read_rnd_buff_size.name,(char*) &sys_read_rnd_buff_size, SHOW_SYS},
1597
@@ -1654,6 +1678,57 @@ byte *sys_var_thd_ulong::value_ptr(THD *
1598
return (byte*) &(thd->variables.*offset);
1608
@@ -1755,6 +1779,17 @@ byte *sys_var_thd_ulonglong::value_ptr(T
1601
+void sys_var_thd_microtime::set_default(THD *thd, enum_var_type type)
1603
+ pthread_mutex_lock(&LOCK_global_system_variables);
1604
+ global_system_variables.*offset= (ulonglong) option_limits->def_value;
1605
+ pthread_mutex_unlock(&LOCK_global_system_variables);
1608
1612
+bool sys_var_thd_microtime::check(THD *thd, set_var *var)
1610
1614
+ if (var->value->result_type() == DECIMAL_RESULT)
1611
1615
+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_real() * 1000000);
1613
+ var->save_result.ulonglong_value= (ulonglong)var->value->val_int() * 1000000;
1617
+ var->save_result.ulonglong_value= (ulonglong)(var->value->val_int() * 1000000);
1617
+byte *sys_var_thd_microtime::value_ptr(THD *thd, enum_var_type type,
1620
+ if (type == OPT_GLOBAL)
1621
+ return (byte*) &(global_system_variables.*offset);
1622
+ return (byte*) &(thd->variables.*offset);
1625
+bool sys_var_thd_microtime::update(THD *thd, set_var *var)
1627
+ bool fixed= FALSE;
1628
+ ulonglong tmp= var->save_result.ulonglong_value;
1630
+ if (tmp > max_system_variables.*offset)
1631
+ tmp= max_system_variables.*offset;
1633
+ if (option_limits)
1634
+ tmp= getopt_ull_limit_value(tmp, option_limits, &fixed);
1637
+ throw_bounds_warning(thd, option_limits->name, tmp);
1639
+ /* Lock is needed to make things safe on 32 bit systems */
1640
+ if (var->type == OPT_GLOBAL)
1623
bool sys_var_thd_bool::update(THD *thd, set_var *var)
1625
if (var->type == OPT_GLOBAL)
1626
@@ -1911,6 +1946,19 @@ Item *sys_var::item(THD *thd, enum_var_t
1627
pthread_mutex_unlock(&LOCK_global_system_variables);
1628
return new Item_int(value);
1630
+ case SHOW_MICROTIME:
1642
+ /* Lock is needed to make things safe on 32 bit systems */
1643
1636
+ pthread_mutex_lock(&LOCK_global_system_variables);
1644
+ global_system_variables.*offset= tmp;
1637
+ value= *(longlong*) value_ptr(thd, var_type, base);
1645
1638
+ pthread_mutex_unlock(&LOCK_global_system_variables);
1640
+ len = snprintf(buff, 80, "%f", ((double) value) / 1000000.0);
1641
+ return new Item_float(buff,len);
1648
+ thd->variables.*offset= (ulonglong) tmp;
1653
bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
1655
@@ -3498,6 +3573,191 @@ int set_var_password::update(THD *thd)
1646
@@ -3498,6 +3546,191 @@ int set_var_password::update(THD *thd)
1864
1855
class sys_var_thd_ulong :public sys_var_thd
1866
1857
sys_check_func check_func;
1867
@@ -329,6 +329,23 @@ public:
1868
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1871
+class sys_var_thd_microtime :public sys_var_thd
1858
@@ -329,7 +329,6 @@ public:
1859
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1863
class sys_var_thd_ha_rows :public sys_var_thd
1866
@@ -347,7 +346,6 @@ public:
1867
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1871
class sys_var_thd_ulonglong :public sys_var_thd
1874
@@ -376,6 +374,19 @@ public:
1878
+class sys_var_thd_microtime :public sys_var_thd_ulonglong
1874
+ ulonglong SV::*offset;
1875
1881
+ sys_var_thd_microtime(const char *name_arg, ulonglong SV::*offset_arg)
1876
+ :sys_var_thd(name_arg), offset(offset_arg)
1882
+ :sys_var_thd_ulonglong(name_arg, offset_arg)
1878
+ bool update(THD *thd, set_var *var);
1879
+ void set_default(THD *thd, enum_var_type type);
1880
+ SHOW_TYPE type() { return SHOW_MICROTIME; }
1881
+ byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1884
+ SHOW_TYPE show_type() { return SHOW_MICROTIME; }
1882
1885
+ bool check(THD *thd, set_var *var);
1883
1886
+ bool check_update_type(Item_result type)
1885
1888
+ return type != INT_RESULT && type != DECIMAL_RESULT;
1889
class sys_var_thd_ha_rows :public sys_var_thd
1891
@@ -347,7 +364,6 @@ public:
1892
byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1896
class sys_var_thd_ulonglong :public sys_var_thd
1899
@@ -376,7 +392,6 @@ public:
1904
1892
class sys_var_thd_bool :public sys_var_thd
1907
@@ -447,6 +462,66 @@ public:
1894
@@ -447,6 +458,66 @@ public:
1971
1958
class sys_var_thd_storage_engine :public sys_var_thd
1974
@@ -1042,3 +1117,11 @@ void free_key_cache(const char *name, KE
1961
@@ -1042,3 +1113,11 @@ void free_key_cache(const char *name, KE
1975
1962
bool process_key_caches(int (* func) (const char *name, KEY_CACHE *));
1976
1963
void delete_elements(I_List<NAMED_LIST> *list,
1977
1964
void (*free_element)(const char*, gptr));
2353
2340
===================================================================
2354
2341
--- mysql-5.0.67.orig/sql/sql_show.cc
2355
2342
+++ mysql-5.0.67/sql/sql_show.cc
2356
@@ -1531,6 +1531,9 @@ static bool show_status_array(THD *thd,
2343
@@ -1531,6 +1531,12 @@ static bool show_status_array(THD *thd,
2357
2344
case SHOW_LONGLONG:
2358
2345
end= longlong10_to_str(*(longlong*) value, buff, 10);
2360
2347
+ case SHOW_MICROTIME:
2361
+ end= buff + sprintf(buff, "%.6f", (*(ulonglong*)value) / 1000000.0);
2348
+ show_type= ((sys_var*) value)->show_type();
2349
+ value= (char*) ((sys_var*) value)->value_ptr(thd, value_type,
2351
+ end= buff + sprintf(buff, "%f", (((double) (*(ulonglong*)value))) / 1000000.0);
2363
2353
case SHOW_HA_ROWS:
2364
2354
end= longlong10_to_str((longlong) *(ha_rows*) value, buff, 10);