24 #include <plugin/session_dictionary/dictionary.h>
28 #include <drizzled/internal/my_sys.h>
29 #include <drizzled/internal/thread_var.h>
30 #include <drizzled/plugin/authorization.h>
31 #include <drizzled/plugin/client.h>
32 #include <drizzled/pthread_globals.h>
33 #include <drizzled/session/state.h>
41 Sessions::Sessions() :
42 plugin::TableFunction(
"DATA_DICTIONARY",
"SESSIONS")
44 add_field(
"SESSION_ID", plugin::TableFunction::NUMBER, 0,
false);
45 add_field(
"SESSION_USERNAME", 16);
46 add_field(
"SESSION_HOST", NI_MAXHOST);
47 add_field(
"SESSION_CATALOG", plugin::TableFunction::STRING, MAXIMUM_IDENTIFIER_LENGTH,
false);
48 add_field(
"SESSION_SCHEMA", plugin::TableFunction::STRING, MAXIMUM_IDENTIFIER_LENGTH,
true);
49 add_field(
"COMMAND", 16);
50 add_field(
"STATE", plugin::TableFunction::STRING, 256,
true);
52 add_field(
"HAS_GLOBAL_LOCK", plugin::TableFunction::BOOLEAN, 0,
false);
53 add_field(
"IS_INTERACTIVE", plugin::TableFunction::BOOLEAN, 0,
false);
54 add_field(
"IS_CONSOLE", plugin::TableFunction::BOOLEAN, 0,
false);
57 Sessions::Generator::Generator(
Field **arg) :
58 plugin::TableFunction::Generator(arg),
59 session_generator(*getSession().user())
63 bool Sessions::Generator::populate()
65 while (
Session* tmp= session_generator)
67 boost::shared_ptr<session::State> state(tmp->state());
68 identifier::user::ptr tmp_sctx= tmp->user();
71 push((int64_t) tmp->thread_id);
74 if (not tmp_sctx->username().empty())
75 push(tmp_sctx->username());
80 push(tmp_sctx->address());
83 push(tmp->catalog().name());
86 util::string::ptr schema(tmp->schema());
87 if (schema and not schema->empty())
97 if (tmp->getKilled() == Session::KILL_CONNECTION)
103 push(getCommandName(tmp->command));
107 const char *step= tmp->get_proc_info();
108 step ? push(step): push();
114 const char *tmp_ptr= state->query(length);
115 push(tmp_ptr, length);
123 bool has_global_lock= tmp->isGlobalReadLock();
124 push(has_global_lock);
127 push(tmp->getClient()->isInteractive());
130 push(tmp->getClient()->isConsole());
TODO: Rename this file - func.h is stupid.
#define PROCESS_LIST_WIDTH