23 #include <plugin/session_dictionary/dictionary.h>
27 #include <drizzled/pthread_globals.h>
28 #include <drizzled/plugin/client.h>
29 #include <drizzled/plugin/authorization.h>
30 #include <drizzled/internal/my_sys.h>
31 #include <drizzled/internal/thread_var.h>
32 #include <drizzled/session/state.h>
33 #include <drizzled/session/times.h>
39 ProcesslistTool::ProcesslistTool() :
40 plugin::TableFunction(
"DATA_DICTIONARY",
"PROCESSLIST")
42 add_field(
"ID", plugin::TableFunction::NUMBER, 0,
false);
43 add_field(
"USERNAME", 16);
44 add_field(
"HOST", NI_MAXHOST);
45 add_field(
"DB", plugin::TableFunction::STRING, MAXIMUM_IDENTIFIER_LENGTH,
true);
46 add_field(
"COMMAND", 16);
47 add_field(
"TIME", plugin::TableFunction::SIZE, 0,
false);
48 add_field(
"STATE", plugin::TableFunction::STRING, 256,
true);
50 add_field(
"HAS_GLOBAL_LOCK", plugin::TableFunction::BOOLEAN, 0,
false);
53 ProcesslistTool::Generator::Generator(
Field **arg) :
54 plugin::TableFunction::Generator(arg),
55 session_generator(*getSession().user())
59 bool ProcesslistTool::Generator::populate()
61 while (
Session* tmp= session_generator)
63 boost::shared_ptr<session::State> state(tmp->state());
64 identifier::user::ptr tmp_sctx= tmp->user();
67 push((int64_t) tmp->thread_id);
70 if (not tmp_sctx->username().empty())
71 push(tmp_sctx->username());
76 push(tmp_sctx->address());
79 util::string::ptr schema(tmp->schema());
80 if (schema and not schema->empty())
90 if (tmp->getKilled() == Session::KILL_CONNECTION)
96 push(getCommandName(tmp->command));
100 boost::posix_time::time_duration duration_result= getSession().times.start_timer() - getSession().times._start_timer;
101 push(static_cast<uint64_t>(duration_result.is_negative() ? 0 : duration_result.total_seconds()));
104 const char *step= tmp->get_proc_info();
105 step ? push(step): push();
111 const char *tmp_ptr= state->query(length);
112 push(tmp_ptr, length);
120 bool has_global_lock= tmp->isGlobalReadLock();
121 push(has_global_lock);
TODO: Rename this file - func.h is stupid.
#define PROCESS_LIST_WIDTH