]> git.pld-linux.org Git - packages/mysql.git/blob - processlist_row_stats.patch
- up to 5.5.15
[packages/mysql.git] / processlist_row_stats.patch
1 # name       : processlist_row_stats.patch
2 # introduced : 11 or before
3 # maintainer : Oleg
4 #
5 #!!! notice !!!
6 # Any small change to this file in the main branch
7 # should be done or reviewed by the maintainer!
8 --- a/sql/sql_class.cc
9 +++ b/sql/sql_class.cc
10 @@ -2288,6 +2288,7 @@
11  
12    thd->sent_row_count++;
13    thd->sent_row_count_2++;
14 +  DEBUG_SYNC(thd, "sent_row");
15  
16    if (thd->vio_ok())
17      DBUG_RETURN(protocol->write());
18 --- a/sql/sql_show.cc
19 +++ b/sql/sql_show.cc
20 @@ -1766,7 +1766,8 @@
21  
22  /****************************************************************************
23    Return info about all processes
24 -  returns for each thread: thread id, user, host, db, command, info
25 +  returns for each thread: thread id, user, host, db, command, info,
26 +  rows_sent, rows_examined, rows_read
27  ****************************************************************************/
28  
29  class thread_info :public ilink {
30 @@ -1784,6 +1785,7 @@
31    uint   command;
32    const char *user,*host,*db,*proc_info,*state_info;
33    CSET_STRING query_string;
34 +  ulonglong rows_sent, rows_examined, rows_read;
35  };
36  
37  #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
38 @@ -1836,6 +1838,15 @@
39    field->maybe_null=1;
40    field_list.push_back(field=new Item_empty_string("Info",max_query_length));
41    field->maybe_null=1;
42 +  field_list.push_back(field= new Item_return_int("Rows_sent",
43 +                                                  MY_INT64_NUM_DECIMAL_DIGITS,
44 +                                                  MYSQL_TYPE_LONGLONG));
45 +  field_list.push_back(field= new Item_return_int("Rows_examined",
46 +                                                  MY_INT64_NUM_DECIMAL_DIGITS,
47 +                                                  MYSQL_TYPE_LONGLONG));
48 +  field_list.push_back(field= new Item_return_int("Rows_read",
49 +                                                  MY_INT64_NUM_DECIMAL_DIGITS,
50 +                                                  MYSQL_TYPE_LONGLONG));
51    if (protocol->send_result_set_metadata(&field_list,
52                              Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
53      DBUG_VOID_RETURN;
54 @@ -1889,6 +1900,9 @@
55            thd_info->query_string=
56              CSET_STRING(q, q ? length : 0, tmp->query_charset());
57          }
58 +        thd_info->rows_sent= tmp->sent_row_count;
59 +        thd_info->rows_examined= tmp->examined_row_count;
60 +        thd_info->rows_read= tmp->warning_info->current_row_for_warning();
61          mysql_mutex_unlock(&tmp->LOCK_thd_data);
62          thd_info->start_time= tmp->start_time;
63          thread_infos.append(thd_info);
64 @@ -1917,6 +1931,9 @@
65      protocol->store(thd_info->state_info, system_charset_info);
66      protocol->store(thd_info->query_string.str(),
67                      thd_info->query_string.charset());
68 +    protocol->store(thd_info->rows_sent);
69 +    protocol->store(thd_info->rows_examined);
70 +    protocol->store(thd_info->rows_read);
71      if (protocol->write())
72        break; /* purecov: inspected */
73    }
74 @@ -2027,6 +2044,15 @@
75        table->field[8]->store(((tmp->start_utime ?
76                                 now_utime - tmp->start_utime : 0)/ 1000));
77  
78 +      mysql_mutex_lock(&tmp->LOCK_thd_data);
79 +      /* ROWS_SENT */
80 +      table->field[9]->store((ulonglong) tmp->sent_row_count);
81 +      /* ROWS_EXAMINED */
82 +      table->field[10]->store((ulonglong) tmp->examined_row_count);
83 +      /* ROWS_READ */
84 +      table->field[11]->store((ulonglong) tmp->warning_info->current_row_for_warning());
85 +      mysql_mutex_unlock(&tmp->LOCK_thd_data);
86 +
87        if (schema_table_store_record(thd, table))
88        {
89          mysql_mutex_unlock(&LOCK_thread_count);
90 @@ -8117,6 +8143,12 @@
91     SKIP_OPEN_TABLE},
92    {"TIME_MS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG,
93     0, 0, "Time_ms", SKIP_OPEN_TABLE},
94 +  {"ROWS_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
95 +   MY_I_S_UNSIGNED, "Rows_sent", SKIP_OPEN_TABLE},
96 +  {"ROWS_EXAMINED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
97 +   MY_I_S_UNSIGNED, "Rows_examined", SKIP_OPEN_TABLE},
98 +  {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
99 +   MY_I_S_UNSIGNED, "Rows_read", SKIP_OPEN_TABLE},
100    {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
101  };
102  
This page took 0.117055 seconds and 4 git commands to generate.