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/enum.h>
00025 #include <drizzled/lex_string.h>
00026 
00027 namespace drizzled {
00028 
00029 namespace plugin
00030 {
00031   class StorageEngine;
00032 }
00033 
00034 class Session;
00035 class sys_var;
00036 class Item;
00037 class Item_func_set_user_var;
00038 class Time_zone;
00039 typedef struct my_locale_st MY_LOCALE;
00040 typedef struct charset_info_st CHARSET_INFO;
00041 
00042 /* Classes to support the SET command */
00043 
00044 
00045 /****************************************************************************
00046   Variables that are changable runtime are declared using the
00047   following classes
00048 ****************************************************************************/
00049 
00050 /****************************************************************************
00051   Classes for parsing of the SET command
00052 ****************************************************************************/
00053 
00054 class set_var_base
00055 {
00056 public:
00057   set_var_base() {}
00058   virtual ~set_var_base() {}
00059   virtual int check(Session *session)=0;  /* To check privileges etc. */
00060   virtual int update(Session *session)=0; /* To set the value */
00061   /* light check for PS */
00062 };
00063 
00064 /* MySQL internal variables */
00065 class set_var :
00066   public set_var_base
00067 {
00068   uint64_t uint64_t_value;
00069   std::string str_value;
00070 public:
00071   sys_var *var;
00072   Item *value;
00073   sql_var_t type;
00074   LEX_STRING base;      /* for structs */
00075 
00076   set_var(sql_var_t type_arg, sys_var *var_arg,
00077           const LEX_STRING *base_name_arg, Item *value_arg);
00078   int check(Session *session);
00079   int update(Session *session);
00080   void setValue(const std::string &new_value);
00081   void setValue(uint64_t new_value);
00082   void updateValue();
00083 
00084   uint64_t getInteger()
00085   {
00086     return uint64_t_value;
00087   }
00088 
00089 };
00090 
00091 /* User variables like @my_own_variable */
00092 
00093 class set_var_user: public set_var_base
00094 {
00095   Item_func_set_user_var *user_var_item;
00096 public:
00097   explicit set_var_user(Item_func_set_user_var *item) :
00098     user_var_item(item)
00099   {}
00100   int check(Session *session);
00101   int update(Session *session);
00102 };
00103 
00104 typedef boost::shared_ptr<set_var_base> SetVarPtr;
00105 typedef std::vector<SetVarPtr> SetVarVector;
00106 int sql_set_variables(Session *session, const SetVarVector &var_list);
00107 
00108 } /* namespace drizzled */
00109