154
String *Item_decimal_typecast::val_str(String *str)
156
my_decimal tmp_buf, *tmp= val_decimal(&tmp_buf);
159
my_decimal2string(E_DEC_FATAL_ERROR, tmp, 0, 0, 0, str);
164
double Item_decimal_typecast::val_real()
166
my_decimal tmp_buf, *tmp= val_decimal(&tmp_buf);
170
my_decimal2double(E_DEC_FATAL_ERROR, tmp, &res);
175
int64_t Item_decimal_typecast::val_int()
177
my_decimal tmp_buf, *tmp= val_decimal(&tmp_buf);
181
my_decimal2int(E_DEC_FATAL_ERROR, tmp, unsigned_flag, &res);
186
my_decimal *Item_decimal_typecast::val_decimal(my_decimal *dec)
188
my_decimal tmp_buf, *tmp= args[0]->val_decimal(&tmp_buf);
192
if ((null_value= args[0]->null_value))
194
my_decimal_round(E_DEC_FATAL_ERROR, tmp, decimals, false, dec);
200
my_decimal_set_zero(dec);
204
precision= my_decimal_length_to_precision(max_length,
205
decimals, unsigned_flag);
206
if (precision - decimals < (uint) my_decimal_intg(dec))
208
max_my_decimal(dec, precision, decimals);
215
push_warning_printf(current_thd, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
216
ER_WARN_DATA_OUT_OF_RANGE,
217
ER(ER_WARN_DATA_OUT_OF_RANGE),
223
void Item_decimal_typecast::print(String *str, enum_query_type query_type)
225
char len_buf[20*3 + 1];
228
uint32_t precision= my_decimal_length_to_precision(max_length, decimals,
230
str->append(STRING_WITH_LEN("cast("));
231
args[0]->print(str, query_type);
232
str->append(STRING_WITH_LEN(" as decimal("));
234
end=int10_to_str(precision, len_buf,10);
235
str->append(len_buf, (uint32_t) (end - len_buf));
239
end=int10_to_str(decimals, len_buf,10);
240
str->append(len_buf, (uint32_t) (end - len_buf));
247
154
double Item_func_plus::real_op()
249
156
double value= args[0]->val_real() + args[1]->val_real();