1 diff -r e3b747e556c8 mysql-test/r/information_schema.result
2 --- a/mysql-test/r/information_schema.result Mon May 18 18:44:04 2009 -0700
3 +++ b/mysql-test/r/information_schema.result Mon May 18 18:48:11 2009 -0700
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;
20 select table_schema,table_name, column_name from
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
31 SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA;
33 -information_schema 21
34 +information_schema 22
36 create table t1 (i int, j int);
37 create trigger trg1 before insert on t1 for each row
39 COLUMN_PRIVILEGES TABLE_SCHEMA
40 INDEX_STATISTICS TABLE_SCHEMA
41 KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
44 ROUTINES ROUTINE_SCHEMA
47 COLUMN_PRIVILEGES TABLE_SCHEMA
48 INDEX_STATISTICS TABLE_SCHEMA
49 KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
52 ROUTINES ROUTINE_SCHEMA
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 e3b747e556c8 mysql-test/r/information_schema_db.result
63 --- a/mysql-test/r/information_schema_db.result Mon May 18 18:44:04 2009 -0700
64 +++ b/mysql-test/r/information_schema_db.result Mon May 18 18:48:11 2009 -0700
73 diff -r e3b747e556c8 mysql-test/r/mysqlshow.result
74 --- a/mysql-test/r/mysqlshow.result Mon May 18 18:44:04 2009 -0700
75 +++ b/mysql-test/r/mysqlshow.result Mon May 18 18:48:11 2009 -0700
92 diff -r e3b747e556c8 patch_info/microsec_process.info
93 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
94 +++ b/patch_info/microsec_process.info Mon May 18 18:48:11 2009 -0700
96 +File=microsec_process.patch
97 +Name=Adds INFOMATION_SCHEMA.PROCESSLIST with TIME_MS column
99 +Author=Percona <info@percona.com>
102 diff -r e3b747e556c8 sql/mysql_priv.h
103 --- a/sql/mysql_priv.h Mon May 18 18:44:04 2009 -0700
104 +++ b/sql/mysql_priv.h Mon May 18 18:48:11 2009 -0700
107 /* Characters shown for the command in 'show processlist' */
108 #define PROCESS_LIST_WIDTH 100
109 +/* Characters shown for the command in 'information_schema.processlist' */
110 +#define PROCESS_LIST_INFO_WIDTH 65535
112 #define PRECISION_FOR_DOUBLE 53
113 #define PRECISION_FOR_FLOAT 24
114 diff -r e3b747e556c8 sql/sql_show.cc
115 --- a/sql/sql_show.cc Mon May 18 18:44:04 2009 -0700
116 +++ b/sql/sql_show.cc Mon May 18 18:48:11 2009 -0700
117 @@ -1480,6 +1480,122 @@
121 +int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond)
123 + TABLE *table= tables->table;
124 + CHARSET_INFO *cs= system_charset_info;
126 + ulonglong current_timer= my_timer(¤t_timer, frequency);
127 + DBUG_ENTER("fill_process_list");
129 + user= thd->security_ctx->master_access & PROCESS_ACL ?
130 + NullS : thd->security_ctx->priv_user;
132 + VOID(pthread_mutex_lock(&LOCK_thread_count));
136 + I_List_iterator<THD> it(threads);
139 + while ((tmp= it++))
141 + Security_context *tmp_sctx= tmp->security_ctx;
142 + struct st_my_thread_var *mysys_var;
145 + if ((!tmp->vio_ok() && !tmp->system_thread) ||
146 + (user && (!tmp_sctx->user || strcmp(tmp_sctx->user, user))))
149 + restore_record(table, s->default_values);
151 + table->field[0]->store((longlong) tmp->thread_id, TRUE);
153 + val= tmp_sctx->user ? tmp_sctx->user :
154 + (tmp->system_thread ? "system user" : "unauthenticated user");
155 + table->field[1]->store(val, strlen(val), cs);
157 + if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) &&
158 + thd->security_ctx->host_or_ip[0])
160 + char host[LIST_PROCESS_HOST_LEN + 1];
161 + my_snprintf(host, LIST_PROCESS_HOST_LEN, "%s:%u",
162 + tmp_sctx->host_or_ip, tmp->peer_port);
163 + table->field[2]->store(host, strlen(host), cs);
166 + table->field[2]->store(tmp_sctx->host_or_ip,
167 + strlen(tmp_sctx->host_or_ip), cs);
171 + table->field[3]->store(tmp->db, strlen(tmp->db), cs);
172 + table->field[3]->set_notnull();
175 + if ((mysys_var= tmp->mysys_var))
176 + pthread_mutex_lock(&mysys_var->mutex);
178 + if ((val= (char *) (tmp->killed == THD::KILL_CONNECTION? "Killed" : 0)))
179 + table->field[4]->store(val, strlen(val), cs);
181 + table->field[4]->store(command_name[tmp->command],
182 + strlen(command_name[tmp->command]), cs);
184 + ulonglong utime= (tmp->start_timer && current_timer) ? current_timer - tmp->start_timer : 0;
185 + /* correction for negative time */
186 + if (utime > 2629743) utime= 0;
187 + table->field[5]->store(utime / 1000000, TRUE);
189 +#ifndef EMBEDDED_LIBRARY
190 + val= (char*) (tmp->locked ? "Locked" :
191 + tmp->net.reading_or_writing ?
192 + (tmp->net.reading_or_writing == 2 ?
194 + tmp->command == COM_SLEEP ? "" :
195 + "Reading from net") :
196 + tmp->proc_info ? tmp->proc_info :
198 + tmp->mysys_var->current_cond ?
199 + "Waiting on cond" : NullS);
201 + val= (char *) "Writing to net";
205 + table->field[6]->store(val, strlen(val), cs);
206 + table->field[6]->set_notnull();
210 + pthread_mutex_unlock(&mysys_var->mutex);
215 + table->field[7]->store(tmp->query,
216 + min(PROCESS_LIST_INFO_WIDTH,
217 + tmp->query_length), cs);
218 + table->field[7]->set_notnull();
222 + table->field[8]->store((double)(utime / 1000.0));
224 + if (schema_table_store_record(thd, table))
226 + VOID(pthread_mutex_unlock(&LOCK_thread_count));
233 + VOID(pthread_mutex_unlock(&LOCK_thread_count));
237 /*****************************************************************************
239 *****************************************************************************/
240 @@ -4849,6 +4965,22 @@
241 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
244 +ST_FIELD_INFO processlist_fields_info[]=
246 + {"ID", 4, MYSQL_TYPE_LONG, 0, 0, "Id"},
247 + {"USER", 16, MYSQL_TYPE_STRING, 0, 0, "User"},
248 + {"HOST", LIST_PROCESS_HOST_LEN, MYSQL_TYPE_STRING, 0, 0, "Host"},
249 + {"DB", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, "Db"},
250 + {"COMMAND", 16, MYSQL_TYPE_STRING, 0, 0, "Command"},
251 + {"TIME", 7, MYSQL_TYPE_LONG, 0, 0, "Time"},
252 + {"STATE", 64, MYSQL_TYPE_STRING, 0, 1, "State"},
253 + {"INFO", PROCESS_LIST_INFO_WIDTH, MYSQL_TYPE_STRING, 0, 1, "Info"},
254 + {"TIME_MS", 100 * (MY_INT64_NUM_DECIMAL_DIGITS + 1) + 3, MYSQL_TYPE_DECIMAL,
256 + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
261 Description of ST_FIELD_INFO in table.h
263 @@ -4873,6 +5005,8 @@
264 get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
265 {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
266 fill_open_tables, make_old_format, 0, -1, -1, 1},
267 + {"PROCESSLIST", processlist_fields_info, create_schema_table,
268 + fill_schema_processlist, make_old_format, 0, -1, -1, 0},
269 {"PROFILING", query_profile_statistics_info, create_schema_table,
270 fill_query_profile_statistics_info, make_profile_table_for_show,
271 NULL, -1, -1, false},
272 diff -r e3b747e556c8 sql/table.h
273 --- a/sql/table.h Mon May 18 18:44:04 2009 -0700
274 +++ b/sql/table.h Mon May 18 18:48:11 2009 -0700
277 SCH_KEY_COLUMN_USAGE,