~ourdelta-developers/ourdelta/ourdelta-mysqlhotcopy

« back to all changes in this revision

Viewing changes to mysql/5.0/percona/microslow_innodb/microslow_innodb.patch

Merge from percona d6 (MySQL 5.0) branch.
microslow backward compatibility fixups

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
+Version=1.1
9
9
+Author=Percona <info@percona.com>
10
10
+License=GPL
11
 
+Comment=Minor fixes by Arjen Lentz <arjen@openquery.com.au>
 
11
+Comment=Fixups (backward compatibility) by Arjen Lentz <arjen@openquery.com.au>
12
12
Index: mysql-5.0.67/include/my_time.h
13
13
===================================================================
14
14
--- mysql-5.0.67.orig/include/my_time.h
1420
1420
    (gptr*) 0,
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;
1452
1456
-
 
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;
1455
1461
+  
1456
1462
   /*
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;
1462
1468
     break;
1465
1471
+          msl_flag_resolve_by_name(slog_filter, argument,
1466
1472
+                                   SLOG_F_NONE, SLOG_F_INVALID)) == SLOG_F_INVALID)
1467
1473
+    {
1468
 
+      fprintf(stderr,"Invalid argument to log_slow_filter\n");
 
1474
+      fprintf(stderr,"Invalid argument in log_slow_filter: %s\n", argument);
1469
1475
+      exit(1);
1470
1476
+    }
1471
1477
+    break;
1474
1480
+         msl_flag_resolve_by_name(slog_verb, argument,
1475
1481
+                                  SLOG_V_NONE, SLOG_V_INVALID)) == SLOG_V_INVALID)
1476
1482
+    {
1477
 
+      fprintf(stderr,"Invalid argument to log_slow_verbosity\n");
 
1483
+      fprintf(stderr,"Invalid argument in log_slow_verbosity: %s\n", argument);
1478
1484
+      exit(1);
1479
1485
+    }
1480
1486
+    break;
1481
1487
+  case OPT_LONG_QUERY_TIME:
1482
 
+    /*
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.
1486
 
+    */
1487
 
+    if (global_system_variables.long_query_time < 600)
1488
 
+      global_system_variables.long_query_time *= 1000000;
 
1488
+  {
 
1489
+    double doubleslow = strtod(argument,NULL);
 
1490
+    if (doubleslow < 0 || doubleslow > (LONG_TIMEOUT))
 
1491
+    {
 
1492
+      fprintf(stderr,"Out of range long_query_time value: %s\n", argument);
 
1493
+      exit(1);
 
1494
+    }
 
1495
+    global_system_variables.long_query_time = (ulonglong) (doubleslow * 1000000);
1489
1496
+    break;
 
1497
+  }
1490
1498
   case OPT_STORAGE_ENGINE:
1491
1499
   {
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 **
1494
1502
   if (opt_bdb)
1495
1503
     sql_print_warning("this binary does not contain BDB storage engine");
1496
1504
 #endif
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},
1574
1582
 #endif
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
1599
1609
 }
1600
1610
 
1601
 
+void sys_var_thd_microtime::set_default(THD *thd, enum_var_type type)
1602
 
+{
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);
1606
 
+}
1607
 
+
 
1611
 
1608
1612
+bool sys_var_thd_microtime::check(THD *thd, set_var *var)
1609
1613
+{
1610
1614
+  if (var->value->result_type() == DECIMAL_RESULT)
1611
1615
+    var->save_result.ulonglong_value= (ulonglong)(var->value->val_real() * 1000000);
1612
 
+  else 
1613
 
+    var->save_result.ulonglong_value= (ulonglong)var->value->val_int() * 1000000;
 
1616
+  else
 
1617
+    var->save_result.ulonglong_value= (ulonglong)(var->value->val_int() * 1000000);
 
1618
+
1614
1619
+  return 0;
1615
1620
+}
1616
1621
+
1617
 
+byte *sys_var_thd_microtime::value_ptr(THD *thd, enum_var_type type,
1618
 
+                                  LEX_STRING *base)
1619
 
+{
1620
 
+  if (type == OPT_GLOBAL)
1621
 
+    return (byte*) &(global_system_variables.*offset);
1622
 
+  return (byte*) &(thd->variables.*offset);
1623
 
+}
1624
 
+
1625
 
+bool sys_var_thd_microtime::update(THD *thd,  set_var *var)
1626
 
+{
1627
 
+  bool fixed= FALSE;
1628
 
+  ulonglong tmp= var->save_result.ulonglong_value;
1629
 
+
1630
 
+  if (tmp > max_system_variables.*offset)
1631
 
+    tmp= max_system_variables.*offset;
1632
 
+
1633
 
+  if (option_limits)
1634
 
+    tmp= getopt_ull_limit_value(tmp, option_limits, &fixed);
1635
 
+
1636
 
+  if (fixed)
1637
 
+    throw_bounds_warning(thd, option_limits->name, tmp);
1638
 
+  
1639
 
+  /* Lock is needed to make things safe on 32 bit systems */
1640
 
+  if (var->type == OPT_GLOBAL)
 
1622
+
 
1623
 bool sys_var_thd_bool::update(THD *thd,  set_var *var)
 
1624
 {
 
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);
 
1629
   }
 
1630
+  case SHOW_MICROTIME:
1641
1631
+  {
1642
 
+    /* Lock is needed to make things safe on 32 bit systems */
 
1632
+    longlong value;
 
1633
+    char buff[80];
 
1634
+    int len;
 
1635
+
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);
 
1639
+
 
1640
+    len = snprintf(buff, 80, "%f", ((double) value) / 1000000.0);
 
1641
+    return new Item_float(buff,len);
1646
1642
+  }
1647
 
+  else
1648
 
+    thd->variables.*offset= (ulonglong) tmp;
1649
 
+
1650
 
+  return 0;
1651
 
+}
1652
 
 
1653
 
 bool sys_var_thd_ha_rows::update(THD *thd, set_var *var)
1654
 
 {
1655
 
@@ -3498,6 +3573,191 @@ int set_var_password::update(THD *thd)
 
1643
   case SHOW_HA_ROWS:
 
1644
   {
 
1645
     ha_rows value;
 
1646
@@ -3498,6 +3546,191 @@ int set_var_password::update(THD *thd)
1656
1647
 #endif
1657
1648
 }
1658
1649
 
1864
1855
 class sys_var_thd_ulong :public sys_var_thd
1865
1856
 {
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);
1869
 
 };
1870
 
 
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);
 
1860
 };
 
1861
 
 
1862
-
 
1863
 class sys_var_thd_ha_rows :public sys_var_thd
 
1864
 {
 
1865
 public:
 
1866
@@ -347,7 +346,6 @@ public:
 
1867
   byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
 
1868
 };
 
1869
 
 
1870
-
 
1871
 class sys_var_thd_ulonglong :public sys_var_thd
 
1872
 {
 
1873
 public:
 
1874
@@ -376,6 +374,19 @@ public:
 
1875
   }
 
1876
 };
 
1877
 
 
1878
+class sys_var_thd_microtime :public sys_var_thd_ulonglong
1872
1879
+{
1873
1880
+public:
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)
1877
1883
+  {}
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)
1884
 
+  { 
 
1887
+  {
1885
1888
+    return type != INT_RESULT && type != DECIMAL_RESULT;
1886
1889
+  }
1887
1890
+};
1888
1891
 
1889
 
 class sys_var_thd_ha_rows :public sys_var_thd
1890
 
 {
1891
 
@@ -347,7 +364,6 @@ public:
1892
 
   byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
1893
 
 };
1894
 
 
1895
 
-
1896
 
 class sys_var_thd_ulonglong :public sys_var_thd
1897
 
 {
1898
 
 public:
1899
 
@@ -376,7 +392,6 @@ public:
1900
 
   }
1901
 
 };
1902
 
 
1903
 
-
1904
1892
 class sys_var_thd_bool :public sys_var_thd
1905
1893
 {
1906
 
 public:
1907
 
@@ -447,6 +462,66 @@ public:
 
1894
@@ -447,6 +458,66 @@ public:
1908
1895
 };
1909
1896
 
1910
1897
 
1971
1958
 class sys_var_thd_storage_engine :public sys_var_thd
1972
1959
 {
1973
1960
 protected:
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);
2359
2346
           break;
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,
 
2350
+                                                           &null_lex_str);
 
2351
+          end= buff + sprintf(buff, "%f", (((double) (*(ulonglong*)value))) / 1000000.0);
2362
2352
+          break;
2363
2353
         case SHOW_HA_ROWS:
2364
2354
           end= longlong10_to_str((longlong) *(ha_rows*) value, buff, 10);