~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/status_dictionary/status.cc

  • Committer: Stewart Smith
  • Date: 2008-11-21 16:06:07 UTC
  • mto: This revision was merged to the branch mainline in revision 593.
  • Revision ID: stewart@flamingspork.com-20081121160607-n6gdlt013spuo54r
remove mysql_frm_type
and fix engines to return correct value from delete_table when table doesn't exist.
(it should be ENOENT).

Also fix up some tests that manipulated frm files by hand. These tests are no longer valid and will need to be rewritten in the not too distant future.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2010 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; either version 2 of the License, or
9
 
 *  (at your option) any later version.
10
 
 *
11
 
 *  This program is distributed in the hope that it will be useful,
12
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 *  GNU General Public License for more details.
15
 
 *
16
 
 *  You should have received a copy of the GNU General Public License
17
 
 *  along with this program; if not, write to the Free Software
18
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 
 */
20
 
 
21
 
#include "config.h"
22
 
 
23
 
#include "plugin/status_dictionary/dictionary.h"
24
 
 
25
 
#include <drizzled/pthread_globals.h>
26
 
#include <drizzled/internal/m_string.h>
27
 
#include <drizzled/definitions.h>
28
 
#include <drizzled/status_helper.h>
29
 
 
30
 
#include <vector>
31
 
#include <string>
32
 
#include <sstream>
33
 
 
34
 
using namespace std;
35
 
using namespace drizzled;
36
 
 
37
 
StateTool::StateTool(const char *arg, bool global) :
38
 
  plugin::TableFunction("DATA_DICTIONARY", arg),
39
 
  option_type(global ? OPT_GLOBAL : OPT_SESSION)
40
 
{
41
 
  add_field("VARIABLE_NAME");
42
 
  add_field("VARIABLE_VALUE", 1024);
43
 
}
44
 
 
45
 
StateTool::Generator::Generator(Field **arg, sql_var_t option_arg,
46
 
                                drizzle_show_var *variables_args)
47
 
                                :
48
 
  plugin::TableFunction::Generator(arg),
49
 
  option_type(option_arg),
50
 
  variables(variables_args)
51
 
{
52
 
}
53
 
 
54
 
StateTool::Generator::~Generator()
55
 
{
56
 
}
57
 
 
58
 
bool StateTool::Generator::populate()
59
 
{
60
 
  while (variables && variables->name)
61
 
  {
62
 
    drizzle_show_var *var;
63
 
    MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, int64_t);
64
 
    char * const buff= (char *) &buff_data;
65
 
 
66
 
    /*
67
 
      if var->type is SHOW_FUNC, call the function.
68
 
      Repeat as necessary, if new var is again SHOW_FUNC
69
 
    */
70
 
    {
71
 
      drizzle_show_var tmp;
72
 
 
73
 
      for (var= variables; var->type == SHOW_FUNC; var= &tmp)
74
 
        ((mysql_show_var_func)((st_show_var_func_container *)var->value)->func)(&tmp, buff);
75
 
    }
76
 
 
77
 
    if (isWild(variables->name))
78
 
    {
79
 
      variables++;
80
 
      continue;
81
 
    }
82
 
 
83
 
    fill(variables->name, var->value, var->type);
84
 
 
85
 
    variables++;
86
 
 
87
 
    return true;
88
 
  }
89
 
 
90
 
  return false;
91
 
}
92
 
 
93
 
void StateTool::Generator::fill(const std::string &name, char *value, SHOW_TYPE show_type)
94
 
{
95
 
  std::ostringstream oss;
96
 
  std::string return_value;
97
 
 
98
 
  LOCK_global_system_variables.lock();
99
 
 
100
 
  if (show_type == SHOW_SYS)
101
 
  {
102
 
    show_type= ((sys_var*) value)->show_type();
103
 
    value= (char*) ((sys_var*) value)->value_ptr(&(getSession()), option_type,
104
 
                                                 &null_lex_str);
105
 
  }
106
 
 
107
 
  return_value= StatusHelper::fillHelper(NULL, value, show_type); 
108
 
 
109
 
  LOCK_global_system_variables.unlock();
110
 
  push(name);
111
 
  if (return_value.length())
112
 
    push(return_value);
113
 
  else 
114
 
    push(" ");
115
 
}