22 #include <plugin/show_dictionary/dictionary.h>
23 #include <drizzled/identifier.h>
27 using namespace drizzled;
29 ShowIndexes::ShowIndexes() :
30 show_dictionary::Show(
"SHOW_INDEXES")
33 add_field(
"Unique", plugin::TableFunction::BOOLEAN, 0,
false);
34 add_field(
"Key_name");
35 add_field(
"Seq_in_index", plugin::TableFunction::NUMBER, 0,
false);
36 add_field(
"Column_name");
39 ShowIndexes::Generator::Generator(
Field **arg) :
40 show_dictionary::Show::Generator(arg),
41 is_tables_primed(false),
42 is_index_primed(false),
43 is_index_part_primed(false),
45 index_part_iterator(0)
47 if (not isShowQuery())
52 if (not select.getShowTable().empty() && not select.getShowSchema().empty())
54 table_name.append(select.getShowTable().c_str());
55 identifier::Table identifier(select.getShowSchema().c_str(), select.getShowTable().c_str());
57 if (not plugin::Authorization::isAuthorized(*getSession().user(),
60 drizzled::error::access(*getSession().user(), identifier);
64 table_proto= plugin::StorageEngine::getTableMessage(getSession(), identifier);
67 is_tables_primed=
true;
71 bool ShowIndexes::Generator::nextIndexCore()
73 if (isIndexesPrimed())
79 if (not isTablesPrimed())
83 is_index_primed=
true;
86 if (index_iterator >= getTableProto().indexes_size())
89 index= getTableProto().
indexes(index_iterator);
94 bool ShowIndexes::Generator::nextIndex()
96 while (not nextIndexCore())
104 bool ShowIndexes::Generator::nextIndexPartsCore()
106 if (is_index_part_primed)
108 index_part_iterator++;
112 if (not isIndexesPrimed())
115 index_part_iterator= 0;
116 is_index_part_primed=
true;
119 if (index_part_iterator >= getIndex().index_part_size())
122 index_part= getIndex().index_part(index_part_iterator);
128 bool ShowIndexes::Generator::nextIndexParts()
130 while (not nextIndexPartsCore())
134 is_index_part_primed=
false;
142 bool ShowIndexes::Generator::populate()
144 if (not nextIndexParts())
152 void ShowIndexes::Generator::fill()
155 push(getTableName());
158 push(getIndex().is_unique());
161 push(getIndex().name());
164 push(static_cast<int64_t>(index_part_iterator + 1));
167 push(getTableProto().field(getIndexPart().fieldnr()).name());