~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/set_var.cc

  • Committer: Mark Atwood
  • Date: 2011-08-12 04:08:33 UTC
  • mfrom: (2385.2.17 refactor5)
  • Revision ID: me@mark.atwood.name-20110812040833-u6j85nc6ahuc0dtz
mergeĀ lp:~olafvdspek/drizzle/refactor5

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
 
20
#include <config.h>
21
21
 
 
22
#include <boost/foreach.hpp>
22
23
#include <boost/lexical_cast.hpp>
23
24
#include <boost/exception/get_error_info.hpp>
24
25
#include <string>
25
26
 
26
 
#include "drizzled/session.h"
27
 
#include "drizzled/item/string.h"
28
 
#include "drizzled/sql_list.h"
 
27
#include <drizzled/session.h>
 
28
#include <drizzled/item/string.h>
 
29
#include <drizzled/function/set_user_var.h>
 
30
#include <drizzled/sql_lex.h>
 
31
#include <drizzled/util/test.h>
29
32
 
30
33
using namespace std;
31
34
 
55
58
int sql_set_variables(Session *session, const SetVarVector &var_list)
56
59
{
57
60
  int error;
58
 
 
59
 
  SetVarVector::const_iterator it(var_list.begin());
60
 
 
61
 
  while (it != var_list.end())
 
61
  BOOST_FOREACH(SetVarVector::const_reference it, var_list)
62
62
  {
63
 
    if ((error= (*it)->check(session)))
 
63
    if ((error= it->check(session)))
64
64
      goto err;
65
 
    ++it;
66
65
  }
67
66
  if (!(error= test(session->is_error())))
68
67
  {
69
 
    it= var_list.begin();
70
 
    while (it != var_list.end())
 
68
    BOOST_FOREACH(SetVarVector::const_reference it, var_list)
71
69
    {
72
 
      error|= (*it)->update(session);         // Returns 0, -1 or 1
73
 
      ++it;
 
70
      error|= it->update(session);         // Returns 0, -1 or 1
74
71
    }
75
72
  }
76
73
 
77
74
err:
78
 
  free_underlaid_joins(session, &session->lex->select_lex);
79
 
  return(error);
 
75
  free_underlaid_joins(session, &session->lex().select_lex);
 
76
  return error;
80
77
}
81
78
 
82
79
 
84
81
  Functions to handle SET mysql_internal_variable=const_expr
85
82
*****************************************************************************/
86
83
set_var::set_var(sql_var_t type_arg, sys_var *var_arg,
87
 
                 const LEX_STRING *base_name_arg, Item *value_arg) :
 
84
                 const lex_string_t *base_name_arg, Item *value_arg) :
88
85
  uint64_t_value(0),
89
86
  str_value(""),
90
87
  var(var_arg),
98
95
  if (value_arg && value_arg->type() == Item::FIELD_ITEM)
99
96
  {
100
97
    Item_field *item= (Item_field*) value_arg;
101
 
    if (!(value=new Item_string(item->field_name,
102
 
                                (uint32_t) strlen(item->field_name),
103
 
                                item->collation.collation)))
104
 
      value=value_arg;                  /* Give error message later */
 
98
    value=new Item_string(item->field_name, (uint32_t) strlen(item->field_name), item->collation.collation);
105
99
  }
106
100
  else
107
101
  {
123
117
    return -1;
124
118
  }
125
119
  /* value is a NULL pointer if we are using SET ... = DEFAULT */
126
 
  if (!value)
 
120
  if (not value)
127
121
  {
128
122
    if (var->check_default(type))
129
123
    {
160
154
{
161
155
  try
162
156
  {
163
 
    if (! value)
 
157
    if (not value)
164
158
      var->set_default(session, type);
165
159
    else if (var->update(session, this))
166
160
      return -1;                                // should never happen
240
234
 
241
235
int set_var_user::update(Session *)
242
236
{
243
 
  if (user_var_item->update())
244
 
  {
245
 
    /* Give an error if it's not given already */
246
 
    my_message(ER_SET_CONSTANTS_ONLY, ER(ER_SET_CONSTANTS_ONLY), MYF(0));
247
 
    return -1;
248
 
  }
249
 
  return 0;
 
237
  user_var_item->update();
 
238
        return 0;
250
239
}
251
240
 
252
241
void set_var::setValue(const std::string &new_value)