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