]> git.pld-linux.org Git - packages/mysql.git/commitdiff
- rel 2; update percona patches auto/th/mysql-5_5_17-2
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Wed, 14 Dec 2011 17:40:12 +0000 (17:40 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    mysql.spec -> 1.562
    query_cache_enhance.patch -> 1.10
    response_time_distribution.patch -> 1.9
    slow_extended.patch -> 1.10

mysql.spec
query_cache_enhance.patch
response_time_distribution.patch
slow_extended.patch

index 75d3d135248d2b9612fe2ea0f0b958dde2fc68c3..7eaae6e44c3bc5343d266b42c44a5cde6c60b705 100644 (file)
@@ -36,7 +36,7 @@ Summary(uk.UTF-8):    MySQL - швидкий SQL-сервер
 Summary(zh_CN.UTF-8):  MySQL数据库服务器
 Name:          mysql
 Version:       5.5.17
-Release:       1
+Release:       2
 License:       GPL + MySQL FLOSS Exception
 Group:         Applications/Databases
 # Source0Download: http://dev.mysql.com/downloads/mysql/5.5.html#downloads
index e8680d94c0c571d13bf16ed921cf046717d40fbe..211d4ebdec5da946757d4e742eafc0d2b5f99b2f 100644 (file)
  #ifdef EMBEDDED_LIBRARY
  #include "emb_qcache.h"
  #endif
-@@ -454,7 +629,14 @@
+@@ -454,7 +629,12 @@
    Query_cache_wait_state wait_state(thd, __func__, __FILE__, __LINE__);
    DBUG_ENTER("Query_cache::try_lock");
  
 +  const char* old_proc_info= thd->proc_info;
 +  thd_proc_info(thd,"Waiting on query cache mutex");
++  DEBUG_SYNC(thd, "before_query_cache_mutex");
    mysql_mutex_lock(&structure_guard_mutex);
-+  DEBUG_SYNC(thd, "status_waiting_on_query_cache_mutex");
-+  DBUG_EXECUTE_IF("status_waiting_on_query_cache_mutex_sleep", {
-+      sleep(1);
-+    });
++  DEBUG_SYNC(thd, "after_query_cache_mutex");
 +  thd->proc_info = old_proc_info;
    while (1)
    {
      if (m_cache_lock_status == Query_cache::UNLOCKED)
-@@ -1274,6 +1456,8 @@
+@@ -1274,6 +1454,8 @@
        unlock();
        DBUG_VOID_RETURN;
      }
  
      /* Key is query + database + flag */
      if (thd->db_length)
-@@ -1451,6 +1635,9 @@
+@@ -1451,6 +1633,9 @@
    Query_cache_block_table *block_table, *block_table_end;
    ulong tot_length;
    Query_cache_query_flags flags;
    DBUG_ENTER("Query_cache::send_result_to_client");
  
    /*
-@@ -1472,21 +1659,103 @@
+@@ -1472,21 +1657,103 @@
  
    {
      uint i= 0;
      if ((my_toupper(system_charset_info, sql[i])     != 'S' ||
           my_toupper(system_charset_info, sql[i + 1]) != 'E' ||
           my_toupper(system_charset_info, sql[i + 2]) != 'L') &&
-@@ -1521,6 +1790,12 @@
+@@ -1521,6 +1788,12 @@
      goto err_unlock;
  
    Query_cache_block *query_block;
  
    tot_length= query_length + thd->db_length + 1 + QUERY_CACHE_FLAGS_SIZE;
    if (thd->db_length)
-@@ -1587,6 +1862,8 @@
+@@ -1587,6 +1860,8 @@
         (uchar*) &flags, QUERY_CACHE_FLAGS_SIZE);
    query_block = (Query_cache_block *)  my_hash_search(&queries, (uchar*) sql,
                                                        tot_length);
 +SET GLOBAL query_cache_size= default;
 +set global query_cache_strip_comments=OFF;
 --- /dev/null
-+++ b/mysql-test/r/percona_status_wait_query_cache_mutex.result
-@@ -0,0 +1,23 @@
-+SET GLOBAL query_cache_size=1355776;
-+flush query cache;
-+flush query cache;
-+reset query cache;
-+flush status;
-+DROP TABLE IF EXISTS t;
-+CREATE TABLE t(id INT, number INT);
-+INSERT INTO t VALUES (0,1);
-+INSERT INTO t VALUES (1,2);
-+INSERT INTO t VALUES (2,3);
-+SET SESSION debug="+d,status_waiting_on_query_cache_mutex_sleep";
-+SET DEBUG_SYNC='status_waiting_on_query_cache_mutex SIGNAL thread_ready';
-+SELECT number from t where id > 0;
-+SHOW PROCESSLIST;
-+Id    User    Host    db      Command Time    State   Info    Rows_sent       Rows_examined   Rows_read
-+###   root    ###     test    Query   ###     NULL    SHOW PROCESSLIST        ###     ###     ###
-+###   root    ###     test    Query   ###     Waiting on query cache mutex    SELECT number from t where id > 0       ###     ###     ###
-+SELECT id, info, state FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY id;
-+id    info    state
-+###   SELECT id, info, state FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY id  executing
-+###   SELECT number from t where id > 0       Waiting on query cache mutex
-+DROP TABLE t;
-+SET GLOBAL query_cache_size=0;
---- /dev/null
 +++ b/mysql-test/t/percona_query_cache_with_comments.test
 @@ -0,0 +1,5 @@
 +--disable_ps_protocol
 +set global query_cache_strip_comments=OFF;
 --- /dev/null
 +++ b/mysql-test/t/percona_status_wait_query_cache_mutex.test
-@@ -0,0 +1,31 @@
+@@ -0,0 +1,35 @@
 +--source include/have_query_cache.inc
 +--source include/have_debug.inc
 +--source include/have_debug_sync.inc
 +SET GLOBAL query_cache_size=1355776;
 +--source include/percona_query_cache_with_comments_clear.inc
++--let try_lock_mutex_query=SELECT "try_lock_mutex_query" as action
 +
-+-- disable_warnings
-+DROP TABLE IF EXISTS t;
-+-- enable_warnings
-+CREATE TABLE t(id INT, number INT);
-+INSERT INTO t VALUES (0,1);
-+INSERT INTO t VALUES (1,2);
-+INSERT INTO t VALUES (2,3);
++--connect (mutex_locked_conn, localhost, root,,)
++--connect (try_mutex_lock_conn, localhost, root,,)
 +
-+--connect (conn,localhost,root,,)
++--connection mutex_locked_conn
++SET DEBUG_SYNC='after_query_cache_mutex SIGNAL mutex_locked WAIT_FOR unlock_mutex';
++send SELECT "mutex_locked_query" as action;
++
++--connection default
++SET DEBUG_SYNC='now WAIT_FOR mutex_locked';
 +
-+--connection conn
-+SET SESSION debug="+d,status_waiting_on_query_cache_mutex_sleep";
-+SET DEBUG_SYNC='status_waiting_on_query_cache_mutex SIGNAL thread_ready';
-+SEND SELECT number from t where id > 0;
++--connection try_mutex_lock_conn
++SET DEBUG_SYNC='before_query_cache_mutex SIGNAL try_lock_mutex';
++send_eval $try_lock_mutex_query;
 +
 +--connection default
-+--replace_column 1 ### 3 ### 6 ### 9 ### 10 ### 11 ###
-+SHOW PROCESSLIST;
++SET DEBUG_SYNC='now WAIT_FOR try_lock_mutex';
++eval SELECT SQL_NO_CACHE state FROM INFORMATION_SCHEMA.PROCESSLIST WHERE info='$try_lock_mutex_query';
++SET DEBUG_SYNC='now SIGNAL unlock_mutex';
 +
-+--replace_column 1 ###
-+SELECT id, info, state FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY id;
++--connection mutex_locked_conn
++reap;
++--connection try_mutex_lock_conn
++reap;
 +
-+--disconnect conn
-+DROP TABLE t;
++--connection default
++--disconnect mutex_locked_conn
++--disconnect try_mutex_lock_conn
 +SET GLOBAL query_cache_size=0;
 --- a/mysql-test/r/mysqld--help-notwin.result
 +++ b/mysql-test/r/mysqld--help-notwin.result
  query-cache-type ON
  query-cache-wlock-invalidate FALSE
  query-prealloc-size 8192
+--- /dev/null
++++ b/mysql-test/r/percona_status_wait_query_cache_mutex.result
+@@ -0,0 +1,20 @@
++SET GLOBAL query_cache_size=1355776;
++flush query cache;
++flush query cache;
++reset query cache;
++flush status;
++SET DEBUG_SYNC='after_query_cache_mutex SIGNAL mutex_locked WAIT_FOR unlock_mutex';
++SELECT "mutex_locked_query" as action;
++SET DEBUG_SYNC='now WAIT_FOR mutex_locked';
++SET DEBUG_SYNC='before_query_cache_mutex SIGNAL try_lock_mutex';
++SELECT "try_lock_mutex_query" as action;
++SET DEBUG_SYNC='now WAIT_FOR try_lock_mutex';
++SELECT SQL_NO_CACHE state FROM INFORMATION_SCHEMA.PROCESSLIST WHERE info='SELECT "try_lock_mutex_query" as action';
++state
++Waiting on query cache mutex
++SET DEBUG_SYNC='now SIGNAL unlock_mutex';
++action
++mutex_locked_query
++action
++try_lock_mutex_query
++SET GLOBAL query_cache_size=0;
index 76e6c5677dcf272854a372b3e9e3e41ca1ee0ded..128dd0dd62e4bc28caa2b6b903077a7f7342a497 100644 (file)
 + 131072.000000        0             0.000000
 + 262144.000000        0             0.000000
 + 524288.000000        0             0.000000
-+ 1048576.00000        0             0.000000
-+ 2097152.00000        0             0.000000
-+ 4194304.00000        0             0.000000
-+ 8388608.00000        0             0.000000
++1048576.000000        0             0.000000
++2097152.000000        0             0.000000
++4194304.000000        0             0.000000
++8388608.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 + 131072.000000        0             0.000000
 + 262144.000000        0             0.000000
 + 524288.000000        0             0.000000
-+ 1048576.00000        0             0.000000
-+ 2097152.00000        0             0.000000
-+ 4194304.00000        0             0.000000
-+ 8388608.00000        0             0.000000
++1048576.000000        0             0.000000
++2097152.000000        0             0.000000
++4194304.000000        0             0.000000
++8388608.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default;
 +SET GLOBAL QUERY_RESPONSE_TIME_STATS=default;
 + 131072.000000        0             0.000000
 + 262144.000000        0             0.000000
 + 524288.000000        0             0.000000
-+ 1048576.00000        0             0.000000
-+ 2097152.00000        0             0.000000
-+ 4194304.00000        0             0.000000
-+ 8388608.00000        0             0.000000
++1048576.000000        0             0.000000
++2097152.000000        0             0.000000
++4194304.000000        0             0.000000
++8388608.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 + 131072.000000        0             0.000000
 + 262144.000000        0             0.000000
 + 524288.000000        0             0.000000
-+ 1048576.00000        0             0.000000
-+ 2097152.00000        0             0.000000
-+ 4194304.00000        0             0.000000
-+ 8388608.00000        0             0.000000
++1048576.000000        0             0.000000
++2097152.000000        0             0.000000
++4194304.000000        0             0.000000
++8388608.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default;
 +SET GLOBAL QUERY_RESPONSE_TIME_STATS=default;
 +   1000.000000        0             0.000000
 +  10000.000000        0             0.000000
 + 100000.000000        0             0.000000
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +   1000.000000        0             0.000000
 +  10000.000000        0             0.000000
 + 100000.000000        0             0.000000
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default;
 +SET GLOBAL QUERY_RESPONSE_TIME_STATS=default;
 +  16807.000000        0             0.000000
 + 117649.000000        0             0.000000
 + 823543.000000        0             0.000000
-+ 5764801.00000        0             0.000000
++5764801.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +  16807.000000        0             0.000000
 + 117649.000000        0             0.000000
 + 823543.000000        0             0.000000
-+ 5764801.00000        0             0.000000
++5764801.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default;
 +SET GLOBAL QUERY_RESPONSE_TIME_STATS=default;
 +      1.000000        34           12.250000
 +    156.000000        33           77.099997
 +  24336.000000        0             0.000000
-+ 3796416.00000        0             0.000000
++3796416.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +      1.000000        34           12.250000
 +    156.000000        33           77.099997
 +  24336.000000        0             0.000000
-+ 3796416.00000        0             0.000000
++3796416.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default;
 +SET GLOBAL QUERY_RESPONSE_TIME_STATS=default;
 +      0.001000        0             0.000000
 +      1.000000        34           12.250000
 +   1000.000000        33           77.099997
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +      0.001000        0             0.000000
 +      1.000000        34           12.250000
 +   1000.000000        33           77.099997
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default;
 +SET GLOBAL QUERY_RESPONSE_TIME_STATS=default;
 +      0.001000        0             0.000000
 +      1.000000        34           12.250000
 +   1000.000000        33           77.099997
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +      0.001000        0             0.000000
 +      1.000000        34           12.250000
 +   1000.000000        33           77.099997
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default;
 +SET GLOBAL QUERY_RESPONSE_TIME_STATS=default;
 + 131072.000000        0             0.000000
 + 262144.000000        0             0.000000
 + 524288.000000        0             0.000000
-+ 1048576.00000        0             0.000000
-+ 2097152.00000        0             0.000000
-+ 4194304.00000        0             0.000000
-+ 8388608.00000        0             0.000000
++1048576.000000        0             0.000000
++2097152.000000        0             0.000000
++4194304.000000        0             0.000000
++8388608.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 + 131072.000000        0             0.000000
 + 262144.000000        0             0.000000
 + 524288.000000        0             0.000000
-+ 1048576.00000        0             0.000000
-+ 2097152.00000        0             0.000000
-+ 4194304.00000        0             0.000000
-+ 8388608.00000        0             0.000000
++1048576.000000        0             0.000000
++2097152.000000        0             0.000000
++4194304.000000        0             0.000000
++8388608.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
 +SET SESSION query_exec_time=0.31;
 + 131072.000000        0             0.000000
 + 262144.000000        0             0.000000
 + 524288.000000        0             0.000000
-+ 1048576.00000        0             0.000000
-+ 2097152.00000        0             0.000000
-+ 4194304.00000        0             0.000000
-+ 8388608.00000        0             0.000000
++1048576.000000        0             0.000000
++2097152.000000        0             0.000000
++4194304.000000        0             0.000000
++8388608.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 + 131072.000000        0             0.000000
 + 262144.000000        0             0.000000
 + 524288.000000        0             0.000000
-+ 1048576.00000        0             0.000000
-+ 2097152.00000        0             0.000000
-+ 4194304.00000        0             0.000000
-+ 8388608.00000        0             0.000000
++1048576.000000        0             0.000000
++2097152.000000        0             0.000000
++4194304.000000        0             0.000000
++8388608.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET SESSION query_exec_time=default;
 +SET SESSION query_exec_time=0.1;
 + 131072.000000        0             0.000000
 + 262144.000000        0             0.000000
 + 524288.000000        0             0.000000
-+ 1048576.00000        0             0.000000
-+ 2097152.00000        0             0.000000
-+ 4194304.00000        0             0.000000
-+ 8388608.00000        0             0.000000
++1048576.000000        0             0.000000
++2097152.000000        0             0.000000
++4194304.000000        0             0.000000
++8388608.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 + 131072.000000        0             0.000000
 + 262144.000000        0             0.000000
 + 524288.000000        0             0.000000
-+ 1048576.00000        0             0.000000
-+ 2097152.00000        0             0.000000
-+ 4194304.00000        0             0.000000
-+ 8388608.00000        0             0.000000
++1048576.000000        0             0.000000
++2097152.000000        0             0.000000
++4194304.000000        0             0.000000
++8388608.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
 +SET SESSION query_exec_time=0.31;
 + 131072.000000        0             0.000000
 + 262144.000000        0             0.000000
 + 524288.000000        0             0.000000
-+ 1048576.00000        0             0.000000
-+ 2097152.00000        0             0.000000
-+ 4194304.00000        0             0.000000
-+ 8388608.00000        0             0.000000
++1048576.000000        0             0.000000
++2097152.000000        0             0.000000
++4194304.000000        0             0.000000
++8388608.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 + 131072.000000        0             0.000000
 + 262144.000000        0             0.000000
 + 524288.000000        0             0.000000
-+ 1048576.00000        0             0.000000
-+ 2097152.00000        0             0.000000
-+ 4194304.00000        0             0.000000
-+ 8388608.00000        0             0.000000
++1048576.000000        0             0.000000
++2097152.000000        0             0.000000
++4194304.000000        0             0.000000
++8388608.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET SESSION query_exec_time=default;
 +SET SESSION query_exec_time=0.1;
 +   1000.000000        0             0.000000
 +  10000.000000        0             0.000000
 + 100000.000000        0             0.000000
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +   1000.000000        0             0.000000
 +  10000.000000        0             0.000000
 + 100000.000000        0             0.000000
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
 +SET SESSION query_exec_time=0.31;
 +   1000.000000        0             0.000000
 +  10000.000000        0             0.000000
 + 100000.000000        0             0.000000
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +   1000.000000        0             0.000000
 +  10000.000000        0             0.000000
 + 100000.000000        0             0.000000
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET SESSION query_exec_time=default;
 +SET SESSION query_exec_time=0.1;
 +  16807.000000        0             0.000000
 + 117649.000000        0             0.000000
 + 823543.000000        0             0.000000
-+ 5764801.00000        0             0.000000
++5764801.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +  16807.000000        0             0.000000
 + 117649.000000        0             0.000000
 + 823543.000000        0             0.000000
-+ 5764801.00000        0             0.000000
++5764801.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
 +SET SESSION query_exec_time=0.31;
 +  16807.000000        0             0.000000
 + 117649.000000        0             0.000000
 + 823543.000000        0             0.000000
-+ 5764801.00000        0             0.000000
++5764801.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +  16807.000000        0             0.000000
 + 117649.000000        0             0.000000
 + 823543.000000        0             0.000000
-+ 5764801.00000        0             0.000000
++5764801.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET SESSION query_exec_time=default;
 +SET SESSION query_exec_time=0.1;
 +      1.000000        0             0.000000
 +    156.000000        0             0.000000
 +  24336.000000        0             0.000000
-+ 3796416.00000        0             0.000000
++3796416.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +      1.000000        0             0.000000
 +    156.000000        0             0.000000
 +  24336.000000        0             0.000000
-+ 3796416.00000        0             0.000000
++3796416.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
 +SET SESSION query_exec_time=0.31;
 +      1.000000        11            4.050000
 +    156.000000        11           25.699999
 +  24336.000000        0             0.000000
-+ 3796416.00000        0             0.000000
++3796416.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +      1.000000        11            4.050000
 +    156.000000        11           25.699999
 +  24336.000000        0             0.000000
-+ 3796416.00000        0             0.000000
++3796416.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET SESSION query_exec_time=default;
 +SET SESSION query_exec_time=0.1;
 +      0.001000        0             0.000000
 +      1.000000        0             0.000000
 +   1000.000000        0             0.000000
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +      0.001000        0             0.000000
 +      1.000000        0             0.000000
 +   1000.000000        0             0.000000
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
 +SET SESSION query_exec_time=0.31;
 +      0.001000        0             0.000000
 +      1.000000        11            4.050000
 +   1000.000000        11           25.699999
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +      0.001000        0             0.000000
 +      1.000000        11            4.050000
 +   1000.000000        11           25.699999
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET SESSION query_exec_time=default;
 +SET SESSION query_exec_time=0.1;
 +      0.001000        0             0.000000
 +      1.000000        0             0.000000
 +   1000.000000        0             0.000000
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +      0.001000        0             0.000000
 +      1.000000        0             0.000000
 +   1000.000000        0             0.000000
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET GLOBAL QUERY_RESPONSE_TIME_STATS=1;
 +SET SESSION query_exec_time=0.31;
 +      0.001000        0             0.000000
 +      1.000000        11            4.050000
 +   1000.000000        11           25.699999
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +      0.001000        0             0.000000
 +      1.000000        11            4.050000
 +   1000.000000        11           25.699999
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET SESSION query_exec_time=default;
 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default;
 + 131072.000000        0             0.000000
 + 262144.000000        0             0.000000
 + 524288.000000        0             0.000000
-+ 1048576.00000        0             0.000000
-+ 2097152.00000        0             0.000000
-+ 4194304.00000        0             0.000000
-+ 8388608.00000        0             0.000000
++1048576.000000        0             0.000000
++2097152.000000        0             0.000000
++4194304.000000        0             0.000000
++8388608.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 + 131072.000000        0             0.000000
 + 262144.000000        0             0.000000
 + 524288.000000        0             0.000000
-+ 1048576.00000        0             0.000000
-+ 2097152.00000        0             0.000000
-+ 4194304.00000        0             0.000000
-+ 8388608.00000        0             0.000000
++1048576.000000        0             0.000000
++2097152.000000        0             0.000000
++4194304.000000        0             0.000000
++8388608.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET SESSION query_exec_time=default;
 +SET SESSION query_exec_time=0.1;
 + 131072.000000        0             0.000000
 + 262144.000000        0             0.000000
 + 524288.000000        0             0.000000
-+ 1048576.00000        0             0.000000
-+ 2097152.00000        0             0.000000
-+ 4194304.00000        0             0.000000
-+ 8388608.00000        0             0.000000
++1048576.000000        0             0.000000
++2097152.000000        0             0.000000
++4194304.000000        0             0.000000
++8388608.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 + 131072.000000        0             0.000000
 + 262144.000000        0             0.000000
 + 524288.000000        0             0.000000
-+ 1048576.00000        0             0.000000
-+ 2097152.00000        0             0.000000
-+ 4194304.00000        0             0.000000
-+ 8388608.00000        0             0.000000
++1048576.000000        0             0.000000
++2097152.000000        0             0.000000
++4194304.000000        0             0.000000
++8388608.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET SESSION query_exec_time=default;
 +SET SESSION query_exec_time=0.1;
 +   1000.000000        0             0.000000
 +  10000.000000        0             0.000000
 + 100000.000000        0             0.000000
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +   1000.000000        0             0.000000
 +  10000.000000        0             0.000000
 + 100000.000000        0             0.000000
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET SESSION query_exec_time=default;
 +SET SESSION query_exec_time=0.1;
 +  16807.000000        0             0.000000
 + 117649.000000        0             0.000000
 + 823543.000000        0             0.000000
-+ 5764801.00000        0             0.000000
++5764801.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +  16807.000000        0             0.000000
 + 117649.000000        0             0.000000
 + 823543.000000        0             0.000000
-+ 5764801.00000        0             0.000000
++5764801.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET SESSION query_exec_time=default;
 +SET SESSION query_exec_time=0.1;
 +      1.000000        55            8.450000
 +    156.000000        11           25.699999
 +  24336.000000        0             0.000000
-+ 3796416.00000        0             0.000000
++3796416.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +      1.000000        55            8.450000
 +    156.000000        11           25.699999
 +  24336.000000        0             0.000000
-+ 3796416.00000        0             0.000000
++3796416.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET SESSION query_exec_time=default;
 +SET SESSION query_exec_time=0.1;
 +      0.001000        0             0.000000
 +      1.000000        55            8.450000
 +   1000.000000        11           25.699999
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +      0.001000        0             0.000000
 +      1.000000        55            8.450000
 +   1000.000000        11           25.699999
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET SESSION query_exec_time=default;
 +SET SESSION query_exec_time=0.1;
 +      0.001000        0             0.000000
 +      1.000000        55            8.450000
 +   1000.000000        11           25.699999
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SELECT * FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME;
 +time  count   total
 +      0.001000        0             0.000000
 +      1.000000        55            8.450000
 +   1000.000000        11           25.699999
-+ 1000000.00000        0             0.000000
++1000000.000000        0             0.000000
 +TOO LONG      0       TOO LONG
 +SET SESSION query_exec_time=default;
 +SET GLOBAL QUERY_RESPONSE_TIME_RANGE_BASE=default;
  extern bool in_bootstrap;
 --- /dev/null
 +++ b/sql/query_response_time.cc
-@@ -0,0 +1,310 @@
+@@ -0,0 +1,302 @@
 +#include "mysql_version.h"
 +#include "my_global.h"
 +#ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
 +#define MAXIMUM_BASE QRT_MAXIMUM_BASE
 +#define POSITIVE_POWER_FILLER QRT_POSITIVE_POWER_FILLER
 +#define NEGATIVE_POWER_FILLER QRT_NEGATIVE_POWER_FILLER
-+#define STRING_OVERFLOW QRT_STRING_OVERFLOW
 +#define TIME_OVERFLOW   QRT_TIME_OVERFLOW
 +#define DEFAULT_BASE    QRT_DEFAULT_BASE
 +
 +  ulonglong m_bound[OVERALL_POWER_COUNT];
 +};
 +
-+void print_time(char* buffer, std::size_t buffer_size, std::size_t string_positive_power_length, const char* format, uint64 value)
++static
++void print_time(char* buffer, std::size_t buffer_size, const char* format,
++                uint64 value)
 +{
-+  memset(buffer,'X',buffer_size);
-+  buffer[string_positive_power_length]= '.';
 +  ulonglong second=      (value / MILLION);
 +  ulonglong microsecond= (value % MILLION);
-+  std::size_t result_length= snprintf(buffer,buffer_size,format,second,microsecond);
-+  if(result_length < 0)
-+  {
-+    assert(sizeof(STRING_OVERFLOW) <= buffer_size);
-+    memcpy(buffer, STRING_OVERFLOW, sizeof(STRING_OVERFLOW));
-+    return;
-+  }
-+  buffer[result_length]= 0;
++  my_snprintf(buffer, buffer_size, format, second, microsecond);
 +}
 +
 +class time_collector
 +  uint32 count(uint index) const
 +  {
 +    my_atomic_rwlock_rdlock(&time_collector_lock);
-+    uint32 result= my_atomic_load32((volatile int32*)&m_count[index]);
++    uint32 result= my_atomic_load32((int32*)&m_count[index]);
 +    my_atomic_rwlock_rdunlock(&time_collector_lock);
 +    return result;
 +  }
 +  uint64 total(uint index) const
 +  {
 +    my_atomic_rwlock_rdlock(&time_collector_lock);
-+    uint64 result= my_atomic_load64((volatile int64*)&m_total[index]);
++    uint64 result= my_atomic_load64((int64*)&m_total[index]);
 +    my_atomic_rwlock_rdunlock(&time_collector_lock);
 +    return result;
 +  }
 +      if(m_utility->bound(i) > time)
 +      {
 +        my_atomic_rwlock_wrlock(&time_collector_lock);
-+        my_atomic_add32((volatile int32*)(&m_count[i]), 1);
-+        my_atomic_add64((volatile int64*)(&m_total[i]), time);
++        my_atomic_add32((int32*)(&m_count[i]), 1);
++        my_atomic_add64((int64*)(&m_total[i]), time);
 +        my_atomic_rwlock_wrunlock(&time_collector_lock);
 +        break;
 +      }
 +  used on architectures that do not have atomic implementation of atomic
 +  operations. */
 +  my_atomic_rwlock_t time_collector_lock;
-+  volatile uint32   m_count[OVERALL_POWER_COUNT + 1];
-+  volatile uint64   m_total[OVERALL_POWER_COUNT + 1];
++  uint32   m_count[OVERALL_POWER_COUNT + 1];
++  uint64   m_total[OVERALL_POWER_COUNT + 1];
 +};
 +
 +class collector
 +      }
 +      else
 +      {
-+        print_time(time,sizeof(time),TIME_STRING_POSITIVE_POWER_LENGTH,TIME_STRING_FORMAT,this->bound(i));
-+        print_time(total,sizeof(total),TOTAL_STRING_POSITIVE_POWER_LENGTH,TOTAL_STRING_FORMAT,this->total(i));
++        print_time(time, sizeof(time), TIME_STRING_FORMAT, this->bound(i));
++        print_time(total, sizeof(total), TOTAL_STRING_FORMAT, this->total(i));
 +      }
 +      fields[0]->store(time,strlen(time),system_charset_info);
 +      fields[1]->store(this->count(i));
 +#endif // HAVE_RESPONSE_TIME_DISTRIBUTION
 --- /dev/null
 +++ b/sql/query_response_time.h
-@@ -0,0 +1,71 @@
+@@ -0,0 +1,64 @@
 +#ifndef QUERY_RESPONSE_TIME_H
 +#define QUERY_RESPONSE_TIME_H
 +
 +  and number 7234 result is:
 +  '   7234'
 +*/
-+#define QRT_POSITIVE_POWER_FILLER " "
++#define QRT_POSITIVE_POWER_FILLER ""
 +/*
 +  Filler for fractional number. Similiary to whole number
 +*/
 +#define QRT_NEGATIVE_POWER_FILLER "0"
 +
 +/*
-+  Message if string overflow (string overflow - internal error, this string say about bug in QRT)
-+*/
-+#define QRT_STRING_OVERFLOW "TOO BIG STRING"
-+
-+/*
 +  Message if time too big for statistic collecting (very long query)
 +*/
 +#define QRT_TIME_OVERFLOW "TOO LONG"
 +
 +#define QRT_TIME_STRING_LENGTH                                \
 +  max( (QRT_TIME_STRING_POSITIVE_POWER_LENGTH + 1 /* '.' */ + 6 /*QRT_TIME_STRING_NEGATIVE_POWER_LENGTH*/), \
-+       max( (sizeof(QRT_TIME_OVERFLOW) - 1),          \
-+          (sizeof(QRT_STRING_OVERFLOW) - 1) ) )
++       (sizeof(QRT_TIME_OVERFLOW) - 1) )
 +
 +#define QRT_TOTAL_STRING_LENGTH                               \
 +  max( (QRT_TOTAL_STRING_POSITIVE_POWER_LENGTH + 1 /* '.' */ + 6 /*QRT_TOTAL_STRING_NEGATIVE_POWER_LENGTH*/), \
-+       max( (sizeof(QRT_TIME_OVERFLOW) - 1),          \
-+          (sizeof(QRT_STRING_OVERFLOW) - 1) ) )
++       (sizeof(QRT_TIME_OVERFLOW) - 1) )
 +
 +extern ST_SCHEMA_TABLE query_response_time_table;
 +
 +have_response_time_distribution       YES
 --- a/include/atomic/x86-gcc.h
 +++ b/include/atomic/x86-gcc.h
-@@ -108,27 +108,22 @@
+@@ -108,27 +108,23 @@
    v=tmp;
  
  /*
 -                : "c" (&set), "m" (*a)                            \
 -                : "memory", "esp")
 +#define make_atomic_cas_body64                                     \
-+  asm ("movl %%edi, -4(%%esp);"                                    \
-+       "leal %0, %%edi;"                                           \
-+       "xchgl %%ebx, %%esi;"                                       \
-+       LOCK_prefix "; cmpxchg8b (%%edi);"                          \
-+       "movl %%esi, %%ebx;"                                        \
-+       "movl -4(%%esp), %%edi;"                                    \
-+       "setz %1;"                                                  \
-+       : "+m" (*a), "=q" (ret), "+A" (*cmp)                        \
-+       : "S" ((int32)(set & 0xFFFFFFFF)), "c" ((int32)(set >> 32)) \
-+       : "flags")
++  asm volatile ("movl %%edi, -4(%%esp);"                           \
++                "leal %0, %%edi;"                                  \
++                "xchgl %%ebx, %%esi;"                              \
++                LOCK_prefix "; cmpxchg8b (%%edi);"                 \
++                "movl %%esi, %%ebx;"                               \
++                "movl -4(%%esp), %%edi;"                           \
++                "setz %1;"                                         \
++                : "+m" (*a), "=q" (ret), "+A" (*cmp)               \
++                : "S" ((int32)(set & 0xFFFFFFFF)),                 \
++                  "c" ((int32)(set >> 32))                         \
++                : "memory", "flags")
  #endif
  
  /*
index f1cbd37b2dd4aeaf2a3373ffa0542dba0ef5829b..7f6a106b8929479dee816a420291d5f917f052d8 100644 (file)
      }
      else
      {
-@@ -1239,8 +1255,20 @@
-       query_length= command_name[thd->command].length;
+@@ -1240,7 +1256,7 @@
      }
  
-+    if (!query_length)
-+    {
-+      thd->sent_row_count= thd->examined_row_count= 0;
-+      thd->sent_row_count= 0;
-+      thd->bytes_sent_old= thd->status_var.bytes_sent;
-+      thd->tmp_tables_used= thd->tmp_tables_disk_used= 0;
-+      thd->tmp_tables_size= 0;
-+      thd->innodb_was_used= FALSE;
-+      thd->query_plan_flags= QPLAN_NONE;
-+      thd->query_plan_fsort_passes= 0;
-+    }
-+
      for (current_handler= slow_log_handler_list; *current_handler ;)
 -      error= (*current_handler++)->log_slow(thd, current_time, thd->start_time,
 +      error= (*current_handler++)->log_slow(thd, current_utime, thd->start_time,
                                              user_host_buff, user_host_len,
                                              query_utime, lock_utime, is_command,
                                              query, query_length) || error;
-@@ -2656,12 +2684,13 @@
+@@ -2656,12 +2672,13 @@
      TRUE - error occured
  */
  
    bool error= 0;
    DBUG_ENTER("MYSQL_QUERY_LOG::write");
  
-@@ -2683,17 +2712,28 @@
+@@ -2683,17 +2700,28 @@
  
      if (!(specialflag & SPECIAL_SHORT_LOG_FORMAT))
      {
  
          /* Note that my_b_write() assumes it knows the length for this */
          if (my_b_write(&log_file, (uchar*) buff, buff_len))
-@@ -2711,12 +2751,69 @@
+@@ -2710,13 +2738,71 @@
+     /* For slow query log */
      sprintf(query_time_buff, "%.6f", ulonglong2double(query_utime)/1000000.0);
      sprintf(lock_time_buff,  "%.6f", ulonglong2double(lock_utime)/1000000.0);
++    DBUG_PRINT("info", ("Last_errno: %u", thd->last_errno));
      if (my_b_printf(&log_file,
 -                    "# Query_time: %s  Lock_time: %s"
 -                    " Rows_sent: %lu  Rows_examined: %lu\n",
  
 +extern "C"
 +void increment_thd_innodb_stats(THD* thd,
-+                    unsigned long long trx_id,
-+                    long io_reads,
-+                    long long  io_read,
-+                    long      io_reads_wait_timer,
-+                    long      lock_que_wait_timer,
-+                    long      que_wait_timer,
-+                    long      page_access)
++                                unsigned long long trx_id,
++                                long io_reads,
++                                long long  io_read,
++                                long      io_reads_wait_timer,
++                                long      lock_que_wait_timer,
++                                long      que_wait_timer,
++                                long      page_access)
 +{
-+  thd->innodb_was_used = TRUE;
-+  thd->innodb_trx_id = trx_id;
-+  thd->innodb_io_reads += io_reads;
-+  thd->innodb_io_read += io_read;
-+  thd->innodb_io_reads_wait_timer += io_reads_wait_timer;
-+  thd->innodb_lock_que_wait_timer += lock_que_wait_timer;
-+  thd->innodb_innodb_que_wait_timer += que_wait_timer;
-+  thd->innodb_page_access += page_access;
++  thd->innodb_was_used=               TRUE;
++  thd->innodb_trx_id=                 trx_id;
++  thd->innodb_io_reads+=              io_reads;
++  thd->innodb_io_read+=               io_read;
++  thd->innodb_io_reads_wait_timer+=   io_reads_wait_timer;
++  thd->innodb_lock_que_wait_timer+=   lock_que_wait_timer;
++  thd->innodb_innodb_que_wait_timer+= que_wait_timer;
++  thd->innodb_page_access+=           page_access;
 +}
 +
 +extern "C"
  
  /**
    Dumps a text description of a thread, its security context
-@@ -926,6 +957,8 @@
+@@ -942,6 +973,8 @@
                             const char* msg,
                             MYSQL_ERROR ** cond_hdl)
  {
    if (!m_internal_handler)
    {
      *cond_hdl= NULL;
-@@ -3675,6 +3708,12 @@
+@@ -1236,6 +1269,8 @@
+   /* Initialize the Debug Sync Facility. See debug_sync.cc. */
+   debug_sync_init_thread(this);
+ #endif /* defined(ENABLED_DEBUG_SYNC) */
++
++  clear_slow_extended();
+ }
+@@ -3682,8 +3717,6 @@
+   backup->in_sub_stmt=     in_sub_stmt;
+   backup->enable_slow_log= enable_slow_log;
+   backup->limit_found_rows= limit_found_rows;
+-  backup->examined_row_count= examined_row_count;
+-  backup->sent_row_count=   sent_row_count;
+   backup->cuted_fields=     cuted_fields;
+   backup->client_capabilities= client_capabilities;
+   backup->savepoints= transaction.savepoints;
+@@ -3691,6 +3724,7 @@
      first_successful_insert_id_in_prev_stmt;
    backup->first_successful_insert_id_in_cur_stmt= 
      first_successful_insert_id_in_cur_stmt;
-+  backup->innodb_io_reads= innodb_io_reads;
-+  backup->innodb_io_read= innodb_io_read;
-+  backup->innodb_io_reads_wait_timer= innodb_io_reads_wait_timer;
-+  backup->innodb_lock_que_wait_timer= innodb_lock_que_wait_timer;
-+  backup->innodb_innodb_que_wait_timer= innodb_innodb_que_wait_timer;
-+  backup->innodb_page_access= innodb_page_access;
++  reset_sub_statement_state_slow_extended(backup);
  
    if ((!lex->requires_prelocking() || is_update_query(lex->sql_command)) &&
        !is_current_stmt_binlog_format_row())
-@@ -3695,6 +3734,14 @@
+@@ -3706,13 +3740,74 @@
+   /* Disable result sets */
+   client_capabilities &= ~CLIENT_MULTI_RESULTS;
+   in_sub_stmt|= new_state;
+-  examined_row_count= 0;
+-  sent_row_count= 0;
    cuted_fields= 0;
    transaction.savepoints= 0;
    first_successful_insert_id_in_cur_stmt= 0;
-+  last_errno= 0;
-+  innodb_trx_id= 0;
-+  innodb_io_reads= 0;
-+  innodb_io_read= 0;
-+  innodb_io_reads_wait_timer= 0;
-+  innodb_lock_que_wait_timer= 0;
-+  innodb_innodb_que_wait_timer= 0;
-+  innodb_page_access= 0;
  }
  
++void THD::clear_slow_extended()
++{
++  DBUG_ENTER("THD::clear_slow_extended");
++  sent_row_count=               0;
++  examined_row_count=           0;
++  bytes_sent_old=               status_var.bytes_sent;
++  tmp_tables_used=              0;
++  tmp_tables_disk_used=         0;
++  tmp_tables_size=              0;
++  innodb_was_used=              FALSE;
++  innodb_trx_id=                0;
++  innodb_io_reads=              0;
++  innodb_io_read=               0;
++  innodb_io_reads_wait_timer=   0;
++  innodb_lock_que_wait_timer=   0;
++  innodb_innodb_que_wait_timer= 0;
++  innodb_page_access=           0;
++  query_plan_flags=             QPLAN_NONE;
++  query_plan_fsort_passes=      0;
++  last_errno=                   0;
++  DBUG_VOID_RETURN;
++}
++
++void THD::reset_sub_statement_state_slow_extended(Sub_statement_state *backup)
++{
++  DBUG_ENTER("THD::reset_sub_statement_state_slow_extended");
++  backup->sent_row_count=               sent_row_count;
++  backup->examined_row_count=           examined_row_count;
++  backup->tmp_tables_used=              tmp_tables_used;
++  backup->tmp_tables_disk_used=         tmp_tables_disk_used;
++  backup->tmp_tables_size=              tmp_tables_size;
++  backup->innodb_was_used=              innodb_was_used;
++  backup->innodb_io_reads=              innodb_io_reads;
++  backup->innodb_io_read=               innodb_io_read;
++  backup->innodb_io_reads_wait_timer=   innodb_io_reads_wait_timer;
++  backup->innodb_lock_que_wait_timer=   innodb_lock_que_wait_timer;
++  backup->innodb_innodb_que_wait_timer= innodb_innodb_que_wait_timer;
++  backup->innodb_page_access=           innodb_page_access;
++  backup->query_plan_flags=             query_plan_flags;
++  backup->query_plan_fsort_passes=      query_plan_fsort_passes;
++  clear_slow_extended();
++  DBUG_VOID_RETURN;
++}
++
++void THD::restore_sub_statement_state_slow_extended(const Sub_statement_state *backup)
++{
++  DBUG_ENTER("THD::restore_sub_statement_state_slow_extended");
++  sent_row_count=                backup->sent_row_count;
++  examined_row_count+=           backup->examined_row_count;
++  tmp_tables_used+=              backup->tmp_tables_used;
++  tmp_tables_disk_used+=         backup->tmp_tables_disk_used;
++  tmp_tables_size+=              backup->tmp_tables_size;
++  innodb_was_used=               (innodb_was_used || backup->innodb_was_used);
++  innodb_io_reads+=              backup->innodb_io_reads;
++  innodb_io_read+=               backup->innodb_io_read;
++  innodb_io_reads_wait_timer+=   backup->innodb_io_reads_wait_timer;
++  innodb_lock_que_wait_timer+=   backup->innodb_lock_que_wait_timer;
++  innodb_innodb_que_wait_timer+= backup->innodb_innodb_que_wait_timer;
++  innodb_page_access+=           backup->innodb_page_access;
++  query_plan_flags|=             backup->query_plan_flags;
++  query_plan_fsort_passes+=      backup->query_plan_fsort_passes;
++  DBUG_VOID_RETURN;
++}
  
-@@ -3757,6 +3804,12 @@
+ void THD::restore_sub_statement_state(Sub_statement_state *backup)
+ {
+@@ -3753,7 +3848,6 @@
+   first_successful_insert_id_in_cur_stmt= 
+     backup->first_successful_insert_id_in_cur_stmt;
+   limit_found_rows= backup->limit_found_rows;
+-  sent_row_count=   backup->sent_row_count;
+   client_capabilities= backup->client_capabilities;
+   /*
+     If we've left sub-statement mode, reset the fatal error flag.
+@@ -3771,8 +3865,8 @@
+     The following is added to the old values as we are interested in the
+     total complexity of the query
    */
-   examined_row_count+= backup->examined_row_count;
+-  examined_row_count+= backup->examined_row_count;
    cuted_fields+=       backup->cuted_fields;
-+  innodb_io_reads+= backup->innodb_io_reads;
-+  innodb_io_read+= backup->innodb_io_read;
-+  innodb_io_reads_wait_timer+= backup->innodb_io_reads_wait_timer;
-+  innodb_lock_que_wait_timer+= backup->innodb_lock_que_wait_timer;
-+  innodb_innodb_que_wait_timer+= backup->innodb_innodb_que_wait_timer;
-+  innodb_page_access+= backup->innodb_page_access;
++  restore_sub_statement_state_slow_extended(backup);
    DBUG_VOID_RETURN;
  }
  
    double long_query_time_double;
  
  } SV;
-@@ -1140,6 +1182,14 @@
+@@ -1140,6 +1182,24 @@
    uint in_sub_stmt;
    bool enable_slow_log;
    bool last_insert_id_used;
 +
++  /*** Following variables used in slow_extended.patch ***/
++  ulong      tmp_tables_used;
++  ulong      tmp_tables_disk_used;
++  ulonglong  tmp_tables_size;
++
++  bool       innodb_was_used;
 +  ulong      innodb_io_reads;
 +  ulonglong  innodb_io_read;
 +  ulong      innodb_io_reads_wait_timer;
 +  ulong      innodb_lock_que_wait_timer;
 +  ulong      innodb_innodb_que_wait_timer;
 +  ulong      innodb_page_access;
++
++  ulong      query_plan_flags;
++  ulong      query_plan_fsort_passes;
++  /*** The variables above used in slow_extended.patch ***/
 +
    SAVEPOINT *savepoints;
    enum enum_check_fields count_cuted_fields;
  };
-@@ -1588,6 +1638,26 @@
+@@ -1588,6 +1648,71 @@
    thr_lock_type update_lock_default;
    Delayed_insert *di;
  
++  /*** Following variables used in slow_extended.patch ***/
++  /*
++    Variable write_to_slow_log:
++     1) initialized in
++       * sql_connect.cc (log_slow_rate_limit support)
++       * slave.cc       (log_slow_slave_statements support)
++     2) The variable is initialized on the thread startup and remains
++        constant afterwards.  This will change when 
++        LP #712396 ("log_slow_slave_statements not work on replication 
++        threads without RESTART") is implemented.
++     3) An implementation of LP #688646 ("Make query sampling possible by query") should use it.
++  */
 +  bool       write_to_slow_log;
-+
++  /*
++    Variable bytes_send_old saves value of thd->status_var.bytes_sent
++    before query execution.
++  */
 +  ulonglong  bytes_sent_old;
++  /*
++    Variables tmp_tables_*** collect statistics about usage of temporary tables
++  */
 +  ulong      tmp_tables_used;
 +  ulong      tmp_tables_disk_used;
 +  ulonglong  tmp_tables_size;
++  /*
++    Variable innodb_was_used shows used or not InnoDB engine in current query.
++  */
 +  bool       innodb_was_used;
++  /*
++    Following Variables innodb_*** (is |should be) different from
++    default values only if (innodb_was_used==TRUE)
++  */
 +  ulonglong  innodb_trx_id;
 +  ulong      innodb_io_reads;
 +  ulonglong  innodb_io_read;
 +  ulong      innodb_innodb_que_wait_timer;
 +  ulong      innodb_page_access;
 +
++  /*
++    Variable query_plan_flags collects information about query plan entites
++    used on query execution.
++  */
 +  ulong      query_plan_flags;
++  /*
++    Variable query_plan_fsort_passes collects information about file sort passes
++    acquired during query execution.
++  */
 +  ulong      query_plan_fsort_passes;
-+
++  /*
++    Query can generate several errors/warnings during execution
++    (see THD::handle_condition comment in sql_class.h)
++    Variable last_errno contains the last error/warning acquired during
++    query execution.
++  */
 +  uint       last_errno;
++  /*** The variables above used in slow_extended.patch ***/
++
++  /*** Following methods used in slow_extended.patch ***/
++  void clear_slow_extended();
++  void reset_sub_statement_state_slow_extended(Sub_statement_state *backup);
++  void restore_sub_statement_state_slow_extended(const Sub_statement_state *backup);
++  /*** The methods above used in slow_extended.patch ***/
 +
    /* <> 0 if we are inside of trigger or stored function. */
    uint in_sub_stmt;
  
  const char *any_db="*any*";   // Special symbol for check_access
  
-@@ -1430,6 +1431,60 @@
+@@ -888,6 +889,7 @@
+     the slow log only if opt_log_slow_admin_statements is set.
+   */
+   thd->enable_slow_log= TRUE;
++  thd->clear_slow_extended();
+   thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */
+   thd->set_time();
+   if (!thd->is_valid_time())
+@@ -1430,6 +1432,60 @@
    DBUG_RETURN(error);
  }
  
  
  void log_slow_statement(THD *thd)
  {
-@@ -1443,13 +1498,48 @@
+@@ -1443,13 +1499,48 @@
    if (unlikely(thd->in_sub_stmt))
      DBUG_VOID_RETURN;                           // Don't set time for sub stmt
  
      thd_proc_info(thd, "logging slow query");
  
      if (((thd->server_status & SERVER_QUERY_WAS_SLOW) ||
-@@ -1879,6 +1969,9 @@
-     context.resolve_in_table_list_only(select_lex->
-                                        table_list.first);
-+  /* Reset the counter at all cases for the extended slow query log */
-+  thd->sent_row_count= 0;
-+
-   /*
-     Reset warning count for each query that uses tables
-     A better approach would be to reset this for any commands
-@@ -5303,6 +5396,21 @@
+@@ -5301,7 +5392,8 @@
+   thd->stmt_da->reset_diagnostics_area();
+   thd->warning_info->reset_for_next_command();
    thd->rand_used= 0;
-   thd->sent_row_count= thd->examined_row_count= 0;
-+  thd->bytes_sent_old= thd->status_var.bytes_sent;
-+  thd->tmp_tables_used= thd->tmp_tables_disk_used= 0;
-+  thd->tmp_tables_size= 0;
-+  thd->innodb_was_used= FALSE;
-+  thd->innodb_trx_id= 0;
-+  thd->innodb_io_reads= 0;
-+  thd->innodb_io_read= 0;
-+  thd->innodb_io_reads_wait_timer= 0;
-+  thd->innodb_lock_que_wait_timer= 0;
-+  thd->innodb_innodb_que_wait_timer= 0;
-+  thd->innodb_page_access= 0;
-+  thd->query_plan_flags= QPLAN_NONE;
-+  thd->query_plan_fsort_passes= 0;
-+  thd->last_errno= 0;
+-  thd->sent_row_count= thd->examined_row_count= 0;
 +
++  thd->clear_slow_extended();
    thd->reset_current_stmt_binlog_format_row();
    thd->binlog_unsafe_warning_flags= 0;
 --- a/sql/sql_select.cc
 +++ b/sql/sql_select.cc
 @@ -6902,7 +6902,10 @@
This page took 0.217095 seconds and 4 git commands to generate.