]>
Commit | Line | Data |
---|---|---|
df1b5770 AM |
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 | diff -ruN a/sql/sql_class.cc b/sql/sql_class.cc | |
9 | --- a/sql/sql_class.cc 2011-03-09 17:07:26.221709282 +0200 | |
10 | +++ b/sql/sql_class.cc 2011-03-09 17:07:44.900164285 +0200 | |
11 | @@ -2022,6 +2022,7 @@ | |
12 | ||
13 | thd->sent_row_count++; | |
14 | thd->sent_row_count_2++; | |
15 | + DEBUG_SYNC(thd, "sent_row"); | |
16 | ||
17 | if (thd->vio_ok()) | |
18 | DBUG_RETURN(protocol->write()); | |
19 | diff -ruN a/sql/sql_show.cc b/sql/sql_show.cc | |
20 | --- a/sql/sql_show.cc 2011-03-09 17:07:26.251706801 +0200 | |
21 | +++ b/sql/sql_show.cc 2011-03-09 17:07:44.904163954 +0200 | |
22 | @@ -1759,7 +1759,8 @@ | |
23 | ||
24 | /**************************************************************************** | |
25 | Return info about all processes | |
26 | - returns for each thread: thread id, user, host, db, command, info | |
27 | + returns for each thread: thread id, user, host, db, command, info, | |
28 | + rows_sent, rows_examined, rows_read | |
29 | ****************************************************************************/ | |
30 | ||
31 | class thread_info :public ilink { | |
32 | @@ -1777,6 +1778,7 @@ | |
33 | uint command; | |
34 | const char *user,*host,*db,*proc_info,*state_info; | |
35 | CSET_STRING query_string; | |
36 | + ulonglong rows_sent, rows_examined, rows_read; | |
37 | }; | |
38 | ||
39 | #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION | |
40 | @@ -1829,6 +1831,15 @@ | |
41 | field->maybe_null=1; | |
42 | field_list.push_back(field=new Item_empty_string("Info",max_query_length)); | |
43 | field->maybe_null=1; | |
44 | + field_list.push_back(field= new Item_return_int("Rows_sent", | |
45 | + MY_INT64_NUM_DECIMAL_DIGITS, | |
46 | + MYSQL_TYPE_LONGLONG)); | |
47 | + field_list.push_back(field= new Item_return_int("Rows_examined", | |
48 | + MY_INT64_NUM_DECIMAL_DIGITS, | |
49 | + MYSQL_TYPE_LONGLONG)); | |
50 | + field_list.push_back(field= new Item_return_int("Rows_read", | |
51 | + MY_INT64_NUM_DECIMAL_DIGITS, | |
52 | + MYSQL_TYPE_LONGLONG)); | |
53 | if (protocol->send_result_set_metadata(&field_list, | |
54 | Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) | |
55 | DBUG_VOID_RETURN; | |
56 | @@ -1882,6 +1893,9 @@ | |
57 | thd_info->query_string= | |
58 | CSET_STRING(q, q ? length : 0, tmp->query_charset()); | |
59 | } | |
60 | + thd_info->rows_sent= tmp->sent_row_count; | |
61 | + thd_info->rows_examined= tmp->examined_row_count; | |
62 | + thd_info->rows_read= tmp->warning_info->current_row_for_warning(); | |
63 | mysql_mutex_unlock(&tmp->LOCK_thd_data); | |
64 | thd_info->start_time= tmp->start_time; | |
65 | thread_infos.append(thd_info); | |
66 | @@ -1910,6 +1924,9 @@ | |
67 | protocol->store(thd_info->state_info, system_charset_info); | |
68 | protocol->store(thd_info->query_string.str(), | |
69 | thd_info->query_string.charset()); | |
70 | + protocol->store(thd_info->rows_sent); | |
71 | + protocol->store(thd_info->rows_examined); | |
72 | + protocol->store(thd_info->rows_read); | |
73 | if (protocol->write()) | |
74 | break; /* purecov: inspected */ | |
75 | } | |
76 | @@ -2020,6 +2037,15 @@ | |
77 | table->field[8]->store(((tmp->start_utime ? | |
78 | now_utime - tmp->start_utime : 0)/ 1000)); | |
79 | ||
80 | + mysql_mutex_lock(&tmp->LOCK_thd_data); | |
81 | + /* ROWS_SENT */ | |
82 | + table->field[9]->store((ulonglong) tmp->sent_row_count); | |
83 | + /* ROWS_EXAMINED */ | |
84 | + table->field[10]->store((ulonglong) tmp->examined_row_count); | |
85 | + /* ROWS_READ */ | |
86 | + table->field[11]->store((ulonglong) tmp->warning_info->current_row_for_warning()); | |
87 | + mysql_mutex_unlock(&tmp->LOCK_thd_data); | |
88 | + | |
89 | if (schema_table_store_record(thd, table)) | |
90 | { | |
91 | mysql_mutex_unlock(&LOCK_thread_count); | |
92 | @@ -7941,6 +7967,12 @@ | |
93 | SKIP_OPEN_TABLE}, | |
94 | {"TIME_MS", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, | |
95 | 0, 0, "Time_ms", SKIP_OPEN_TABLE}, | |
96 | + {"ROWS_SENT", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, | |
97 | + MY_I_S_UNSIGNED, "Rows_sent", SKIP_OPEN_TABLE}, | |
98 | + {"ROWS_EXAMINED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, | |
99 | + MY_I_S_UNSIGNED, "Rows_examined", SKIP_OPEN_TABLE}, | |
100 | + {"ROWS_READ", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, | |
101 | + MY_I_S_UNSIGNED, "Rows_read", SKIP_OPEN_TABLE}, | |
102 | {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} | |
103 | }; | |
104 |