22 #include <plugin/schema_dictionary/dictionary.h>
23 #include <drizzled/statement/select.h>
28 IndexPartsTool::IndexPartsTool() :
31 add_field(
"TABLE_SCHEMA", plugin::TableFunction::STRING, MAXIMUM_IDENTIFIER_LENGTH,
false);
32 add_field(
"TABLE_NAME", plugin::TableFunction::STRING, MAXIMUM_IDENTIFIER_LENGTH,
false);
33 add_field(
"INDEX_NAME", plugin::TableFunction::STRING, MAXIMUM_IDENTIFIER_LENGTH,
false);
34 add_field(
"COLUMN_NAME", plugin::TableFunction::STRING, MAXIMUM_IDENTIFIER_LENGTH,
false);
35 add_field(
"COLUMN_NUMBER", plugin::TableFunction::NUMBER, 0,
false);
36 add_field(
"SEQUENCE_IN_INDEX", plugin::TableFunction::NUMBER, 0,
false);
37 add_field(
"COMPARE_LENGTH", plugin::TableFunction::NUMBER, 0,
true);
38 add_field(
"IS_ORDER_REVERSE", plugin::TableFunction::BOOLEAN, 0,
false);
39 add_field(
"IS_USED_IN_PRIMARY", plugin::TableFunction::BOOLEAN, 0,
false);
40 add_field(
"IS_UNIQUE", plugin::TableFunction::BOOLEAN, 0,
false);
41 add_field(
"IS_NULLABLE", plugin::TableFunction::BOOLEAN, 0,
false);
44 IndexPartsTool::Generator::Generator(
Field **arg) :
46 index_part_iterator(0),
47 is_index_part_primed(false)
52 bool IndexPartsTool::Generator::nextIndexPartsCore()
54 if (is_index_part_primed)
56 index_part_iterator++;
60 if (not isIndexesPrimed())
63 index_part_iterator= 0;
64 is_index_part_primed=
true;
67 if (index_part_iterator >= getIndex().index_part_size())
70 index_part= getIndex().index_part(index_part_iterator);
75 bool IndexPartsTool::Generator::nextIndexParts()
77 while (not nextIndexPartsCore())
81 is_index_part_primed=
false;
87 bool IndexPartsTool::Generator::populate()
89 if (not nextIndexParts())
97 void IndexPartsTool::Generator::fill()
102 push(getTableProto().schema());
105 push(getTableProto().name());
108 push(getIndex().name());
114 push(static_cast<int64_t>(index_part.fieldnr()));
117 push(static_cast<int64_t>(index_part_iterator));
120 if ((field.type() == message::Table::Field::VARCHAR or
121 field.type() == message::Table::Field::BLOB) and
122 (index_part.has_compare_length()) and
123 (index_part.compare_length() != field.string_options().length()))
125 push(static_cast<int64_t>(index_part.compare_length()));
131 push(index_part.in_reverse_order());
134 push(getIndex().is_primary());
137 push(getIndex().is_unique());
140 push(getIndex().options().null_part_key());
TODO: Rename this file - func.h is stupid.