]> git.pld-linux.org Git - packages/mysql.git/blob - mysql-microsec_process.patch
- for 5.0.75
[packages/mysql.git] / mysql-microsec_process.patch
1 diff -r 327ce7a34c91 mysql-test/r/information_schema.result
2 --- a/mysql-test/r/information_schema.result    Fri Nov 07 15:44:23 2008 -0800
3 +++ b/mysql-test/r/information_schema.result    Fri Nov 07 15:52:53 2008 -0800
4 @@ -44,6 +44,7 @@
5  COLUMN_PRIVILEGES
6  INDEX_STATISTICS
7  KEY_COLUMN_USAGE
8 +PROCESSLIST
9  PROFILING
10  ROUTINES
11  SCHEMATA
12 @@ -740,7 +741,7 @@
13  CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1;
14  CREATE VIEW a2 AS SELECT t_CRASHME FROM a1;
15  count(*)
16 -106
17 +107
18  drop view a2, a1;
19  drop table t_crashme;
20  select table_schema,table_name, column_name from
21 @@ -749,6 +750,7 @@
22  table_schema   table_name      column_name
23  information_schema     COLUMNS COLUMN_DEFAULT
24  information_schema     COLUMNS COLUMN_TYPE
25 +information_schema     PROCESSLIST     INFO
26  information_schema     ROUTINES        ROUTINE_DEFINITION
27  information_schema     ROUTINES        SQL_MODE
28  information_schema     TRIGGERS        ACTION_CONDITION
29 @@ -813,7 +815,7 @@
30  flush privileges;
31  SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
32  table_schema   count(*)
33 -information_schema     21
34 +information_schema     22
35  mysql  17
36  create table t1 (i int, j int);
37  create trigger trg1 before insert on t1 for each row
38 @@ -1206,6 +1208,7 @@
39  COLUMN_PRIVILEGES      TABLE_SCHEMA
40  INDEX_STATISTICS       TABLE_SCHEMA
41  KEY_COLUMN_USAGE       CONSTRAINT_SCHEMA
42 +PROCESSLIST    ID
43  PROFILING      QUERY_ID
44  ROUTINES       ROUTINE_SCHEMA
45  SCHEMATA       SCHEMA_NAME
46 @@ -1242,6 +1245,7 @@
47  COLUMN_PRIVILEGES      TABLE_SCHEMA
48  INDEX_STATISTICS       TABLE_SCHEMA
49  KEY_COLUMN_USAGE       CONSTRAINT_SCHEMA
50 +PROCESSLIST    ID
51  PROFILING      QUERY_ID
52  ROUTINES       ROUTINE_SCHEMA
53  SCHEMATA       SCHEMA_NAME
54 @@ -1329,6 +1333,7 @@
55  COLUMN_PRIVILEGES      information_schema.COLUMN_PRIVILEGES    1
56  INDEX_STATISTICS       information_schema.INDEX_STATISTICS     1
57  KEY_COLUMN_USAGE       information_schema.KEY_COLUMN_USAGE     1
58 +PROCESSLIST    information_schema.PROCESSLIST  1
59  PROFILING      information_schema.PROFILING    1
60  ROUTINES       information_schema.ROUTINES     1
61  SCHEMATA       information_schema.SCHEMATA     1
62 diff -r 327ce7a34c91 mysql-test/r/information_schema_db.result
63 --- a/mysql-test/r/information_schema_db.result Fri Nov 07 15:44:23 2008 -0800
64 +++ b/mysql-test/r/information_schema_db.result Fri Nov 07 15:52:53 2008 -0800
65 @@ -13,6 +13,7 @@
66  COLUMN_PRIVILEGES
67  INDEX_STATISTICS
68  KEY_COLUMN_USAGE
69 +PROCESSLIST
70  PROFILING
71  ROUTINES
72  SCHEMATA
73 diff -r 327ce7a34c91 mysql-test/r/mysqlshow.result
74 --- a/mysql-test/r/mysqlshow.result     Fri Nov 07 15:44:23 2008 -0800
75 +++ b/mysql-test/r/mysqlshow.result     Fri Nov 07 15:52:53 2008 -0800
76 @@ -87,6 +87,7 @@
77  | COLUMN_PRIVILEGES                     |
78  | INDEX_STATISTICS                      |
79  | KEY_COLUMN_USAGE                      |
80 +| PROCESSLIST                           |
81  | PROFILING                             |
82  | ROUTINES                              |
83  | SCHEMATA                              |
84 @@ -113,6 +114,7 @@
85  | COLUMN_PRIVILEGES                     |
86  | INDEX_STATISTICS                      |
87  | KEY_COLUMN_USAGE                      |
88 +| PROCESSLIST                           |
89  | PROFILING                             |
90  | ROUTINES                              |
91  | SCHEMATA                              |
92 diff -r 327ce7a34c91 sql/mysql_priv.h
93 --- a/sql/mysql_priv.h  Fri Nov 07 15:44:23 2008 -0800
94 +++ b/sql/mysql_priv.h  Fri Nov 07 15:52:53 2008 -0800
95 @@ -244,6 +244,8 @@
96  
97  /* Characters shown for the command in 'show processlist' */
98  #define PROCESS_LIST_WIDTH 100
99 +/* Characters shown for the command in 'information_schema.processlist' */
100 +#define PROCESS_LIST_INFO_WIDTH 65535
101  
102  #define PRECISION_FOR_DOUBLE 53
103  #define PRECISION_FOR_FLOAT  24
104 diff -r 327ce7a34c91 sql/sql_show.cc
105 --- a/sql/sql_show.cc   Fri Nov 07 15:44:23 2008 -0800
106 +++ b/sql/sql_show.cc   Fri Nov 07 15:52:53 2008 -0800
107 @@ -1466,6 +1466,120 @@
108    }
109    send_eof(thd);
110    DBUG_VOID_RETURN;
111 +}
112 +
113 +int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
114 +{
115 +  TABLE *table= tables->table;
116 +  CHARSET_INFO *cs= system_charset_info;
117 +  char *user;
118 +  ulonglong current_timer= my_timer(&current_timer, frequency);
119 +  DBUG_ENTER("fill_process_list");
120 +
121 +  user= thd->security_ctx->master_access & PROCESS_ACL ?
122 +        NullS : thd->security_ctx->priv_user;
123 +
124 +  VOID(pthread_mutex_lock(&LOCK_thread_count));
125 +
126 +  if (!thd->killed)
127 +  {
128 +    I_List_iterator<THD> it(threads);
129 +    THD* tmp;
130 +
131 +    while ((tmp= it++))
132 +    {
133 +      Security_context *tmp_sctx= tmp->security_ctx;
134 +      struct st_my_thread_var *mysys_var;
135 +      const char *val;
136 +
137 +      if ((!tmp->vio_ok() && !tmp->system_thread) ||
138 +          (user && (!tmp_sctx->user || strcmp(tmp_sctx->user, user))))
139 +        continue;
140 +
141 +      restore_record(table, s->default_values);
142 +      /* ID */
143 +      table->field[0]->store((longlong) tmp->thread_id, TRUE);
144 +      /* USER */
145 +      val= tmp_sctx->user ? tmp_sctx->user :
146 +            (tmp->system_thread ? "system user" : "unauthenticated user");
147 +      table->field[1]->store(val, strlen(val), cs);
148 +      /* HOST */
149 +      if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) &&
150 +          thd->security_ctx->host_or_ip[0])
151 +      {
152 +        char host[LIST_PROCESS_HOST_LEN + 1];
153 +        my_snprintf(host, LIST_PROCESS_HOST_LEN, "%s:%u",
154 +                    tmp_sctx->host_or_ip, tmp->peer_port);
155 +        table->field[2]->store(host, strlen(host), cs);
156 +      }
157 +      else
158 +        table->field[2]->store(tmp_sctx->host_or_ip,
159 +                               strlen(tmp_sctx->host_or_ip), cs);
160 +      /* DB */
161 +      if (tmp->db)
162 +      {
163 +        table->field[3]->store(tmp->db, strlen(tmp->db), cs);
164 +        table->field[3]->set_notnull();
165 +      }
166 +
167 +      if ((mysys_var= tmp->mysys_var))
168 +        pthread_mutex_lock(&mysys_var->mutex);
169 +      /* COMMAND */
170 +      if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0)))
171 +        table->field[4]->store(val, strlen(val), cs);
172 +      else
173 +        table->field[4]->store(command_name[tmp->command],
174 +                               strlen(command_name[tmp->command]), cs);
175 +      /* MYSQL_TIME */
176 +      const ulonglong utime= tmp->start_timer ? current_timer - tmp->start_timer : 0; 
177 +      table->field[5]->store(utime / 1000000, TRUE);
178 +      /* STATE */
179 +#ifndef EMBEDDED_LIBRARY
180 +      val= (char*) (tmp->locked ? "Locked" :
181 +                    tmp->net.reading_or_writing ?
182 +                    (tmp->net.reading_or_writing == 2 ?
183 +                     "Writing to net" :
184 +                     tmp->command == COM_SLEEP ? "" :
185 +                     "Reading from net") :
186 +                    tmp->proc_info ? tmp->proc_info :
187 +                    tmp->mysys_var &&
188 +                    tmp->mysys_var->current_cond ?
189 +                    "Waiting on cond" : NullS);
190 +#else
191 +      val= (char *) "Writing to net";
192 +#endif
193 +      if (val)
194 +      {
195 +        table->field[6]->store(val, strlen(val), cs);
196 +        table->field[6]->set_notnull();
197 +      }
198 +
199 +      if (mysys_var)
200 +        pthread_mutex_unlock(&mysys_var->mutex);
201 +
202 +      /* INFO */
203 +      if (tmp->query)
204 +      {
205 +        table->field[7]->store(tmp->query,
206 +                               min(PROCESS_LIST_INFO_WIDTH,
207 +                                   tmp->query_length), cs);
208 +        table->field[7]->set_notnull();
209 +      }
210 +
211 +      /* TIME_MS */
212 +      table->field[8]->store((double)(utime / 1000.0));
213 +
214 +      if (schema_table_store_record(thd, table))
215 +      {
216 +        VOID(pthread_mutex_unlock(&LOCK_thread_count));
217 +        DBUG_RETURN(1);
218 +      }
219 +
220 +    }
221 +  }
222 +
223 +  VOID(pthread_mutex_unlock(&LOCK_thread_count));
224 +  DBUG_RETURN(0);
225  }
226  
227  /*****************************************************************************
228 @@ -4821,6 +4941,22 @@
229    {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
230  };
231  
232 +ST_FIELD_INFO processlist_fields_info[]=
233 +{
234 +  {"ID", 4, MYSQL_TYPE_LONG, 0, 0, "Id"},
235 +  {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
236 +  {"HOST", LIST_PROCESS_HOST_LEN,  MYSQL_TYPE_STRING, 0, 0, "Host"},
237 +  {"DB", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Db"},
238 +  {"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0, "Command"},
239 +  {"TIME", 7, MYSQL_TYPE_LONG, 0, 0, "Time"},
240 +  {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State"},
241 +  {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info"},
242 +  {"TIME_MS", 100 * (MY_INT64_NUM_DECIMAL_DIGITS + 1) + 3, MYSQL_TYPE_DECIMAL,
243 +    0, 0, "Time_ms"},
244 +  {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
245 +};
246 +
247 +
248  /*
249    Description of ST_FIELD_INFO in table.h
250  */
251 @@ -4845,6 +4981,8 @@
252      get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
253    {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
254     fill_open_tables, make_old_format, 0, -1, -1, 1},
255 +  {"PROCESSLIST", processlist_fields_info, create_schema_table,
256 +   fill_schema_processlist, make_old_format, 0, -1, -1, 0},
257    {"PROFILING", query_profile_statistics_info, create_schema_table,
258     fill_query_profile_statistics_info, make_profile_table_for_show, 
259     NULL, -1, -1, false},
260 diff -r 327ce7a34c91 sql/table.h
261 --- a/sql/table.h       Fri Nov 07 15:44:23 2008 -0800
262 +++ b/sql/table.h       Fri Nov 07 15:52:53 2008 -0800
263 @@ -378,6 +378,7 @@
264    SCH_INDEX_STATS,
265    SCH_KEY_COLUMN_USAGE,
266    SCH_OPEN_TABLES,
267 +  SCH_PROCESSLIST,
268    SCH_PROFILES,
269    SCH_PROCEDURES,
270    SCH_SCHEMATA,
271 diff -ruN mysql-5.0.67_highperf/patch_info/microsec_process.info mysql-5.0.67_highperf_tmp/patch_info/microsec_process.info
272 --- /dev/null   1970-01-01 09:00:00.000000000 +0900
273 +++ mysql-5.0.67_highperf_tmp/patch_info/microsec_process.info  2008-11-12 09:27:52.000000000 +0900
274 @@ -0,0 +1,6 @@
275 +File=microsec_process.patch
276 +Name=Adds INFOMATION_SCHEMA.PROCESSLIST with TIME_MS column
277 +Version=1.0
278 +Author=Percona <info@percona.com>
279 +License=GPL
280 +Comment=
281 +ChangeLog=
This page took 0.09076 seconds and 4 git commands to generate.