~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/set_var.cc

merged with up to date trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
5
5
 *
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
52
52
    -1  ERROR, message not sent
53
53
*/
54
54
 
55
 
int sql_set_variables(Session *session, List<set_var_base> *var_list)
 
55
int sql_set_variables(Session *session, const SetVarVector &var_list)
56
56
{
57
57
  int error;
58
 
  List_iterator_fast<set_var_base> it(*var_list);
59
 
 
60
 
  set_var_base *var;
61
 
  while ((var=it++))
 
58
 
 
59
  SetVarVector::const_iterator it(var_list.begin());
 
60
 
 
61
  while (it != var_list.end())
62
62
  {
63
 
    if ((error= var->check(session)))
 
63
    if ((error= (*it)->check(session)))
64
64
      goto err;
 
65
    ++it;
65
66
  }
66
67
  if (!(error= test(session->is_error())))
67
68
  {
68
 
    it.rewind();
69
 
    while ((var= it++))
70
 
      error|= var->update(session);         // Returns 0, -1 or 1
 
69
    it= var_list.begin();
 
70
    while (it != var_list.end())
 
71
    {
 
72
      error|= (*it)->update(session);         // Returns 0, -1 or 1
 
73
      ++it;
 
74
    }
71
75
  }
72
76
 
73
77
err:
109
113
  if (var->check_type(type))
110
114
  {
111
115
    int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE;
112
 
    my_error(err, MYF(0), var->getName().c_str());
 
116
    my_error(static_cast<drizzled::error_t>(err), MYF(0), var->getName().c_str());
113
117
    return -1;
114
118
  }
115
119
  /* value is a NULL pointer if we are using SET ... = DEFAULT */