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());
56 select.getShowSchema().c_str(),
57 select.getShowTable().c_str());
59 if (not plugin::Authorization::isAuthorized(*getSession().user(),
62 drizzled::error::access(*getSession().user(), identifier);
66 table_proto= plugin::StorageEngine::getTableMessage(getSession(), identifier);
69 is_tables_primed=
true;
73 bool ShowIndexes::Generator::nextIndexCore()
75 if (isIndexesPrimed())
81 if (not isTablesPrimed())
85 is_index_primed=
true;
88 if (index_iterator >= getTableProto().indexes_size())
91 index= getTableProto().
indexes(index_iterator);
96 bool ShowIndexes::Generator::nextIndex()
98 while (not nextIndexCore())
106 bool ShowIndexes::Generator::nextIndexPartsCore()
108 if (is_index_part_primed)
110 index_part_iterator++;
114 if (not isIndexesPrimed())
117 index_part_iterator= 0;
118 is_index_part_primed=
true;
121 if (index_part_iterator >= getIndex().index_part_size())
124 index_part= getIndex().index_part(index_part_iterator);
130 bool ShowIndexes::Generator::nextIndexParts()
132 while (not nextIndexPartsCore())
136 is_index_part_primed=
false;
144 bool ShowIndexes::Generator::populate()
146 if (not nextIndexParts())
154 void ShowIndexes::Generator::fill()
157 push(getTableName());
160 push(getIndex().is_unique());
163 push(getIndex().name());
166 push(static_cast<int64_t>(index_part_iterator + 1));
169 push(getTableProto().field(getIndexPart().fieldnr()).name());