17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
#include <drizzled/server_includes.h>
22
22
#include <drizzled/function/set_user_var.h>
23
23
#include <drizzled/field/num.h>
24
24
#include <drizzled/session.h>
25
25
#include <drizzled/plugin/client.h>
27
using namespace drizzled;
31
30
When a user variable is updated (in a SET command or a query like
141
140
switch (cached_result_type) {
142
141
case REAL_RESULT:
144
save_result.vreal= use_result_field ? result_field->val_real() :
143
save_result.vreal= use_result_field ? result_field->val_real() :
150
save_result.vint= use_result_field ? result_field->val_int() :
152
unsigned_flag= use_result_field ? ((Field_num*)result_field)->unsigned_flag:
153
args[0]->unsigned_flag;
149
save_result.vint= use_result_field ? result_field->val_int() :
151
unsigned_flag= use_result_field ? ((Field_num*)result_field)->unsigned_flag:
152
args[0]->unsigned_flag;
156
155
case STRING_RESULT:
158
save_result.vstr= use_result_field ? result_field->val_str_internal(&value) :
159
args[0]->val_str(&value);
157
save_result.vstr= use_result_field ? result_field->val_str(&value) :
158
args[0]->val_str(&value);
162
161
case DECIMAL_RESULT:
164
save_result.vdec= use_result_field ?
165
result_field->val_decimal(&decimal_buff) :
166
args[0]->val_decimal(&decimal_buff);
163
save_result.vdec= use_result_field ?
164
result_field->val_decimal(&decimal_buff) :
165
args[0]->val_decimal(&decimal_buff);
170
170
// This case should never be chosen
198
197
switch (cached_result_type) {
199
198
case REAL_RESULT:
201
res= update_hash((void*) &save_result.vreal,sizeof(save_result.vreal),
202
REAL_RESULT, &my_charset_bin, DERIVATION_IMPLICIT, 0);
200
res= update_hash((void*) &save_result.vreal,sizeof(save_result.vreal),
201
REAL_RESULT, &my_charset_bin, DERIVATION_IMPLICIT, 0);
208
res= update_hash((void*) &save_result.vint, sizeof(save_result.vint),
209
INT_RESULT, &my_charset_bin, DERIVATION_IMPLICIT,
206
res= update_hash((void*) &save_result.vint, sizeof(save_result.vint),
207
INT_RESULT, &my_charset_bin, DERIVATION_IMPLICIT,
214
211
case STRING_RESULT:
216
if (!save_result.vstr) // Null value
217
res= update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin,
218
DERIVATION_IMPLICIT, 0);
220
res= update_hash((void*) save_result.vstr->ptr(),
221
save_result.vstr->length(), STRING_RESULT,
222
save_result.vstr->charset(),
223
DERIVATION_IMPLICIT, 0);
213
if (!save_result.vstr) // Null value
214
res= update_hash((void*) 0, 0, STRING_RESULT, &my_charset_bin,
215
DERIVATION_IMPLICIT, 0);
217
res= update_hash((void*) save_result.vstr->ptr(),
218
save_result.vstr->length(), STRING_RESULT,
219
save_result.vstr->charset(),
220
DERIVATION_IMPLICIT, 0);
227
223
case DECIMAL_RESULT:
229
if (!save_result.vdec) // Null value
230
res= update_hash((void*) 0, 0, DECIMAL_RESULT, &my_charset_bin,
231
DERIVATION_IMPLICIT, 0);
233
res= update_hash((void*) save_result.vdec,
234
sizeof(type::Decimal), DECIMAL_RESULT,
235
&my_charset_bin, DERIVATION_IMPLICIT, 0);
225
if (!save_result.vdec) // Null value
226
res= update_hash((void*) 0, 0, DECIMAL_RESULT, &my_charset_bin,
227
DERIVATION_IMPLICIT, 0);
229
res= update_hash((void*) save_result.vdec,
230
sizeof(my_decimal), DECIMAL_RESULT,
231
&my_charset_bin, DERIVATION_IMPLICIT, 0);
240
236
// This case should never be chosen
320
315
str->append(')');
319
void Item_func_set_user_var::print_as_stmt(String *str,
320
enum_query_type query_type)
322
str->append(STRING_WITH_LEN("set @"));
323
str->append(name.str, name.length);
324
str->append(STRING_WITH_LEN(":="));
325
args[0]->print(str, query_type);
323
329
bool Item_func_set_user_var::send(plugin::Client *client, String *str_arg)
325
331
if (result_field)