~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/embedded_innodb/status_table_function.cc

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
22
#if defined(HAVE_HAILDB_H)
 
23
# include <haildb.h>
 
24
#else
 
25
# include <embedded_innodb-1.0/innodb.h>
 
26
#endif /* HAVE_HAILDB_H */
 
27
 
 
28
#include "status_table_function.h"
 
29
 
 
30
using namespace std;
 
31
using namespace drizzled;
 
32
 
 
33
class LibInnoDBStatusTool : public drizzled::plugin::TableFunction
 
34
{
 
35
public:
 
36
 
 
37
  LibInnoDBStatusTool();
 
38
 
 
39
  LibInnoDBStatusTool(const char *table_arg) :
 
40
    drizzled::plugin::TableFunction("data_dictionary", table_arg)
 
41
  { }
 
42
 
 
43
  ~LibInnoDBStatusTool() {}
 
44
 
 
45
  class Generator : public drizzled::plugin::TableFunction::Generator
 
46
  {
 
47
  private:
 
48
    uint32_t names_next;
 
49
  public:
 
50
    Generator(drizzled::Field **arg);
 
51
    ~Generator();
 
52
 
 
53
    bool populate();
 
54
  };
 
55
 
 
56
  LibInnoDBStatusTool::Generator *generator(drizzled::Field **arg)
 
57
  {
 
58
    return new Generator(arg);
 
59
  }
 
60
};
 
61
 
 
62
static const char*      libinnodb_status_var_names[] = {
 
63
  "read_req_pending",
 
64
  "write_req_pending",
 
65
  "fsync_req_pending",
 
66
  "write_req_done",
 
67
  "read_req_done",
 
68
  "fsync_req_done",
 
69
  "bytes_total_written",
 
70
  "bytes_total_read",
 
71
 
 
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",
 
78
  "buffer_pool_reads",
 
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",
 
85
 
 
86
  "double_write_pages_written",
 
87
  "double_write_invoked",
 
88
 
 
89
  "log_buffer_slot_waits",
 
90
  "log_write_reqs",
 
91
  "log_write_flush_count",
 
92
  "log_bytes_written",
 
93
  "log_fsync_req_done",
 
94
  "log_write_req_pending",
 
95
  "log_fsync_req_pending",
 
96
 
 
97
  "lock_row_waits",
 
98
  "lock_row_waiting",
 
99
  "lock_total_wait_time_in_secs",
 
100
  "lock_wait_time_avg_in_secs",
 
101
  "lock_max_wait_time_in_secs",
 
102
 
 
103
  "row_total_read",
 
104
  "row_total_inserted",
 
105
  "row_total_updated",
 
106
  "row_total_deleted",
 
107
 
 
108
  "page_size",
 
109
  "have_atomic_builtins",
 
110
  NULL
 
111
};
 
112
 
 
113
LibInnoDBStatusTool::LibInnoDBStatusTool() :
 
114
  plugin::TableFunction("DATA_DICTIONARY", "INNODB_STATUS")
 
115
{
 
116
  add_field("NAME");
 
117
  add_field("VALUE", plugin::TableFunction::NUMBER);
 
118
}
 
119
 
 
120
LibInnoDBStatusTool::Generator::Generator(Field **arg) :
 
121
  plugin::TableFunction::Generator(arg),
 
122
  names_next(0)
 
123
{
 
124
}
 
125
 
 
126
LibInnoDBStatusTool::Generator::~Generator()
 
127
{
 
128
}
 
129
 
 
130
bool LibInnoDBStatusTool::Generator::populate()
 
131
{
 
132
  if (libinnodb_status_var_names[names_next] != NULL)
 
133
  {
 
134
    const char* config_name= libinnodb_status_var_names[names_next];
 
135
 
 
136
    push(config_name);
 
137
 
 
138
    ib_i64_t value;
 
139
    ib_err_t err= ib_status_get_i64(config_name, &value);
 
140
    assert(err == DB_SUCCESS);
 
141
 
 
142
    push(value);
 
143
 
 
144
    names_next++;
 
145
    return true;
 
146
  }
 
147
 
 
148
  return false; // No more rows
 
149
}
 
150
 
 
151
static LibInnoDBStatusTool *status_tool;
 
152
 
 
153
int status_table_function_initialize(drizzled::module::Context &context)
 
154
{
 
155
  status_tool= new(std::nothrow)LibInnoDBStatusTool();
 
156
  context.add(status_tool);
 
157
 
 
158
  return 0;
 
159
}