2
Copyright (C) 2010 Stewart Smith
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.
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.
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.
20
#include <drizzled/plugin/table_function.h>
24
#include "config_table_function.h"
27
using namespace drizzled;
29
class LibInnoDBConfigTool : public drizzled::plugin::TableFunction
33
LibInnoDBConfigTool();
35
LibInnoDBConfigTool(const char *table_arg) :
36
drizzled::plugin::TableFunction("data_dictionary", table_arg)
39
~LibInnoDBConfigTool() {}
41
class Generator : public drizzled::plugin::TableFunction::Generator
48
Generator(drizzled::Field **arg);
54
LibInnoDBConfigTool::Generator *generator(drizzled::Field **arg)
56
return new Generator(arg);
60
LibInnoDBConfigTool::LibInnoDBConfigTool() :
61
plugin::TableFunction("DATA_DICTIONARY", "HAILDB_CONFIGURATION")
65
add_field("VALUE", plugin::TableFunction::STRING, 64, true);
68
LibInnoDBConfigTool::Generator::Generator(Field **arg) :
69
plugin::TableFunction::Generator(arg),
72
ib_err_t err= ib_cfg_get_all(&names, &names_count);
73
assert(err == DB_SUCCESS);
76
LibInnoDBConfigTool::Generator::~Generator()
81
bool LibInnoDBConfigTool::Generator::populate()
83
if (names_next < names_count)
85
const char* config_name= names[names_next];
90
ib_err_t err= ib_cfg_var_get_type(config_name, &type);
91
assert(err == DB_SUCCESS);
94
err= ib_cfg_get(config_name, &value_ptr);
95
assert(err == DB_SUCCESS);
102
ib_bool_t value= (ib_bool_t)value_ptr;
103
if (value == IB_FALSE)
112
push((uint64_t)value_ptr);
118
push((uint64_t)value_ptr);
124
if (value_ptr == NULL)
127
push((char*)value_ptr);
132
if (value_ptr == NULL)
146
return false; // No more rows
149
static LibInnoDBConfigTool *config_tool;
151
int config_table_function_initialize(drizzled::module::Context &context)
153
config_tool= new LibInnoDBConfigTool();
154
context.add(config_tool);