~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/set_var.cc

  • Committer: Brian Aker
  • Date: 2010-11-11 04:18:45 UTC
  • mfrom: (1897.4.20 rip-plugin-sysvar)
  • Revision ID: brian@tangent.org-20101111041845-b7td4vnx4wu01ga1
Merge in changes from Monty for sys var.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#include "config.h"
 
21
 
 
22
#include <boost/lexical_cast.hpp>
 
23
#include <string>
 
24
 
21
25
#include "drizzled/session.h"
22
26
#include "drizzled/item/string.h"
23
27
#include "drizzled/sql_list.h"
143
147
*/
144
148
int set_var::update(Session *session)
145
149
{
146
 
  if (! value)
147
 
    var->set_default(session, type);
148
 
  else if (var->update(session, this))
149
 
    return -1;                          // should never happen
150
 
  if (var->getAfterUpdateTrigger())
151
 
    (*var->getAfterUpdateTrigger())(session, type);
 
150
  try
 
151
  {
 
152
    if (! value)
 
153
      var->set_default(session, type);
 
154
    else if (var->update(session, this))
 
155
      return -1;                                // should never happen
 
156
    if (var->getAfterUpdateTrigger())
 
157
      (*var->getAfterUpdateTrigger())(session, type);
 
158
  }
 
159
  catch (boost::exception &)
 
160
  {
 
161
    /* 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(),
 
166
                        new_val.c_str());
 
167
  }
152
168
  return 0;
153
169
}
154
170