1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#include "plugin/schema_dictionary/dictionary.h"
25
using namespace drizzled;
27
IndexesTool::IndexesTool() :
30
add_field("TABLE_SCHEMA");
31
add_field("TABLE_NAME");
32
add_field("INDEX_NAME");
33
add_field("IS_USED_IN_PRIMARY", plugin::TableFunction::BOOLEAN);
34
add_field("IS_UNIQUE", plugin::TableFunction::BOOLEAN);
35
add_field("IS_NULLABLE", plugin::TableFunction::BOOLEAN);
36
add_field("KEY_LENGTH", plugin::TableFunction::NUMBER);
37
add_field("INDEX_TYPE");
38
add_field("INDEX_COMMENT", 1024);
41
IndexesTool::Generator::Generator(Field **arg) :
42
TablesTool::Generator(arg),
44
is_index_primed(false)
48
bool IndexesTool::Generator::nextIndexCore()
50
if (isIndexesPrimed())
56
if (not isTablesPrimed())
60
is_index_primed= true;
63
if (index_iterator >= getTableProto().indexes_size())
66
index= getTableProto().indexes(index_iterator);
71
bool IndexesTool::Generator::nextIndex()
73
while (not nextIndexCore())
77
is_index_primed= false;
83
bool IndexesTool::Generator::populate()
93
void IndexesTool::Generator::fill()
104
/* IS_USED_IN_PRIMARY */
105
push(index.is_primary());
108
push(index.is_unique());
111
push(index.options().null_part_key());
114
push(static_cast<uint64_t>(index.key_length()));
121
switch (index.type())
124
case message::Table::Index::UNKNOWN_INDEX:
126
length= sizeof("UNKNOWN");
128
case message::Table::Index::BTREE:
130
length= sizeof("BTREE");
132
case message::Table::Index::RTREE:
134
length= sizeof("RTREE");
136
case message::Table::Index::HASH:
138
length= sizeof("HASH");
140
case message::Table::Index::FULLTEXT:
142
length= sizeof("FULLTEXT");
148
/* "INDEX_COMMENT" */
149
push(index.comment());