1084
int ProcessListISMethods::fillTable(Session* session, TableList* tables, COND*)
1086
Table *table= tables->table;
1087
const CHARSET_INFO * const cs= system_charset_info;
1089
time_t now= time(NULL);
1092
if (now == (time_t)-1)
1097
pthread_mutex_lock(&LOCK_thread_count);
1099
if (!session->killed)
1103
for( vector<Session*>::iterator it= session_list.begin(); it != session_list.end(); ++it )
1106
Security_context *tmp_sctx= &tmp->security_ctx;
1107
struct st_my_thread_var *mysys_var;
1110
if (! tmp->protocol->isConnected())
1113
table->restoreRecordAsDefault();
1115
table->field[0]->store((int64_t) tmp->thread_id, true);
1117
val= tmp_sctx->user.c_str() ? tmp_sctx->user.c_str() : "unauthenticated user";
1118
table->field[1]->store(val, strlen(val), cs);
1120
table->field[2]->store(tmp_sctx->ip.c_str(), strlen(tmp_sctx->ip.c_str()), cs);
1124
table->field[3]->store(tmp->db, strlen(tmp->db), cs);
1125
table->field[3]->set_notnull();
1128
if ((mysys_var= tmp->mysys_var))
1129
pthread_mutex_lock(&mysys_var->mutex);
1131
if ((val= (char *) (tmp->killed == Session::KILL_CONNECTION? "Killed" : 0)))
1132
table->field[4]->store(val, strlen(val), cs);
1134
table->field[4]->store(command_name[tmp->command].str,
1135
command_name[tmp->command].length, cs);
1137
table->field[5]->store((uint32_t)(tmp->start_time ?
1138
now - tmp->start_time : 0), true);
1140
val= (char*) (tmp->protocol->isWriting() ?
1142
tmp->protocol->isReading() ?
1143
(tmp->command == COM_SLEEP ?
1144
NULL : "Reading from net") :
1145
tmp->get_proc_info() ? tmp->get_proc_info() :
1147
tmp->mysys_var->current_cond ?
1148
"Waiting on cond" : NULL);
1151
table->field[6]->store(val, strlen(val), cs);
1152
table->field[6]->set_notnull();
1156
pthread_mutex_unlock(&mysys_var->mutex);
1158
length= strlen(tmp->process_list_info);
1162
table->field[7]->store(tmp->process_list_info, length, cs);
1163
table->field[7]->set_notnull();
1166
if (schema_table_store_record(session, table))
1168
pthread_mutex_unlock(&LOCK_thread_count);
1174
pthread_mutex_unlock(&LOCK_thread_count);
1178
1084
/*****************************************************************************
1179
1085
Status functions
1180
1086
*****************************************************************************/
4314
ColumnInfo processlist_fields_info[]=
4316
ColumnInfo("ID", 4, DRIZZLE_TYPE_LONGLONG, 0, 0, "Id", SKIP_OPEN_TABLE),
4317
ColumnInfo("USER", 16, DRIZZLE_TYPE_VARCHAR, 0, 0, "User", SKIP_OPEN_TABLE),
4318
ColumnInfo("HOST", LIST_PROCESS_HOST_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Host",
4320
ColumnInfo("DB", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 1, "Db", SKIP_OPEN_TABLE),
4321
ColumnInfo("COMMAND", 16, DRIZZLE_TYPE_VARCHAR, 0, 0, "Command", SKIP_OPEN_TABLE),
4322
ColumnInfo("TIME", 7, DRIZZLE_TYPE_LONGLONG, 0, 0, "Time", SKIP_OPEN_TABLE),
4323
ColumnInfo("STATE", 64, DRIZZLE_TYPE_VARCHAR, 0, 1, "State", SKIP_OPEN_TABLE),
4324
ColumnInfo("INFO", PROCESS_LIST_INFO_WIDTH, DRIZZLE_TYPE_VARCHAR, 0, 1, "Info",
4330
4220
ColumnInfo plugin_fields_info[]=
4332
4222
ColumnInfo("PLUGIN_NAME", NAME_CHAR_LEN, DRIZZLE_TYPE_VARCHAR, 0, 0, "Name",
4370
4260
static KeyColUsageISMethods key_col_usage_methods;
4371
4261
static OpenTablesISMethods open_tables_methods;
4372
4262
static PluginsISMethods plugins_methods;
4373
static ProcessListISMethods processlist_methods;
4374
4263
static RefConstraintsISMethods ref_constraints_methods;
4375
4264
static SchemataISMethods schemata_methods;
4376
4265
static StatsISMethods stats_methods;
4415
4304
plugin_fields_info,
4416
4305
-1, -1, false, false, 0,
4417
4306
&plugins_methods);
4418
static InfoSchemaTable process_list_table("PROCESSLIST",
4419
processlist_fields_info,
4420
-1, -1, false, false, 0,
4421
&processlist_methods);
4422
4307
static InfoSchemaTable ref_constrain_table("REFERENTIAL_CONSTRAINTS",
4423
4308
referential_constraints_fields_info,
4424
4309
1, 9, false, true, OPEN_TABLE_ONLY,