~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/set_var.cc

  • Committer: Brian Aker
  • Date: 2011-01-10 02:13:14 UTC
  • mto: This revision was merged to the branch mainline in revision 2069.
  • Revision ID: brian@tangent.org-20110110021314-dye0guuovwz4oi3j
Formattting, etc.

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
22
#include <boost/lexical_cast.hpp>
23
23
#include <boost/exception/get_error_info.hpp>
24
24
#include <string>
25
25
 
26
 
#include <drizzled/session.h>
27
 
#include <drizzled/item/string.h>
28
 
#include <drizzled/sql_list.h>
29
 
#include <drizzled/function/set_user_var.h>
 
26
#include "drizzled/session.h"
 
27
#include "drizzled/item/string.h"
 
28
#include "drizzled/sql_list.h"
30
29
 
31
30
using namespace std;
32
31
 
76
75
  }
77
76
 
78
77
err:
79
 
  free_underlaid_joins(session, &session->getLex()->select_lex);
 
78
  free_underlaid_joins(session, &session->lex->select_lex);
80
79
  return(error);
81
80
}
82
81
 
86
85
*****************************************************************************/
87
86
set_var::set_var(sql_var_t type_arg, sys_var *var_arg,
88
87
                 const LEX_STRING *base_name_arg, Item *value_arg) :
89
 
  uint64_t_value(0),
90
 
  str_value(""),
91
 
  var(var_arg),
92
 
  type(type_arg),
93
 
  base(*base_name_arg)
 
88
  var(var_arg), type(type_arg), base(*base_name_arg)
94
89
{
95
90
  /*
96
91
    If the set value is a field, change it to a string to allow things like
105
100
      value=value_arg;                  /* Give error message later */
106
101
  }
107
102
  else
108
 
  {
109
 
    value= value_arg;
110
 
  }
 
103
    value=value_arg;
111
104
}
112
105
 
113
106
int set_var::check(Session *session)
171
164
  catch (invalid_option_value &ex)
172
165
  {
173
166
    /* TODO: Fix this to be typesafe once we have properly typed set_var */
174
 
    string new_val= boost::lexical_cast<string>(uint64_t_value);
 
167
    string new_val= boost::lexical_cast<string>(save_result.uint32_t_value);
175
168
    if (boost::get_error_info<invalid_max_info>(ex) != NULL)
176
169
    { 
177
170
      const uint64_t max_val= *(boost::get_error_info<invalid_max_info>(ex));
198
191
                          new_val.c_str(),
199
192
                          explanation.c_str());
200
193
    }
201
 
    else if (boost::get_error_info<invalid_value>(ex) != NULL)
202
 
    {
203
 
      const std::string str_val= *(boost::get_error_info<invalid_value>(ex));
204
 
      string explanation("(");
205
 
      explanation.append(str_val);
206
 
      explanation.push_back(')');
207
 
      push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
208
 
                          ER_INVALID_OPTION_VALUE,
209
 
                          ER(ER_INVALID_OPTION_VALUE),
210
 
                          var->getName().c_str(),
211
 
                          new_val.c_str(),
212
 
                          explanation.c_str());
213
 
    }
214
194
    else
215
195
    {
216
196
      push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
250
230
  return 0;
251
231
}
252
232
 
253
 
void set_var::setValue(const std::string &new_value)
254
 
{
255
 
  str_value= new_value;
256
 
}
257
 
 
258
 
void set_var::setValue(uint64_t new_value)
259
 
{
260
 
  uint64_t_value= new_value;
261
 
}
262
 
 
263
 
void set_var::updateValue()
264
 
{
265
 
  if (var->show_type() != SHOW_CHAR)
266
 
  {
267
 
    uint64_t_value= value->val_int();
268
 
  }
269
 
}
270
 
 
271
 
 
272
233
} /* namespace drizzled */