~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/set_var.cc

  • Committer: Andrew Hutchings
  • Date: 2010-11-09 13:38:01 UTC
  • mto: (1919.1.2 trunk)
  • mto: This revision was merged to the branch mainline in revision 1920.
  • Revision ID: andrew@linuxjedi.co.uk-20101109133801-byjzsao76346395x
Add FLUSH GLOBAL STATUS; command
Clears the global status variables for the server

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 <boost/exception/get_error_info.hpp>
24
 
#include <string>
25
 
 
26
21
#include "drizzled/session.h"
27
22
#include "drizzled/item/string.h"
28
23
#include "drizzled/sql_list.h"
148
143
*/
149
144
int set_var::update(Session *session)
150
145
{
151
 
  try
152
 
  {
153
 
    if (! value)
154
 
      var->set_default(session, type);
155
 
    else if (var->update(session, this))
156
 
      return -1;                                // should never happen
157
 
    if (var->getAfterUpdateTrigger())
158
 
      (*var->getAfterUpdateTrigger())(session, type);
159
 
  }
160
 
  catch (invalid_option_value &ex)
161
 
  {
162
 
    /* TODO: Fix this to be typesafe once we have properly typed set_var */
163
 
    string new_val= boost::lexical_cast<string>(save_result.uint32_t_value);
164
 
    if (boost::get_error_info<invalid_max_info>(ex) != NULL)
165
 
    { 
166
 
      const uint64_t max_val= *(boost::get_error_info<invalid_max_info>(ex));
167
 
      string explanation("(> ");
168
 
      explanation.append(boost::lexical_cast<std::string>(max_val));
169
 
      explanation.push_back(')');
170
 
      push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
171
 
                          ER_INVALID_OPTION_VALUE,
172
 
                          ER(ER_INVALID_OPTION_VALUE),
173
 
                          var->getName().c_str(),
174
 
                          new_val.c_str(),
175
 
                          explanation.c_str());
176
 
    }
177
 
    else if (boost::get_error_info<invalid_min_info>(ex) != NULL)
178
 
    { 
179
 
      const int64_t min_val= *(boost::get_error_info<invalid_min_info>(ex));
180
 
      string explanation("(< ");
181
 
      explanation.append(boost::lexical_cast<std::string>(min_val));
182
 
      explanation.push_back(')');
183
 
      push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
184
 
                          ER_INVALID_OPTION_VALUE,
185
 
                          ER(ER_INVALID_OPTION_VALUE),
186
 
                          var->getName().c_str(),
187
 
                          new_val.c_str(),
188
 
                          explanation.c_str());
189
 
    }
190
 
    else
191
 
    {
192
 
      push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
193
 
                          ER_INVALID_OPTION_VALUE,
194
 
                          ER(ER_INVALID_OPTION_VALUE),
195
 
                          var->getName().c_str(),
196
 
                          new_val.c_str(),
197
 
                          "");
198
 
    }
199
 
  }
 
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);
200
152
  return 0;
201
153
}
202
154