Drizzled Public API Documentation

set_var.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #pragma once
00021 
00022 #include <boost/shared_ptr.hpp>
00023 
00024 #include <drizzled/common_fwd.h>
00025 #include <drizzled/enum.h>
00026 #include <drizzled/lex_string.h>
00027 
00028 namespace drizzled {
00029 
00030 /* Classes to support the SET command */
00031 
00032 
00033 /****************************************************************************
00034   Variables that are changable runtime are declared using the
00035   following classes
00036 ****************************************************************************/
00037 
00038 /****************************************************************************
00039   Classes for parsing of the SET command
00040 ****************************************************************************/
00041 
00042 class set_var_base
00043 {
00044 public:
00045   virtual ~set_var_base() {}
00046   virtual int check(Session*)= 0; /* To check privileges etc. */
00047   virtual int update(Session*)= 0;  /* To set the value */
00048   /* light check for PS */
00049 };
00050 
00051 /* MySQL internal variables */
00052 class set_var : public set_var_base
00053 {
00054   uint64_t uint64_t_value;
00055   std::string str_value;
00056 public:
00057   sys_var *var;
00058   Item *value;
00059   sql_var_t type;
00060   str_ref base; // for structs
00061 
00062   set_var(sql_var_t type_arg, sys_var *var_arg, str_ref base_name_arg, Item *value_arg);
00063   int check(Session *session);
00064   int update(Session *session);
00065   void setValue(const std::string &new_value);
00066   void setValue(uint64_t new_value);
00067   void updateValue();
00068 
00069   uint64_t getInteger()
00070   {
00071     return uint64_t_value;
00072   }
00073 
00074 };
00075 
00076 /* User variables like @my_own_variable */
00077 
00078 class set_var_user: public set_var_base
00079 {
00080   Item_func_set_user_var *user_var_item;
00081 public:
00082   explicit set_var_user(Item_func_set_user_var *item) :
00083     user_var_item(item)
00084   {}
00085   int check(Session *session);
00086   int update(Session *session);
00087 };
00088 
00089 typedef boost::shared_ptr<set_var_base> SetVarPtr;
00090 typedef std::vector<SetVarPtr> SetVarVector;
00091 int sql_set_variables(Session *session, const SetVarVector &var_list);
00092 
00093 } /* namespace drizzled */
00094