~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/handler/ha_innodb.cc

  • Committer: Brian Aker
  • Date: 2010-02-18 03:52:11 UTC
  • mto: (1273.16.6 fix_is)
  • mto: This revision was merged to the branch mainline in revision 1304.
  • Revision ID: brian@gaz-20100218035211-1aybyu5p4t7kx0u9
Updates to include sample Innodb table function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
#include "i_s.h"
128
128
#include "handler0vars.h"
129
129
 
 
130
#include <iostream>
 
131
#include <sstream>
130
132
#include <string>
131
133
 
 
134
#include "plugin/innobase/handler/status_function.h"
 
135
 
132
136
using namespace std;
133
137
using namespace drizzled;
134
138
 
162
166
#endif /* MYSQL_DYNAMIC_PLUGIN && __WIN__ */
163
167
 
164
168
static plugin::StorageEngine* innodb_engine_ptr= NULL;
 
169
static plugin::TableFunction* status_table_function_ptr= NULL;
165
170
 
166
171
static const long AUTOINC_OLD_STYLE_LOCKING = 0;
167
172
static const long AUTOINC_NEW_STYLE_LOCKING = 1;
611
616
  {NULL, NULL, SHOW_LONG}
612
617
};
613
618
 
 
619
InnodbStatusTool::Generator::Generator(drizzled::Field **fields) :
 
620
  plugin::TableFunction::Generator::Generator(fields)
 
621
 
622
  srv_export_innodb_status();
 
623
  status_var_ptr= innodb_status_variables;
 
624
}
 
625
 
 
626
bool InnodbStatusTool::Generator::populate()
 
627
{
 
628
  if (status_var_ptr->name)
 
629
  {
 
630
    std::ostringstream oss;
 
631
    string return_value;
 
632
    const char *value= status_var_ptr->value;
 
633
 
 
634
    /* VARIABLE_NAME */
 
635
    push(status_var_ptr->name);
 
636
 
 
637
    switch (status_var_ptr->type)
 
638
    {
 
639
    case SHOW_LONG:
 
640
      oss << *(int64_t*) value;
 
641
      return_value= oss.str();
 
642
      break;
 
643
    case SHOW_LONGLONG:
 
644
      oss << *(int64_t*) value;
 
645
      return_value= oss.str();
 
646
      break;
 
647
    case SHOW_BOOL:
 
648
      return_value= *(bool*) value ? "ON" : "OFF";
 
649
      break;
 
650
    default:
 
651
      assert(0);
 
652
    }
 
653
 
 
654
    /* VARIABLE_VALUE */
 
655
    if (return_value.length())
 
656
      push(return_value);
 
657
    else 
 
658
      push(" ");
 
659
 
 
660
    status_var_ptr++;
 
661
 
 
662
    return true;
 
663
  }
 
664
  return false;
 
665
}
 
666
 
614
667
/* General functions */
615
668
 
616
669
/******************************************************************//**
1739
1792
        char            *default_path;
1740
1793
        uint            format_id;
1741
1794
 
1742
 
        (void)innodb_status_variables;
1743
1795
        innodb_engine_ptr= new InnobaseEngine(innobase_engine_name);
1744
1796
 
1745
1797
 
2020
2072
                i_s_cmpmem_reset_init())
2021
2073
                goto error;
2022
2074
 
 
2075
        status_table_function_ptr= new InnodbStatusTool;
 
2076
 
2023
2077
        registry.add(innodb_engine_ptr);
2024
2078
 
 
2079
        registry.add(status_table_function_ptr);
 
2080
 
2025
2081
        registry.add(innodb_trx_schema_table);
2026
2082
        registry.add(innodb_locks_schema_table);
2027
2083
        registry.add(innodb_lock_waits_schema_table);   
2047
2103
{
2048
2104
        int     err= 0;
2049
2105
        i_s_common_deinit(registry);
 
2106
 
 
2107
        registry.remove(status_table_function_ptr);
 
2108
        delete status_table_function_ptr;
 
2109
 
2050
2110
        registry.remove(innodb_engine_ptr);
2051
2111
        delete innodb_engine_ptr;
2052
2112