~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/set_option.cc

  • Committer: Mark Atwood
  • Date: 2008-10-16 11:33:16 UTC
  • mto: (520.1.13 drizzle)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: mark@fallenpegasus.com-20081016113316-ff6jdt31ck90sjdh
an implemention of the errmsg plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems, Inc.
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; either version 2 of the License, or
9
 
 *  (at your option) any later version.
10
 
 *
11
 
 *  This program is distributed in the hope that it will be useful,
12
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 *  GNU General Public License for more details.
15
 
 *
16
 
 *  You should have received a copy of the GNU General Public License
17
 
 *  along with this program; if not, write to the Free Software
18
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 
 */
20
 
 
21
 
#include <config.h>
22
 
#include <drizzled/show.h>
23
 
#include <drizzled/session.h>
24
 
#include <drizzled/statement/set_option.h>
25
 
 
26
 
namespace drizzled
27
 
{
28
 
 
29
 
namespace statement
30
 
{
31
 
SetOption::SetOption(Session *in_session) :
32
 
  Statement(in_session),
33
 
  one_shot_set(false)
34
 
  {
35
 
    getSession()->getLex()->sql_command= SQLCOM_SET_OPTION;
36
 
    init_select(getSession()->getLex());
37
 
    getSession()->getLex()->option_type= OPT_SESSION;
38
 
    getSession()->getLex()->var_list.empty();
39
 
  }
40
 
} // namespace statement
41
 
 
42
 
bool statement::SetOption::execute()
43
 
{
44
 
  TableList *all_tables= getSession()->getLex()->query_tables;
45
 
 
46
 
  if (getSession()->openTablesLock(all_tables))
47
 
  {
48
 
    return true;
49
 
  }
50
 
  bool res= sql_set_variables(getSession(), getSession()->getLex()->var_list);
51
 
  if (res)
52
 
  {
53
 
    /*
54
 
     * We encountered some sort of error, but no message was sent.
55
 
     * Send something semi-generic here since we don't know which
56
 
     * assignment in the list caused the error.
57
 
     */
58
 
    if (! getSession()->is_error())
59
 
    {
60
 
      my_error(ER_WRONG_ARGUMENTS, MYF(0), "SET");
61
 
    }
62
 
  }
63
 
  else
64
 
  {
65
 
    getSession()->my_ok();
66
 
  }
67
 
 
68
 
  return res;
69
 
}
70
 
 
71
 
} /* namespace drizzled */