23 #include <plugin/show_dictionary/dictionary.h>
24 #include <drizzled/open_tables_state.h>
25 #include <drizzled/table/cache.h>
26 #include <drizzled/pthread_globals.h>
31 ShowTableStatus::ShowTableStatus() :
34 add_field(
"Session", plugin::TableFunction::NUMBER, 0,
false);
41 add_field(
"Avg_row_length");
42 add_field(
"Table_size");
43 add_field(
"Auto_increment");
49 scopedLock(table::Cache::mutex())
51 if (not isShowQuery())
56 schema_predicate.append(select.getShowSchema());
58 util::string::ptr schema(getSession().schema());
59 if (schema_predicate.empty() and schema)
61 schema_predicate.append(*schema);
64 if (not schema_predicate.empty())
66 table::CacheMap &open_cache(table::getCache());
68 for (table::CacheMap::const_iterator iter= open_cache.begin();
69 iter != open_cache.end();
72 table_list.push_back(iter->second);
75 for (
drizzled::Table *tmp_table= getSession().open_tables.getTemporaryTables(); tmp_table; tmp_table= tmp_table->getNext())
77 if (tmp_table->getShare())
79 table_list.push_back(tmp_table);
82 std::sort(table_list.begin(), table_list.end(), Table::compare);
86 ShowTableStatus::Generator::~Generator()
90 bool ShowTableStatus::Generator::nextCore()
94 table_list_iterator++;
99 table_list_iterator= table_list.begin();
102 if (table_list_iterator == table_list.end())
105 table= *table_list_iterator;
107 if (checkSchemaName())
113 bool ShowTableStatus::Generator::next()
115 while (not nextCore())
117 if (table_list_iterator != table_list.end())
126 bool ShowTableStatus::Generator::checkSchemaName()
128 if (not schema_predicate.empty() && schema_predicate.compare(schema_name()))
134 const char *ShowTableStatus::Generator::schema_name()
136 return table->getShare()->getSchemaName();
139 bool ShowTableStatus::Generator::populate()
157 if (table->getSession())
158 push(table->getSession()->getSessionId());
160 push(static_cast<int64_t>(0));
163 push(table->getShare()->getSchemaName());
166 push(table->getShare()->getTableName());
169 push(table->getShare()->getTableTypeAsString());
172 push(table->getEngine()->getName());
175 push(static_cast<int64_t>(table->getShare()->getVersion()));
178 push(static_cast<uint64_t>(table->getCursor().records()));
181 push(table->getCursor().rowSize());
184 push(table->getCursor().tableSize());
187 bool session_set=
false;
188 if (table->in_use == NULL)
190 table->in_use= &getSession();
194 table->getCursor().info(HA_STATUS_AUTO);
195 push(table->getCursor().getAutoIncrement());
TODO: Rename this file - func.h is stupid.