1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
4
* Copyright (C) 2008 Sun Microsystems, Inc.
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
51
52
-1 ERROR, message not sent
54
int sql_set_variables(Session *session, List<set_var_base> *var_list)
55
int sql_set_variables(Session *session, const SetVarVector &var_list)
57
List_iterator_fast<set_var_base> it(*var_list);
59
SetVarVector::const_iterator it(var_list.begin());
61
while (it != var_list.end())
62
if ((error= var->check(session)))
63
if ((error= (*it)->check(session)))
65
67
if (!(error= test(session->is_error())))
69
error|= var->update(session); // Returns 0, -1 or 1
70
while (it != var_list.end())
72
error|= (*it)->update(session); // Returns 0, -1 or 1
80
85
*****************************************************************************/
81
86
set_var::set_var(sql_var_t type_arg, sys_var *var_arg,
82
87
const LEX_STRING *base_name_arg, Item *value_arg) :
83
var(var_arg), type(type_arg), base(*base_name_arg)
86
95
If the set value is a field, change it to a string to allow things like
108
119
if (var->check_type(type))
110
121
int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE;
111
my_error(err, MYF(0), var->getName().c_str());
122
my_error(static_cast<drizzled::error_t>(err), MYF(0), var->getName().c_str());
114
125
/* value is a NULL pointer if we are using SET ... = DEFAULT */
156
167
if (var->getAfterUpdateTrigger())
157
168
(*var->getAfterUpdateTrigger())(session, type);
159
catch (boost::exception &)
170
catch (invalid_option_value &ex)
161
172
/* TODO: Fix this to be typesafe once we have properly typed set_var */
162
string new_val= boost::lexical_cast<string>(save_result.uint32_t_value);
163
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
164
ER_TRUNCATED_WRONG_VALUE,
165
ER(ER_TRUNCATED_WRONG_VALUE), var->getName().c_str(),
173
string new_val= boost::lexical_cast<string>(uint64_t_value);
174
if (boost::get_error_info<invalid_max_info>(ex) != NULL)
176
const uint64_t max_val= *(boost::get_error_info<invalid_max_info>(ex));
177
string explanation("(> ");
178
explanation.append(boost::lexical_cast<std::string>(max_val));
179
explanation.push_back(')');
180
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
181
ER_INVALID_OPTION_VALUE,
182
ER(ER_INVALID_OPTION_VALUE),
183
var->getName().c_str(),
185
explanation.c_str());
187
else if (boost::get_error_info<invalid_min_info>(ex) != NULL)
189
const int64_t min_val= *(boost::get_error_info<invalid_min_info>(ex));
190
string explanation("(< ");
191
explanation.append(boost::lexical_cast<std::string>(min_val));
192
explanation.push_back(')');
193
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
194
ER_INVALID_OPTION_VALUE,
195
ER(ER_INVALID_OPTION_VALUE),
196
var->getName().c_str(),
198
explanation.c_str());
200
else if (boost::get_error_info<invalid_value>(ex) != NULL)
202
const std::string str_val= *(boost::get_error_info<invalid_value>(ex));
203
string explanation("(");
204
explanation.append(str_val);
205
explanation.push_back(')');
206
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
207
ER_INVALID_OPTION_VALUE,
208
ER(ER_INVALID_OPTION_VALUE),
209
var->getName().c_str(),
211
explanation.c_str());
215
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
216
ER_INVALID_OPTION_VALUE,
217
ER(ER_INVALID_OPTION_VALUE),
218
var->getName().c_str(),
252
void set_var::setValue(const std::string &new_value)
254
str_value= new_value;
257
void set_var::setValue(uint64_t new_value)
259
uint64_t_value= new_value;
262
void set_var::updateValue()
264
if (var->show_type() != SHOW_CHAR)
266
uint64_t_value= value->val_int();
197
271
} /* namespace drizzled */