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 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;
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 }
00080