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"
22
#if defined(HAVE_HAILDB_H)
25
# include <embedded_innodb-1.0/innodb.h>
26
#endif /* HAVE_HAILDB_H */
28
#include "status_table_function.h"
31
using namespace drizzled;
33
class LibInnoDBStatusTool : public drizzled::plugin::TableFunction
37
LibInnoDBStatusTool();
39
LibInnoDBStatusTool(const char *table_arg) :
40
drizzled::plugin::TableFunction("data_dictionary", table_arg)
43
~LibInnoDBStatusTool() {}
45
class Generator : public drizzled::plugin::TableFunction::Generator
50
Generator(drizzled::Field **arg);
56
LibInnoDBStatusTool::Generator *generator(drizzled::Field **arg)
58
return new Generator(arg);
62
static const char* libinnodb_status_var_names[] = {
69
"bytes_total_written",
72
"buffer_pool_current_size",
73
"buffer_pool_data_pages",
74
"buffer_pool_dirty_pages",
75
"buffer_pool_misc_pages",
76
"buffer_pool_free_pages",
77
"buffer_pool_read_reqs",
79
"buffer_pool_waited_for_free",
80
"buffer_pool_pages_flushed",
81
"buffer_pool_write_reqs",
82
"buffer_pool_total_pages",
83
"buffer_pool_pages_read",
84
"buffer_pool_pages_written",
86
"double_write_pages_written",
87
"double_write_invoked",
89
"log_buffer_slot_waits",
91
"log_write_flush_count",
94
"log_write_req_pending",
95
"log_fsync_req_pending",
99
"lock_total_wait_time_in_secs",
100
"lock_wait_time_avg_in_secs",
101
"lock_max_wait_time_in_secs",
104
"row_total_inserted",
109
"have_atomic_builtins",
113
LibInnoDBStatusTool::LibInnoDBStatusTool() :
114
plugin::TableFunction("DATA_DICTIONARY", "HAILDB_STATUS")
117
add_field("VALUE", plugin::TableFunction::NUMBER);
120
LibInnoDBStatusTool::Generator::Generator(Field **arg) :
121
plugin::TableFunction::Generator(arg),
126
LibInnoDBStatusTool::Generator::~Generator()
130
bool LibInnoDBStatusTool::Generator::populate()
132
if (libinnodb_status_var_names[names_next] != NULL)
134
const char* config_name= libinnodb_status_var_names[names_next];
139
ib_err_t err= ib_status_get_i64(config_name, &value);
140
assert(err == DB_SUCCESS);
148
return false; // No more rows
151
static LibInnoDBStatusTool *status_tool;
153
int status_table_function_initialize(drizzled::module::Context &context)
155
status_tool= new(std::nothrow)LibInnoDBStatusTool();
156
context.add(status_tool);