150
150
return copy_or_same(thd);
153
double Item_func_abs::real_op()
155
double value= args[0]->val_real();
156
null_value= args[0]->null_value;
161
int64_t Item_func_abs::int_op()
163
int64_t value= args[0]->val_int();
164
if ((null_value= args[0]->null_value))
166
return (value >= 0) || unsigned_flag ? value : -value;
170
my_decimal *Item_func_abs::decimal_op(my_decimal *decimal_value)
172
my_decimal val, *value= args[0]->val_decimal(&val);
173
if (!(null_value= args[0]->null_value))
175
my_decimal2decimal(value, decimal_value);
176
if (decimal_value->sign())
177
my_decimal_neg(decimal_value);
178
return decimal_value;
184
void Item_func_abs::fix_length_and_dec()
186
Item_func_num1::fix_length_and_dec();
187
unsigned_flag= args[0]->unsigned_flag;
191
/** Gateway to natural LOG function. */
192
double Item_func_ln::val_real()
195
double value= args[0]->val_real();
196
if ((null_value= args[0]->null_value))
200
signal_divide_by_null();
207
Extended but so slower LOG function.
209
We have to check if all values are > zero and first one is not one
210
as these are the cases then result is not a number.
212
double Item_func_log::val_real()
215
double value= args[0]->val_real();
216
if ((null_value= args[0]->null_value))
220
signal_divide_by_null();
225
double value2= args[1]->val_real();
226
if ((null_value= args[1]->null_value))
228
if (value2 <= 0.0 || value == 1.0)
230
signal_divide_by_null();
233
return log(value2) / log(value);
238
double Item_func_log2::val_real()
241
double value= args[0]->val_real();
243
if ((null_value=args[0]->null_value))
247
signal_divide_by_null();
250
return log(value) / M_LN2;
253
double Item_func_log10::val_real()
256
double value= args[0]->val_real();
257
if ((null_value= args[0]->null_value))
261
signal_divide_by_null();
267
double Item_func_exp::val_real()
270
double value= args[0]->val_real();
271
if ((null_value=args[0]->null_value))
272
return 0.0; /* purecov: inspected */
273
return fix_result(exp(value));
276
153
double Item_func_sqrt::val_real()
278
155
assert(fixed == 1);