1273.13.5
by Brian Aker
Additional definitions. |
1 |
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2010 Sun Microsystems
|
|
5 |
*
|
|
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.
|
|
10 |
*
|
|
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.
|
|
15 |
*
|
|
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
|
|
19 |
*/
|
|
20 |
||
1273.14.5
by Monty Taylor
Merged trunk. |
21 |
#include "config.h" |
1273.13.49
by Brian Aker
Does not work (compile issue in plugin). |
22 |
#include "plugin/schema_dictionary/dictionary.h" |
1273.13.5
by Brian Aker
Additional definitions. |
23 |
|
24 |
using namespace std; |
|
25 |
using namespace drizzled; |
|
26 |
||
1273.13.17
by Brian Aker
Pass through rewrite. |
27 |
IndexesTool::IndexesTool() : |
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
28 |
TablesTool("INDEXES") |
29 |
{
|
|
30 |
add_field("TABLE_SCHEMA"); |
|
31 |
add_field("TABLE_NAME"); |
|
32 |
add_field("INDEX_NAME"); |
|
1643.3.10
by Brian Aker
Column support, clean up of IS/DD for NULL type. |
33 |
add_field("IS_USED_IN_PRIMARY", plugin::TableFunction::BOOLEAN, 0, false); |
34 |
add_field("IS_UNIQUE", plugin::TableFunction::BOOLEAN, 0, false); |
|
35 |
add_field("IS_NULLABLE", plugin::TableFunction::BOOLEAN, 0, false); |
|
36 |
add_field("KEY_LENGTH", plugin::TableFunction::NUMBER, 0, false); |
|
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
37 |
add_field("INDEX_TYPE"); |
1567.1.1
by Brian Aker
This fixes bug 586009, increases the size of the log files so that the UNION |
38 |
add_field("INDEX_COMMENT", plugin::TableFunction::STRING, 1024, true); |
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
39 |
}
|
40 |
||
41 |
IndexesTool::Generator::Generator(Field **arg) : |
|
42 |
TablesTool::Generator(arg), |
|
43 |
index_iterator(0), |
|
44 |
is_index_primed(false) |
|
45 |
{
|
|
46 |
}
|
|
47 |
||
48 |
bool IndexesTool::Generator::nextIndexCore() |
|
49 |
{
|
|
50 |
if (isIndexesPrimed()) |
|
51 |
{
|
|
52 |
index_iterator++; |
|
53 |
}
|
|
54 |
else
|
|
55 |
{
|
|
56 |
if (not isTablesPrimed()) |
|
57 |
return false; |
|
58 |
||
59 |
index_iterator= 0; |
|
60 |
is_index_primed= true; |
|
61 |
}
|
|
62 |
||
63 |
if (index_iterator >= getTableProto().indexes_size()) |
|
64 |
return false; |
|
65 |
||
66 |
index= getTableProto().indexes(index_iterator); |
|
67 |
||
68 |
return true; |
|
69 |
}
|
|
70 |
||
71 |
bool IndexesTool::Generator::nextIndex() |
|
72 |
{
|
|
73 |
while (not nextIndexCore()) |
|
74 |
{
|
|
75 |
if (not nextTable()) |
|
76 |
return false; |
|
77 |
is_index_primed= false; |
|
78 |
}
|
|
79 |
||
80 |
return true; |
|
81 |
}
|
|
82 |
||
1273.13.21
by Brian Aker
Fix interface (we no longer need Fields passed around). |
83 |
bool IndexesTool::Generator::populate() |
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
84 |
{
|
85 |
if (not nextIndex()) |
|
86 |
return false; |
|
87 |
||
88 |
fill(); |
|
89 |
||
90 |
return true; |
|
91 |
}
|
|
92 |
||
93 |
void IndexesTool::Generator::fill() |
|
94 |
{
|
|
1273.13.17
by Brian Aker
Pass through rewrite. |
95 |
/* TABLE_SCHEMA */
|
1395.1.17
by Brian Aker
Correction to some of the output. |
96 |
push(getTableProto().schema()); |
1273.13.17
by Brian Aker
Pass through rewrite. |
97 |
|
98 |
/* TABLE_NAME */
|
|
1395.1.17
by Brian Aker
Correction to some of the output. |
99 |
push(getTableProto().name()); |
1273.13.17
by Brian Aker
Pass through rewrite. |
100 |
|
101 |
/* INDEX_NAME */
|
|
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
102 |
push(index.name()); |
103 |
||
1309.4.4
by Brian Aker
Column changing. |
104 |
/* IS_USED_IN_PRIMARY */
|
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
105 |
push(index.is_primary()); |
106 |
||
107 |
/* IS_UNIQUE */
|
|
108 |
push(index.is_unique()); |
|
109 |
||
110 |
/* IS_NULLABLE */
|
|
111 |
push(index.options().null_part_key()); |
|
1273.13.17
by Brian Aker
Pass through rewrite. |
112 |
|
113 |
/* KEY_LENGTH */
|
|
1273.13.82
by Brian Aker
Revert OSX fix, requiring more cast. |
114 |
push(static_cast<uint64_t>(index.key_length())); |
1273.13.17
by Brian Aker
Pass through rewrite. |
115 |
|
116 |
/* INDEX_TYPE */
|
|
117 |
{
|
|
118 |
const char *str; |
|
119 |
uint32_t length; |
|
120 |
||
121 |
switch (index.type()) |
|
122 |
{
|
|
123 |
default: |
|
124 |
case message::Table::Index::UNKNOWN_INDEX: |
|
125 |
str= "UNKNOWN"; |
|
126 |
length= sizeof("UNKNOWN"); |
|
127 |
break; |
|
128 |
case message::Table::Index::BTREE: |
|
129 |
str= "BTREE"; |
|
130 |
length= sizeof("BTREE"); |
|
131 |
break; |
|
132 |
case message::Table::Index::RTREE: |
|
133 |
str= "RTREE"; |
|
134 |
length= sizeof("RTREE"); |
|
135 |
break; |
|
136 |
case message::Table::Index::HASH: |
|
137 |
str= "HASH"; |
|
138 |
length= sizeof("HASH"); |
|
139 |
break; |
|
140 |
case message::Table::Index::FULLTEXT: |
|
141 |
str= "FULLTEXT"; |
|
142 |
length= sizeof("FULLTEXT"); |
|
143 |
break; |
|
144 |
}
|
|
1732.3.1
by Monty Taylor
Subtract one - and then remove the extra binary character. This will keep |
145 |
/* Subtract 1 here, because sizeof gives us the wrong amount */
|
146 |
push(str, length - 1); |
|
1273.13.17
by Brian Aker
Pass through rewrite. |
147 |
}
|
148 |
||
149 |
/* "INDEX_COMMENT" */
|
|
1567.1.1
by Brian Aker
This fixes bug 586009, increases the size of the log files so that the UNION |
150 |
if (index.has_comment()) |
151 |
{
|
|
152 |
push(index.comment()); |
|
153 |
}
|
|
154 |
else
|
|
155 |
{
|
|
156 |
push(); |
|
157 |
}
|
|
1273.13.17
by Brian Aker
Pass through rewrite. |
158 |
}
|