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
IndexPartsTool::IndexPartsTool() :
28
IndexesTool("INDEX_PARTS")
30
add_field("TABLE_SCHEMA");
31
add_field("TABLE_NAME");
32
add_field("INDEX_NAME");
33
add_field("COLUMN_NAME");
34
add_field("COLUMN_NUMBER", plugin::TableFunction::NUMBER);
35
add_field("COMPARE_LENGTH", plugin::TableFunction::NUMBER);
36
add_field("IS_ORDER_REVERSE", plugin::TableFunction::BOOLEAN);
39
IndexPartsTool::Generator::Generator(Field **arg) :
40
IndexesTool::Generator(arg),
41
index_part_iterator(0),
42
is_index_part_primed(false)
47
bool IndexPartsTool::Generator::nextIndexPartsCore()
49
if (is_index_part_primed)
51
index_part_iterator++;
55
if (not isIndexesPrimed())
58
index_part_iterator= 0;
59
is_index_part_primed= true;
62
if (index_part_iterator >= getIndex().index_part_size())
65
index_part= getIndex().index_part(index_part_iterator);
70
bool IndexPartsTool::Generator::nextIndexParts()
72
while (not nextIndexPartsCore())
76
is_index_part_primed= false;
82
bool IndexPartsTool::Generator::populate()
84
if (not nextIndexParts())
92
void IndexPartsTool::Generator::fill()
101
push(getIndex().name());
104
push(getTableProto().field(index_part.fieldnr()).name());
107
push(index_part.fieldnr());
110
push(index_part.compare_length());
112
/* IS_ORDER_REVERSE */
113
push(index_part.in_reverse_order());