~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/set_var.h

Merge Joe, plus I updated the tests.

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) 2008 Sun Microsystems, Inc.
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; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
#ifndef DRIZZLED_SET_VAR_H
21
 
#define DRIZZLED_SET_VAR_H
22
 
 
23
 
#include <boost/shared_ptr.hpp>
24
 
 
25
 
#include "drizzled/memory/sql_alloc.h"
26
 
#include "drizzled/sql_list.h"
27
 
#include "drizzled/lex_string.h"
28
 
 
29
 
namespace drizzled
30
 
{
31
 
 
32
 
namespace plugin
33
 
{
34
 
class StorageEngine;
35
 
}
36
 
 
37
 
class sys_var;
38
 
class Item;
39
 
class Item_func_set_user_var;
40
 
class Time_zone;
41
 
typedef struct my_locale_st MY_LOCALE;
42
 
typedef struct charset_info_st CHARSET_INFO;
43
 
 
44
 
/* Classes to support the SET command */
45
 
 
46
 
 
47
 
/****************************************************************************
48
 
  Variables that are changable runtime are declared using the
49
 
  following classes
50
 
****************************************************************************/
51
 
 
52
 
/****************************************************************************
53
 
  Classes for parsing of the SET command
54
 
****************************************************************************/
55
 
 
56
 
class set_var_base
57
 
{
58
 
public:
59
 
  set_var_base() {}
60
 
  virtual ~set_var_base() {}
61
 
  virtual int check(Session *session)=0;        /* To check privileges etc. */
62
 
  virtual int update(Session *session)=0;       /* To set the value */
63
 
  /* light check for PS */
64
 
};
65
 
 
66
 
/* MySQL internal variables */
67
 
class set_var :
68
 
  public set_var_base
69
 
{
70
 
  uint64_t uint64_t_value;
71
 
  std::string str_value;
72
 
public:
73
 
  sys_var *var;
74
 
  Item *value;
75
 
  sql_var_t type;
76
 
  LEX_STRING base;                      /* for structs */
77
 
 
78
 
  set_var(sql_var_t type_arg, sys_var *var_arg,
79
 
          const LEX_STRING *base_name_arg, Item *value_arg);
80
 
  int check(Session *session);
81
 
  int update(Session *session);
82
 
  void setValue(const std::string &new_value);
83
 
  void setValue(uint64_t new_value);
84
 
  void updateValue();
85
 
 
86
 
  uint64_t getInteger()
87
 
  {
88
 
    return uint64_t_value;
89
 
  }
90
 
 
91
 
};
92
 
 
93
 
/* User variables like @my_own_variable */
94
 
 
95
 
class set_var_user: public set_var_base
96
 
{
97
 
  Item_func_set_user_var *user_var_item;
98
 
public:
99
 
  explicit set_var_user(Item_func_set_user_var *item) :
100
 
    user_var_item(item)
101
 
  {}
102
 
  int check(Session *session);
103
 
  int update(Session *session);
104
 
};
105
 
 
106
 
typedef boost::shared_ptr<set_var_base> SetVarPtr;
107
 
typedef std::vector<SetVarPtr> SetVarVector;
108
 
int sql_set_variables(Session *session, const SetVarVector &var_list);
109
 
 
110
 
} /* namespace drizzled */
111
 
 
112
 
#endif /* DRIZZLED_SET_VAR_H */