00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <config.h>
00020 #include <drizzled/plugin/table_function.h>
00021
00022 #include <haildb.h>
00023
00024 #include "status_table_function.h"
00025
00026 using namespace std;
00027 using namespace drizzled;
00028
00029 class LibInnoDBStatusTool : public drizzled::plugin::TableFunction
00030 {
00031 public:
00032
00033 LibInnoDBStatusTool();
00034
00035 LibInnoDBStatusTool(const char *table_arg) :
00036 drizzled::plugin::TableFunction("data_dictionary", table_arg)
00037 { }
00038
00039 ~LibInnoDBStatusTool() {}
00040
00041 class Generator : public drizzled::plugin::TableFunction::Generator
00042 {
00043 private:
00044 const char **names;
00045 uint32_t names_count;
00046 uint32_t names_next;
00047 public:
00048 Generator(drizzled::Field **arg);
00049 ~Generator();
00050
00051 bool populate();
00052 };
00053
00054 LibInnoDBStatusTool::Generator *generator(drizzled::Field **arg)
00055 {
00056 return new Generator(arg);
00057 }
00058 };
00059
00060 LibInnoDBStatusTool::LibInnoDBStatusTool() :
00061 plugin::TableFunction("DATA_DICTIONARY", "HAILDB_STATUS")
00062 {
00063 add_field("NAME");
00064 add_field("VALUE", plugin::TableFunction::NUMBER);
00065 }
00066
00067 LibInnoDBStatusTool::Generator::Generator(Field **arg) :
00068 plugin::TableFunction::Generator(arg),
00069 names_next(0)
00070 {
00071 ib_err_t err= ib_status_get_all(&names, &names_count);
00072 assert(err == DB_SUCCESS);
00073 }
00074
00075 LibInnoDBStatusTool::Generator::~Generator()
00076 {
00077 free(names);
00078 }
00079
00080 bool LibInnoDBStatusTool::Generator::populate()
00081 {
00082 if (names[names_next] != NULL)
00083 {
00084 const char* config_name= names[names_next];
00085
00086 push(config_name);
00087
00088 ib_i64_t value;
00089 ib_err_t err= ib_status_get_i64(config_name, &value);
00090 assert(err == DB_SUCCESS);
00091
00092 push(value);
00093
00094 names_next++;
00095 return true;
00096 }
00097
00098 return false;
00099 }
00100
00101 static LibInnoDBStatusTool *status_tool;
00102
00103 int status_table_function_initialize(drizzled::module::Context &context)
00104 {
00105 status_tool= new(std::nothrow)LibInnoDBStatusTool();
00106 context.add(status_tool);
00107
00108 return 0;
00109 }