~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item_func.h

  • Committer: Brian Aker
  • Date: 2008-11-03 03:49:00 UTC
  • mfrom: (520.4.50 devel)
  • Revision ID: brian@tangent.org-20081103034900-znhvcgtipr3tlel5
Merging in Monty's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
#include <drizzled/functions/real.h>
64
64
#include <drizzled/functions/rollup_const.h>
65
65
#include <drizzled/functions/row_count.h>
 
66
#include <drizzled/functions/set_user_var.h>
66
67
#include <drizzled/functions/dec.h>
67
68
#include <drizzled/functions/int_val.h>
68
69
#include <drizzled/functions/acos.h>
88
89
#include <drizzled/functions/sign.h>
89
90
#include <drizzled/functions/signed.h>
90
91
#include <drizzled/functions/tan.h>
 
92
#include <drizzled/functions/update_hash.h>
 
93
#include <drizzled/functions/user_var_as_out_param.h>
91
94
#include <drizzled/functions/unsigned.h>
92
95
 
93
 
/* Handling of user definable variables */
94
 
 
95
 
class user_var_entry;
96
 
 
97
 
class Item_func_set_user_var :public Item_func
98
 
{
99
 
  enum Item_result cached_result_type;
100
 
  user_var_entry *entry;
101
 
  char buffer[MAX_FIELD_WIDTH];
102
 
  String value;
103
 
  my_decimal decimal_buff;
104
 
  bool null_item;
105
 
  union
106
 
  {
107
 
    int64_t vint;
108
 
    double vreal;
109
 
    String *vstr;
110
 
    my_decimal *vdec;
111
 
  } save_result;
112
 
 
113
 
public:
114
 
  LEX_STRING name; // keep it public
115
 
  Item_func_set_user_var(LEX_STRING a,Item *b)
116
 
    :Item_func(b), cached_result_type(INT_RESULT), name(a)
117
 
  {}
118
 
  enum Functype functype() const { return SUSERVAR_FUNC; }
119
 
  double val_real();
120
 
  int64_t val_int();
121
 
  String *val_str(String *str);
122
 
  my_decimal *val_decimal(my_decimal *);
123
 
  double val_result();
124
 
  int64_t val_int_result();
125
 
  String *str_result(String *str);
126
 
  my_decimal *val_decimal_result(my_decimal *);
127
 
  bool update_hash(void *ptr, uint32_t length, enum Item_result type,
128
 
                   const CHARSET_INFO * const cs, Derivation dv, bool unsigned_arg);
129
 
  bool send(Protocol *protocol, String *str_arg);
130
 
  void make_field(Send_field *tmp_field);
131
 
  bool check(bool use_result_field);
132
 
  bool update();
133
 
  enum Item_result result_type () const { return cached_result_type; }
134
 
  bool fix_fields(Session *session, Item **ref);
135
 
  void fix_length_and_dec();
136
 
  virtual void print(String *str, enum_query_type query_type);
137
 
  void print_as_stmt(String *str, enum_query_type query_type);
138
 
  const char *func_name() const { return "set_user_var"; }
139
 
  int save_in_field(Field *field, bool no_conversions,
140
 
                    bool can_use_result_field);
141
 
  int save_in_field(Field *field, bool no_conversions)
142
 
  {
143
 
    return save_in_field(field, no_conversions, 1);
144
 
  }
145
 
  void save_org_in_field(Field *field) { (void)save_in_field(field, 1, 0); }
146
 
  bool register_field_in_read_map(unsigned char *arg);
147
 
  bool register_field_in_bitmap(unsigned char *arg);
148
 
};
149
 
 
150
 
 
151
 
/*
152
 
  This item represents user variable used as out parameter (e.g in LOAD DATA),
153
 
  and it is supposed to be used only for this purprose. So it is simplified
154
 
  a lot. Actually you should never obtain its value.
155
 
 
156
 
  The only two reasons for this thing being an Item is possibility to store it
157
 
  in List<Item> and desire to place this code somewhere near other functions
158
 
  working with user variables.
159
 
*/
160
 
class Item_user_var_as_out_param :public Item
161
 
{
162
 
  LEX_STRING name;
163
 
  user_var_entry *entry;
164
 
public:
165
 
  Item_user_var_as_out_param(LEX_STRING a) : name(a) {}
166
 
  /* We should return something different from FIELD_ITEM here */
167
 
  enum Type type() const { return STRING_ITEM;}
168
 
  double val_real();
169
 
  int64_t val_int();
170
 
  String *val_str(String *str);
171
 
  my_decimal *val_decimal(my_decimal *decimal_buffer);
172
 
  /* fix_fields() binds variable name with its entry structure */
173
 
  bool fix_fields(Session *session, Item **ref);
174
 
  virtual void print(String *str, enum_query_type query_type);
175
 
  void set_null_value(const CHARSET_INFO * const cs);
176
 
  void set_value(const char *str, uint32_t length, const CHARSET_INFO * const cs);
177
 
};
178
 
 
179
 
 
180
96
/* For type casts */
181
97
 
182
98
enum Cast_target