1283.28.3
by Stewart Smith
simple table function for Embedded InnoDB Configuration. Currently returns nothing. |
1 |
/*
|
2 |
Copyright (C) 2010 Stewart Smith
|
|
3 |
||
4 |
This program is free software; you can redistribute it and/or
|
|
5 |
modify it under the terms of the GNU General Public License
|
|
6 |
as published by the Free Software Foundation; either version 2
|
|
7 |
of the License, or (at your option) any later version.
|
|
8 |
||
9 |
This program is distributed in the hope that it will be useful,
|
|
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
GNU General Public License for more details.
|
|
13 |
||
14 |
You should have received a copy of the GNU General Public License
|
|
15 |
along with this program; if not, write to the Free Software
|
|
16 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
17 |
*/
|
|
18 |
||
19 |
#include "config.h" |
|
20 |
#include "drizzled/plugin/table_function.h" |
|
21 |
||
1815.2.1
by Stewart Smith
only include haildb.h in HailDB Plugin, do not even try for embedded innodb header. |
22 |
#include <haildb.h> |
1283.28.4
by Stewart Smith
fetch configuration variable names, put them in the table, test. |
23 |
|
1283.28.3
by Stewart Smith
simple table function for Embedded InnoDB Configuration. Currently returns nothing. |
24 |
#include "config_table_function.h" |
25 |
||
26 |
using namespace std; |
|
27 |
using namespace drizzled; |
|
28 |
||
29 |
class LibInnoDBConfigTool : public drizzled::plugin::TableFunction |
|
30 |
{
|
|
31 |
public: |
|
32 |
||
33 |
LibInnoDBConfigTool(); |
|
34 |
||
35 |
LibInnoDBConfigTool(const char *table_arg) : |
|
36 |
drizzled::plugin::TableFunction("data_dictionary", table_arg) |
|
37 |
{ } |
|
38 |
||
39 |
~LibInnoDBConfigTool() {} |
|
40 |
||
41 |
class Generator : public drizzled::plugin::TableFunction::Generator |
|
42 |
{
|
|
1283.28.4
by Stewart Smith
fetch configuration variable names, put them in the table, test. |
43 |
private: |
44 |
const char **names; |
|
45 |
uint32_t names_count; |
|
46 |
uint32_t names_next; |
|
1283.28.3
by Stewart Smith
simple table function for Embedded InnoDB Configuration. Currently returns nothing. |
47 |
public: |
48 |
Generator(drizzled::Field **arg); |
|
1283.28.4
by Stewart Smith
fetch configuration variable names, put them in the table, test. |
49 |
~Generator(); |
1283.28.3
by Stewart Smith
simple table function for Embedded InnoDB Configuration. Currently returns nothing. |
50 |
|
51 |
bool populate(); |
|
52 |
};
|
|
53 |
||
54 |
LibInnoDBConfigTool::Generator *generator(drizzled::Field **arg) |
|
55 |
{
|
|
56 |
return new Generator(arg); |
|
57 |
}
|
|
58 |
};
|
|
59 |
||
60 |
LibInnoDBConfigTool::LibInnoDBConfigTool() : |
|
1787.5.11
by Stewart Smith
rename remaining things from embedded_innodb/innodb to HailDB. The only things left are now the plugin name and what name the engine appears under (so it's still CREATE TABLE.. ENGINE=INNODB and options are --innodb.foo) |
61 |
plugin::TableFunction("DATA_DICTIONARY", "HAILDB_CONFIGURATION") |
1283.28.3
by Stewart Smith
simple table function for Embedded InnoDB Configuration. Currently returns nothing. |
62 |
{
|
63 |
add_field("NAME"); |
|
64 |
add_field("TYPE"); |
|
1283.28.8
by Stewart Smith
fix up handling of NULL for VALUEs in DATA_DICTIONARY.INNODB_CONFIGURATION table_function |
65 |
add_field("VALUE", plugin::TableFunction::STRING, 64, true); |
1283.28.3
by Stewart Smith
simple table function for Embedded InnoDB Configuration. Currently returns nothing. |
66 |
}
|
67 |
||
68 |
LibInnoDBConfigTool::Generator::Generator(Field **arg) : |
|
1283.28.4
by Stewart Smith
fetch configuration variable names, put them in the table, test. |
69 |
plugin::TableFunction::Generator(arg), |
70 |
names_next(0) |
|
71 |
{
|
|
72 |
ib_err_t err= ib_cfg_get_all(&names, &names_count); |
|
73 |
assert(err == DB_SUCCESS); |
|
74 |
}
|
|
75 |
||
76 |
LibInnoDBConfigTool::Generator::~Generator() |
|
77 |
{
|
|
78 |
free(names); |
|
1283.28.3
by Stewart Smith
simple table function for Embedded InnoDB Configuration. Currently returns nothing. |
79 |
}
|
80 |
||
81 |
bool LibInnoDBConfigTool::Generator::populate() |
|
82 |
{
|
|
1283.28.4
by Stewart Smith
fetch configuration variable names, put them in the table, test. |
83 |
if (names_next < names_count) |
84 |
{
|
|
1283.28.7
by Stewart Smith
export values of Embedded InnoDB configuration options in the data_dictionary.innodb_configuration table. Currently the test will fail due to aparrent bugs in the table_function implementation in drizzle (it's not respecting push() setting value to NULL) |
85 |
const char* config_name= names[names_next]; |
86 |
||
87 |
push(config_name); |
|
1283.28.6
by Stewart Smith
add configuration variable type to data_dictionary.innodb_configuration table. |
88 |
|
89 |
ib_cfg_type_t type; |
|
1283.28.7
by Stewart Smith
export values of Embedded InnoDB configuration options in the data_dictionary.innodb_configuration table. Currently the test will fail due to aparrent bugs in the table_function implementation in drizzle (it's not respecting push() setting value to NULL) |
90 |
ib_err_t err= ib_cfg_var_get_type(config_name, &type); |
91 |
assert(err == DB_SUCCESS); |
|
92 |
||
93 |
void *value_ptr; |
|
94 |
err= ib_cfg_get(config_name, &value_ptr); |
|
1283.28.6
by Stewart Smith
add configuration variable type to data_dictionary.innodb_configuration table. |
95 |
assert(err == DB_SUCCESS); |
96 |
||
97 |
switch(type) |
|
98 |
{
|
|
99 |
case IB_CFG_IBOOL: |
|
1283.28.7
by Stewart Smith
export values of Embedded InnoDB configuration options in the data_dictionary.innodb_configuration table. Currently the test will fail due to aparrent bugs in the table_function implementation in drizzle (it's not respecting push() setting value to NULL) |
100 |
{
|
1283.28.6
by Stewart Smith
add configuration variable type to data_dictionary.innodb_configuration table. |
101 |
push("BOOL"); |
1283.28.7
by Stewart Smith
export values of Embedded InnoDB configuration options in the data_dictionary.innodb_configuration table. Currently the test will fail due to aparrent bugs in the table_function implementation in drizzle (it's not respecting push() setting value to NULL) |
102 |
ib_bool_t value= (ib_bool_t)value_ptr; |
103 |
if (value == IB_FALSE) |
|
104 |
push("false"); |
|
105 |
else
|
|
106 |
push("true"); |
|
1283.28.6
by Stewart Smith
add configuration variable type to data_dictionary.innodb_configuration table. |
107 |
break; |
1283.28.7
by Stewart Smith
export values of Embedded InnoDB configuration options in the data_dictionary.innodb_configuration table. Currently the test will fail due to aparrent bugs in the table_function implementation in drizzle (it's not respecting push() setting value to NULL) |
108 |
}
|
1283.28.6
by Stewart Smith
add configuration variable type to data_dictionary.innodb_configuration table. |
109 |
case IB_CFG_ULINT: |
1283.28.7
by Stewart Smith
export values of Embedded InnoDB configuration options in the data_dictionary.innodb_configuration table. Currently the test will fail due to aparrent bugs in the table_function implementation in drizzle (it's not respecting push() setting value to NULL) |
110 |
{
|
1283.28.6
by Stewart Smith
add configuration variable type to data_dictionary.innodb_configuration table. |
111 |
push("ULINT"); |
1283.28.7
by Stewart Smith
export values of Embedded InnoDB configuration options in the data_dictionary.innodb_configuration table. Currently the test will fail due to aparrent bugs in the table_function implementation in drizzle (it's not respecting push() setting value to NULL) |
112 |
push((uint64_t)value_ptr); |
1283.28.6
by Stewart Smith
add configuration variable type to data_dictionary.innodb_configuration table. |
113 |
break; |
1283.28.7
by Stewart Smith
export values of Embedded InnoDB configuration options in the data_dictionary.innodb_configuration table. Currently the test will fail due to aparrent bugs in the table_function implementation in drizzle (it's not respecting push() setting value to NULL) |
114 |
}
|
1283.28.6
by Stewart Smith
add configuration variable type to data_dictionary.innodb_configuration table. |
115 |
case IB_CFG_ULONG: |
1283.28.7
by Stewart Smith
export values of Embedded InnoDB configuration options in the data_dictionary.innodb_configuration table. Currently the test will fail due to aparrent bugs in the table_function implementation in drizzle (it's not respecting push() setting value to NULL) |
116 |
{
|
1283.28.6
by Stewart Smith
add configuration variable type to data_dictionary.innodb_configuration table. |
117 |
push("ULONG"); |
1283.28.7
by Stewart Smith
export values of Embedded InnoDB configuration options in the data_dictionary.innodb_configuration table. Currently the test will fail due to aparrent bugs in the table_function implementation in drizzle (it's not respecting push() setting value to NULL) |
118 |
push((uint64_t)value_ptr); |
1283.28.6
by Stewart Smith
add configuration variable type to data_dictionary.innodb_configuration table. |
119 |
break; |
1283.28.7
by Stewart Smith
export values of Embedded InnoDB configuration options in the data_dictionary.innodb_configuration table. Currently the test will fail due to aparrent bugs in the table_function implementation in drizzle (it's not respecting push() setting value to NULL) |
120 |
}
|
1283.28.6
by Stewart Smith
add configuration variable type to data_dictionary.innodb_configuration table. |
121 |
case IB_CFG_TEXT: |
1283.28.7
by Stewart Smith
export values of Embedded InnoDB configuration options in the data_dictionary.innodb_configuration table. Currently the test will fail due to aparrent bugs in the table_function implementation in drizzle (it's not respecting push() setting value to NULL) |
122 |
{
|
1283.28.6
by Stewart Smith
add configuration variable type to data_dictionary.innodb_configuration table. |
123 |
push("TEXT"); |
1283.28.7
by Stewart Smith
export values of Embedded InnoDB configuration options in the data_dictionary.innodb_configuration table. Currently the test will fail due to aparrent bugs in the table_function implementation in drizzle (it's not respecting push() setting value to NULL) |
124 |
if (value_ptr == NULL) |
125 |
push(); |
|
126 |
else
|
|
127 |
push((char*)value_ptr); |
|
1283.28.6
by Stewart Smith
add configuration variable type to data_dictionary.innodb_configuration table. |
128 |
break; |
1283.28.7
by Stewart Smith
export values of Embedded InnoDB configuration options in the data_dictionary.innodb_configuration table. Currently the test will fail due to aparrent bugs in the table_function implementation in drizzle (it's not respecting push() setting value to NULL) |
129 |
}
|
1283.28.6
by Stewart Smith
add configuration variable type to data_dictionary.innodb_configuration table. |
130 |
case IB_CFG_CB: |
131 |
push("CALLBACK"); |
|
1283.28.7
by Stewart Smith
export values of Embedded InnoDB configuration options in the data_dictionary.innodb_configuration table. Currently the test will fail due to aparrent bugs in the table_function implementation in drizzle (it's not respecting push() setting value to NULL) |
132 |
if (value_ptr == NULL) |
133 |
push(); |
|
134 |
else
|
|
135 |
push("Is set"); |
|
1283.28.6
by Stewart Smith
add configuration variable type to data_dictionary.innodb_configuration table. |
136 |
break; |
137 |
default: |
|
138 |
push("UNKNOWN"); |
|
1283.28.7
by Stewart Smith
export values of Embedded InnoDB configuration options in the data_dictionary.innodb_configuration table. Currently the test will fail due to aparrent bugs in the table_function implementation in drizzle (it's not respecting push() setting value to NULL) |
139 |
push("UNKNOWN"); |
1283.28.6
by Stewart Smith
add configuration variable type to data_dictionary.innodb_configuration table. |
140 |
break; |
141 |
}
|
|
142 |
||
1283.28.4
by Stewart Smith
fetch configuration variable names, put them in the table, test. |
143 |
names_next++; |
144 |
return true; |
|
145 |
}
|
|
1283.28.3
by Stewart Smith
simple table function for Embedded InnoDB Configuration. Currently returns nothing. |
146 |
return false; // No more rows |
147 |
}
|
|
148 |
||
149 |
static LibInnoDBConfigTool *config_tool; |
|
150 |
||
1530.2.6
by Monty Taylor
Moved plugin::Context to module::Context. |
151 |
int config_table_function_initialize(drizzled::module::Context &context) |
1283.28.3
by Stewart Smith
simple table function for Embedded InnoDB Configuration. Currently returns nothing. |
152 |
{
|
153 |
config_tool= new(std::nothrow)LibInnoDBConfigTool(); |
|
1283.31.11
by Stewart Smith
merge trunk |
154 |
context.add(config_tool); |
1283.28.3
by Stewart Smith
simple table function for Embedded InnoDB Configuration. Currently returns nothing. |
155 |
|
156 |
return 0; |
|
157 |
}
|