1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
*
* Copyright (C) 2008 Sun Microsystems
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DRIZZLED_SERVER_ITEM_FUNC_H
#define DRIZZLED_SERVER_ITEM_FUNC_H
/* Function items used by mysql */
#ifdef HAVE_IEEEFP_H
extern "C" /* Bug in BSDI include file */
{
#include <ieeefp.h>
}
#endif
#include <drizzled/functions/func.h>
#include <drizzled/functions/additive_op.h>
#include <drizzled/functions/connection_id.h>
#include <drizzled/functions/decimal_typecast.h>
#include <drizzled/functions/divide.h>
#include <drizzled/functions/get_system_var.h>
#include <drizzled/functions/int.h>
#include <drizzled/functions/bit.h>
#include <drizzled/functions/bit_count.h>
#include <drizzled/functions/bit_length.h>
#include <drizzled/functions/field.h>
#include <drizzled/functions/find_in_set.h>
#include <drizzled/functions/found_rows.h>
#include <drizzled/functions/get_user_var.h>
#include <drizzled/functions/get_variable.h>
#include <drizzled/functions/integer.h>
#include <drizzled/functions/int_divide.h>
#include <drizzled/functions/length.h>
#include <drizzled/functions/lock.h>
#include <drizzled/functions/master_pos_wait.h>
#include <drizzled/functions/min_max.h>
#include <drizzled/functions/minus.h>
#include <drizzled/functions/mod.h>
#include <drizzled/functions/multiply.h>
#include <drizzled/functions/neg.h>
#include <drizzled/functions/numhybrid.h>
#include <drizzled/functions/num_op.h>
#include <drizzled/functions/num1.h>
#include <drizzled/functions/abs.h>
#include <drizzled/functions/plus.h>
#include <drizzled/functions/real.h>
#include <drizzled/functions/rollup_const.h>
#include <drizzled/functions/row_count.h>
#include <drizzled/functions/dec.h>
#include <drizzled/functions/int_val.h>
#include <drizzled/functions/acos.h>
#include <drizzled/functions/ascii.h>
#include <drizzled/functions/asin.h>
#include <drizzled/functions/atan.h>
#include <drizzled/functions/benchmark.h>
#include <drizzled/functions/char_length.h>
#include <drizzled/functions/ceiling.h>
#include <drizzled/functions/cos.h>
#include <drizzled/functions/exp.h>
#include <drizzled/functions/floor.h>
#include <drizzled/functions/last_insert.h>
#include <drizzled/functions/ln.h>
#include <drizzled/functions/log.h>
#include <drizzled/functions/units.h>
#include <drizzled/functions/ord.h>
#include <drizzled/functions/pow.h>
#include <drizzled/functions/rand.h>
#include <drizzled/functions/round.h>
#include <drizzled/functions/sin.h>
#include <drizzled/functions/sqrt.h>
#include <drizzled/functions/sign.h>
#include <drizzled/functions/signed.h>
#include <drizzled/functions/tan.h>
#include <drizzled/functions/unsigned.h>
/* Handling of user definable variables */
class user_var_entry;
class Item_func_set_user_var :public Item_func
{
enum Item_result cached_result_type;
user_var_entry *entry;
char buffer[MAX_FIELD_WIDTH];
String value;
my_decimal decimal_buff;
bool null_item;
union
{
int64_t vint;
double vreal;
String *vstr;
my_decimal *vdec;
} save_result;
public:
LEX_STRING name; // keep it public
Item_func_set_user_var(LEX_STRING a,Item *b)
:Item_func(b), cached_result_type(INT_RESULT), name(a)
{}
enum Functype functype() const { return SUSERVAR_FUNC; }
double val_real();
int64_t val_int();
String *val_str(String *str);
my_decimal *val_decimal(my_decimal *);
double val_result();
int64_t val_int_result();
String *str_result(String *str);
my_decimal *val_decimal_result(my_decimal *);
bool update_hash(void *ptr, uint32_t length, enum Item_result type,
const CHARSET_INFO * const cs, Derivation dv, bool unsigned_arg);
bool send(Protocol *protocol, String *str_arg);
void make_field(Send_field *tmp_field);
bool check(bool use_result_field);
bool update();
enum Item_result result_type () const { return cached_result_type; }
bool fix_fields(Session *session, Item **ref);
void fix_length_and_dec();
virtual void print(String *str, enum_query_type query_type);
void print_as_stmt(String *str, enum_query_type query_type);
const char *func_name() const { return "set_user_var"; }
int save_in_field(Field *field, bool no_conversions,
bool can_use_result_field);
int save_in_field(Field *field, bool no_conversions)
{
return save_in_field(field, no_conversions, 1);
}
void save_org_in_field(Field *field) { (void)save_in_field(field, 1, 0); }
bool register_field_in_read_map(unsigned char *arg);
bool register_field_in_bitmap(unsigned char *arg);
};
/*
This item represents user variable used as out parameter (e.g in LOAD DATA),
and it is supposed to be used only for this purprose. So it is simplified
a lot. Actually you should never obtain its value.
The only two reasons for this thing being an Item is possibility to store it
in List<Item> and desire to place this code somewhere near other functions
working with user variables.
*/
class Item_user_var_as_out_param :public Item
{
LEX_STRING name;
user_var_entry *entry;
public:
Item_user_var_as_out_param(LEX_STRING a) : name(a) {}
/* We should return something different from FIELD_ITEM here */
enum Type type() const { return STRING_ITEM;}
double val_real();
int64_t val_int();
String *val_str(String *str);
my_decimal *val_decimal(my_decimal *decimal_buffer);
/* fix_fields() binds variable name with its entry structure */
bool fix_fields(Session *session, Item **ref);
virtual void print(String *str, enum_query_type query_type);
void set_null_value(const CHARSET_INFO * const cs);
void set_value(const char *str, uint32_t length, const CHARSET_INFO * const cs);
};
/* For type casts */
enum Cast_target
{
ITEM_CAST_BINARY, ITEM_CAST_SIGNED_INT, ITEM_CAST_UNSIGNED_INT,
ITEM_CAST_DATE, ITEM_CAST_TIME, ITEM_CAST_DATETIME, ITEM_CAST_CHAR,
ITEM_CAST_DECIMAL
};
#endif /* DRIZZLE_SERVER_ITEM_FUNC_H */
|