Drizzled Public API Documentation

set_user_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 <drizzled/function/func.h>
00023 
00024 namespace drizzled
00025 {
00026 
00027 /* Handling of user definable variables */
00028 
00029 class user_var_entry;
00030 
00031 class Item_func_set_user_var :public Item_func
00032 {
00033   enum Item_result cached_result_type;
00034   user_var_entry *entry;
00035   char buffer[MAX_FIELD_WIDTH];
00036   String value;
00037   type::Decimal decimal_buff;
00038   bool null_item;
00039   union
00040   {
00041     int64_t vint;
00042     double vreal;
00043     String *vstr;
00044     type::Decimal *vdec;
00045   } save_result;
00046 
00047 public:
00048   LEX_STRING name; // keep it public
00049   Item_func_set_user_var(LEX_STRING a,Item *b)
00050     :Item_func(b), cached_result_type(INT_RESULT), name(a)
00051   {}
00052   enum Functype functype() const { return SUSERVAR_FUNC; }
00053   double val_real();
00054   int64_t val_int();
00055   String *val_str(String *str);
00056   type::Decimal *val_decimal(type::Decimal *);
00057   double val_result();
00058   int64_t val_int_result();
00059   String *str_result(String *str);
00060   type::Decimal *val_decimal_result(type::Decimal *);
00061   bool update_hash(void *ptr, uint32_t length, enum Item_result type,
00062          const CHARSET_INFO * const cs, Derivation dv, bool unsigned_arg);
00063   bool send(plugin::Client *client, String *str_arg);
00064   void make_field(SendField *tmp_field);
00065   bool check(bool use_result_field);
00066   bool update();
00067   enum Item_result result_type () const { return cached_result_type; }
00068   bool fix_fields(Session *session, Item **ref);
00069   void fix_length_and_dec();
00070   virtual void print(String *str);
00071 
00072   const char *func_name() const { return "set_user_var"; }
00073   int save_in_field(Field *field, bool no_conversions,
00074                     bool can_use_result_field);
00075   int save_in_field(Field *field, bool no_conversions)
00076   {
00077     return save_in_field(field, no_conversions, 1);
00078   }
00079   void save_org_in_field(Field *field) { (void)save_in_field(field, 1, 0); }
00080   bool register_field_in_read_map(unsigned char *arg);
00081 };
00082 
00083 } /* namespace drizzled */
00084