~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sys_var.cc

  • Committer: Monty Taylor
  • Date: 2010-12-06 21:17:06 UTC
  • mto: (1977.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1980.
  • Revision ID: mordred@inaugust.com-20101206211706-iiuzzkxhh3fm10zf
Add ability to add a validation function to any sys_var. duh.

Show diffs side-by-side

added added

removed removed

Lines of Context:
321
321
/* Global read-only variable containing hostname */
322
322
static sys_var_const_str        sys_hostname("hostname", glob_hostname);
323
323
 
324
 
bool sys_var::check(Session *, set_var *var)
 
324
bool sys_var::check(Session *session, set_var *var)
325
325
{
 
326
  if (check_func)
 
327
  {
 
328
    int res;
 
329
    if ((res=(*check_func)(session, var)) < 0)
 
330
      my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), getName().c_str(), var->value->str_value.ptr());
 
331
    return res;
 
332
  }
326
333
  var->save_result.uint64_t_value= var->value->val_int();
327
334
  return 0;
328
335
}
329
336
 
330
337
bool sys_var_str::check(Session *session, set_var *var)
331
338
{
 
339
  if (!check_func)
 
340
    return 0;
 
341
 
332
342
  int res;
333
 
  if (!check_func)
334
 
    return 0;
335
 
 
336
343
  if ((res=(*check_func)(session, var)) < 0)
337
344
    my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), getName().c_str(), var->value->str_value.ptr());
338
345
  return res;