22#include <drizzled/function/math/divide.h>
23#include <drizzled/session.h>
24#include <drizzled/system_variables.h>
35 double value= args[0]->val_real();
36 double val2= args[1]->val_real();
41 signal_divide_by_null();
44 return fix_result(value/val2);
54 val1= args[0]->val_decimal(&value1);
57 val2= args[1]->val_decimal(&value2);
60 if ((err= class_decimal_div(E_DEC_FATAL_ERROR & ~E_DEC_DIV_ZERO, decimal_value,
61 val1, val2, prec_increment)) > 3)
63 if (err == E_DEC_DIV_ZERO)
64 signal_divide_by_null();
72void Item_func_div::result_precision()
74 uint32_t precision= min(args[0]->decimal_precision() + prec_increment,
75 (
unsigned int)DECIMAL_MAX_PRECISION);
77 if (result_type() == INT_RESULT)
78 unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
80 unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
82 decimals= min(args[0]->decimals + prec_increment, (
unsigned int)DECIMAL_MAX_SCALE);
83 max_length= class_decimal_precision_to_length(precision, decimals,
88void Item_func_div::fix_length_and_dec()
90 prec_increment= session->
variables.div_precincrement;
91 Item_num_op::fix_length_and_dec();
97 decimals= max(args[0]->decimals,args[1]->decimals)+prec_increment;
98 set_if_smaller(decimals, NOT_FIXED_DEC);
99 max_length= args[0]->max_length - args[0]->decimals + decimals;
100 uint32_t tmp= float_length(decimals);
101 set_if_smaller(max_length,tmp);
105 hybrid_type= DECIMAL_RESULT;
double real_op()
Performs the operation that this functions implements when the result type is REAL.
type::Decimal * decimal_op(type::Decimal *)
Performs the operation that this functions implements when the result type is DECIMAL.
drizzle_system_variables & variables
TODO: Rename this file - func.h is stupid.