00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #pragma once
00021
00022 #include <drizzled/function/func.h>
00023
00024 namespace drizzled
00025 {
00026
00027
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;
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 }
00084