~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/set_var.h

mergeĀ lp:~hingo/drizzle/drizzle-auth_ldap-fix-and-docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLED_SET_VAR_H
21
 
#define DRIZZLED_SET_VAR_H
22
 
 
23
 
#include "drizzled/memory/sql_alloc.h"
24
 
#include "drizzled/sql_list.h"
25
 
#include "drizzled/lex_string.h"
26
 
 
27
 
namespace drizzled
28
 
{
29
 
 
30
 
namespace plugin
31
 
{
32
 
class StorageEngine;
33
 
}
34
 
 
35
 
class sys_var;
36
 
class Item;
37
 
class Item_func_set_user_var;
38
 
class Time_zone;
39
 
typedef struct my_locale_st MY_LOCALE;
40
 
typedef struct charset_info_st CHARSET_INFO;
 
20
#pragma once
 
21
 
 
22
#include <boost/shared_ptr.hpp>
 
23
 
 
24
#include <drizzled/common_fwd.h>
 
25
#include <drizzled/enum.h>
 
26
#include <drizzled/lex_string.h>
 
27
 
 
28
namespace drizzled {
41
29
 
42
30
/* Classes to support the SET command */
43
31
 
51
39
  Classes for parsing of the SET command
52
40
****************************************************************************/
53
41
 
54
 
class set_var_base :
55
 
  public memory::SqlAlloc
 
42
class set_var_base
56
43
{
57
44
public:
58
 
  set_var_base() {}
59
45
  virtual ~set_var_base() {}
60
 
  virtual int check(Session *session)=0;        /* To check privileges etc. */
61
 
  virtual int update(Session *session)=0;       /* To set the value */
 
46
  virtual int check(Session*)= 0;       /* To check privileges etc. */
 
47
  virtual int update(Session*)= 0;      /* To set the value */
62
48
  /* light check for PS */
63
49
};
64
50
 
65
51
/* MySQL internal variables */
66
 
class set_var :
67
 
  public set_var_base
 
52
class set_var : public set_var_base
68
53
{
 
54
  uint64_t uint64_t_value;
 
55
  std::string str_value;
69
56
public:
70
57
  sys_var *var;
71
58
  Item *value;
72
59
  sql_var_t type;
73
 
  union
 
60
  str_ref base; // for structs
 
61
 
 
62
  set_var(sql_var_t type_arg, sys_var *var_arg, str_ref base_name_arg, Item *value_arg);
 
63
  int check(Session *session);
 
64
  int update(Session *session);
 
65
  void setValue(const std::string &new_value);
 
66
  void setValue(uint64_t new_value);
 
67
  void updateValue();
 
68
 
 
69
  uint64_t getInteger()
74
70
  {
75
 
    const CHARSET_INFO *charset;
76
 
    uint32_t uint32_t_value;
77
 
    uint64_t uint64_t_value;
78
 
    size_t size_t_value;
79
 
    plugin::StorageEngine *storage_engine;
80
 
    Time_zone *time_zone;
81
 
    MY_LOCALE *locale_value;
82
 
  } save_result;
83
 
  LEX_STRING base;                      /* for structs */
 
71
    return uint64_t_value;
 
72
  }
84
73
 
85
 
  set_var(sql_var_t type_arg, sys_var *var_arg,
86
 
          const LEX_STRING *base_name_arg, Item *value_arg);
87
 
  int check(Session *session);
88
 
  int update(Session *session);
89
74
};
90
75
 
91
76
/* User variables like @my_own_variable */
94
79
{
95
80
  Item_func_set_user_var *user_var_item;
96
81
public:
97
 
  set_var_user(Item_func_set_user_var *item) :
 
82
  explicit set_var_user(Item_func_set_user_var *item) :
98
83
    user_var_item(item)
99
84
  {}
100
85
  int check(Session *session);
101
86
  int update(Session *session);
102
87
};
103
88
 
104
 
int sql_set_variables(Session *session, List<set_var_base> *var_list);
 
89
typedef boost::shared_ptr<set_var_base> SetVarPtr;
 
90
typedef std::vector<SetVarPtr> SetVarVector;
 
91
int sql_set_variables(Session *session, const SetVarVector &var_list);
105
92
 
106
93
} /* namespace drizzled */
107
94
 
108
 
#endif /* DRIZZLED_SET_VAR_H */