The world's most popular open source database
#include <decimal.h>Include dependency graph for my_decimal.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
| #define DECIMAL_BUFF_LENGTH 9 |
Definition at line 39 of file my_decimal.h.
Referenced by my_decimal::init(), and in_decimal::set().
| #define DECIMAL_LONG3_DIGITS 8 |
Definition at line 36 of file my_decimal.h.
| #define DECIMAL_LONG_DIGITS 10 |
Definition at line 35 of file my_decimal.h.
| #define DECIMAL_LONGLONG_DIGITS 22 |
| #define DECIMAL_MAX_FIELD_SIZE DECIMAL_MAX_PRECISION |
Definition at line 58 of file my_decimal.h.
Referenced by field_decimal::add(), and User_var_log_event::write().
| #define DECIMAL_MAX_PRECISION ((DECIMAL_BUFF_LENGTH * 9) - 8*2) |
Definition at line 46 of file my_decimal.h.
Referenced by Item_func::count_decimal_length(), Item_func_case::decimal_precision(), Item_func_if::decimal_precision(), Item_func_ifnull::decimal_precision(), Item::decimal_precision(), Field_new_decimal::Field_new_decimal(), Item_sum_variance::fix_length_and_dec(), Item_sum_avg::fix_length_and_dec(), create_field::init(), Item_type_holder::join_types(), max_internal_decimal(), max_my_decimal(), my_decimal_precision_to_length(), Item_func_div::result_precision(), Item_func_mul::result_precision(), and Item_func_additive_op::result_precision().
| #define DECIMAL_MAX_SCALE 30 |
Definition at line 47 of file my_decimal.h.
Referenced by field_decimal::avg(), Item_func_round::decimal_op(), Field_new_decimal::Field_new_decimal(), Item_sum_variance::fix_length_and_dec(), Item_sum_avg::fix_length_and_dec(), Item_func_get_user_var::fix_length_and_dec(), Item_type_holder::join_types(), max_my_decimal(), Item_func_div::result_precision(), and Item_func_mul::result_precision().
| #define DECIMAL_MAX_STR_LENGTH (DECIMAL_MAX_PRECISION + 2) |
Definition at line 54 of file my_decimal.h.
Referenced by collect_decimal(), dbug_decimal_as_string(), Item_func_get_user_var::fix_length_and_dec(), Hybrid_type_traits_decimal::fix_length_and_dec(), Field_new_decimal::store(), Field_longstr::store_decimal(), Protocol_prep::store_decimal(), Protocol_simple::store_decimal(), and Field_new_decimal::store_value().
| #define DECIMAL_NOT_SPECIFIED 31 |
| int binary2my_decimal | ( | uint | mask, | |
| const char * | bin, | |||
| my_decimal * | d, | |||
| int | prec, | |||
| int | scale | |||
| ) | [inline] |
Definition at line 209 of file my_decimal.h.
References bin2decimal(), and check_result().
Referenced by collect_decimal(), Item_decimal::Item_decimal(), Item_sum_avg::update_field(), Item_sum_variance::update_field(), Item_variance_field::val_decimal(), Item_avg_field::val_decimal(), and Field_new_decimal::val_decimal().
00211 { 00212 return check_result(mask, bin2decimal((char *)bin, (decimal_t*) d, prec, 00213 scale)); 00214 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int check_result | ( | uint | mask, | |
| int | result | |||
| ) | [inline] |
Definition at line 142 of file my_decimal.h.
References decimal_operation_results().
Referenced by binary2my_decimal(), check_result_and_overflow(), int2my_decimal(), main(), my_decimal2binary(), my_decimal2int(), my_decimal2string(), my_decimal_ceiling(), my_decimal_floor(), my_decimal_round(), and run_query().
00143 { 00144 if (result & mask) 00145 decimal_operation_results(result); 00146 return result; 00147 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int check_result_and_overflow | ( | uint | mask, | |
| int | result, | |||
| my_decimal * | val | |||
| ) | [inline] |
Definition at line 149 of file my_decimal.h.
References check_result(), E_DEC_OVERFLOW, my_decimal::fix_buffer_pointer(), max_internal_decimal(), and my_decimal::sign().
Referenced by double2my_decimal(), my_decimal_add(), my_decimal_div(), my_decimal_mod(), my_decimal_mul(), my_decimal_sub(), and str2my_decimal().
00150 { 00151 if (check_result(mask, result) & E_DEC_OVERFLOW) 00152 { 00153 bool sign= val->sign(); 00154 val->fix_buffer_pointer(); 00155 max_internal_decimal(val); 00156 val->sign(sign); 00157 } 00158 return result; 00159 }
Here is the call graph for this function:

Here is the caller graph for this function:

| const char* dbug_decimal_as_string | ( | char * | buff, | |
| const my_decimal * | val | |||
| ) |
Definition at line 230 of file my_decimal.cc.
00231 { 00232 int length= DECIMAL_MAX_STR_LENGTH; 00233 if (!val) 00234 return "NULL"; 00235 (void)decimal2string((decimal_t*) val, buff, &length, 0,0,0); 00236 return buff; 00237 }
| int decimal_operation_results | ( | int | result | ) |
Definition at line 34 of file my_decimal.cc.
00035 { 00036 switch (result) { 00037 case E_DEC_OK: 00038 break; 00039 case E_DEC_TRUNCATED: 00040 push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, 00041 WARN_DATA_TRUNCATED, ER(WARN_DATA_TRUNCATED), 00042 "", (long)-1); 00043 break; 00044 case E_DEC_OVERFLOW: 00045 push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, 00046 ER_TRUNCATED_WRONG_VALUE, 00047 ER(ER_TRUNCATED_WRONG_VALUE), 00048 "DECIMAL", ""); 00049 break; 00050 case E_DEC_DIV_ZERO: 00051 push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, 00052 ER_DIVISION_BY_ZERO, ER(ER_DIVISION_BY_ZERO)); 00053 break; 00054 case E_DEC_BAD_NUM: 00055 push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, 00056 ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, 00057 ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD), 00058 "decimal", "", "", (long)-1); 00059 break; 00060 case E_DEC_OOM: 00061 my_error(ER_OUT_OF_RESOURCES, MYF(0)); 00062 break; 00063 default: 00064 DBUG_ASSERT(0); 00065 } 00066 return result; 00067 }
| int double2my_decimal | ( | uint | mask, | |
| double | val, | |||
| my_decimal * | d | |||
| ) | [inline] |
Definition at line 301 of file my_decimal.h.
References check_result_and_overflow(), and double2decimal().
Referenced by Item_decimal::Item_decimal(), Field_new_decimal::store(), Item_proc_real::val_decimal(), Item_std_field::val_decimal(), Item_sum_hybrid::val_decimal(), Item_func_numhybrid::val_decimal(), Item_real_func::val_decimal(), Item_cache_real::val_decimal(), Item_param::val_decimal(), Item_float::val_decimal(), Hybrid_type_traits::val_decimal(), Field_real::val_decimal(), and Item::val_decimal_from_real().
00302 { 00303 return check_result_and_overflow(mask, double2decimal(val, (decimal_t*)d), d); 00304 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int int2my_decimal | ( | uint | mask, | |
| longlong | i, | |||
| my_bool | unsigned_flag, | |||
| my_decimal * | d | |||
| ) | [inline] |
Definition at line 308 of file my_decimal.h.
References check_result(), longlong2decimal(), and ulonglong2decimal().
Referenced by field_decimal::avg(), Hybrid_type_traits_fast_decimal::div(), Hybrid_type_traits_decimal::div(), Item_decimal::Item_decimal(), field_decimal::std(), Field_new_decimal::store(), Item_proc_int::val_decimal(), Item_variance_field::val_decimal(), Item_avg_field::val_decimal(), Item_sum_hybrid::val_decimal(), Item_sum_variance::val_decimal(), Item_sum_avg::val_decimal(), Item_in_subselect::val_decimal(), Item_exists_subselect::val_decimal(), Item_func_numhybrid::val_decimal(), Item_func::val_decimal(), Hybrid_type_traits_integer::val_decimal(), Item_cache_int::val_decimal(), Item_hex_string::val_decimal(), Item_param::val_decimal(), Item_int::val_decimal(), Field_bit::val_decimal(), Field_str::val_decimal(), Field_num::val_decimal(), and Item::val_decimal_from_int().
00309 { 00310 return check_result(mask, (unsigned_flag ? 00311 ulonglong2decimal((ulonglong)i, d) : 00312 longlong2decimal(i, d))); 00313 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void max_internal_decimal | ( | my_decimal * | to | ) | [inline] |
Definition at line 137 of file my_decimal.h.
References DECIMAL_MAX_PRECISION, max_my_decimal(), and to.
Referenced by check_result_and_overflow().
00138 { 00139 max_my_decimal(to, DECIMAL_MAX_PRECISION, 0); 00140 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void max_my_decimal | ( | my_decimal * | to, | |
| int | precision, | |||
| int | frac | |||
| ) | [inline] |
Definition at line 130 of file my_decimal.h.
References DBUG_ASSERT, DECIMAL_MAX_PRECISION, DECIMAL_MAX_SCALE, max_decimal(), and to.
Referenced by max_internal_decimal(), Field_new_decimal::set_value_on_overflow(), and Item_decimal_typecast::val_decimal().
00131 { 00132 DBUG_ASSERT((precision <= DECIMAL_MAX_PRECISION)&& 00133 (frac <= DECIMAL_MAX_SCALE)); 00134 max_decimal(precision, frac, (decimal_t*) to); 00135 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int my_decimal2binary | ( | uint | mask, | |
| const my_decimal * | d, | |||
| char * | bin, | |||
| int | prec, | |||
| int | scale | |||
| ) |
Definition at line 120 of file my_decimal.cc.
00122 { 00123 int err1= E_DEC_OK, err2; 00124 my_decimal rounded; 00125 my_decimal2decimal(d, &rounded); 00126 rounded.frac= decimal_actual_fraction(&rounded); 00127 if (scale < rounded.frac) 00128 { 00129 err1= E_DEC_TRUNCATED; 00130 /* decimal_round can return only E_DEC_TRUNCATED */ 00131 decimal_round(&rounded, &rounded, scale, HALF_UP); 00132 } 00133 err2= decimal2bin(&rounded, bin, prec, scale); 00134 if (!err2) 00135 err2= err1; 00136 return check_result(mask, err2); 00137 }
| void my_decimal2decimal | ( | const my_decimal * | from, | |
| my_decimal * | to | |||
| ) | [inline] |
Definition at line 197 of file my_decimal.h.
Referenced by Item_sum_max::add(), Item_sum_min::add(), Cached_item_decimal::cmp(), Item_func_abs::decimal_op(), Item_func_neg::decimal_op(), Item_decimal::Item_decimal(), Item_sum_hybrid::Item_sum_hybrid(), Item_sum_sum::Item_sum_sum(), my_decimal2binary(), in_decimal::set(), Item_decimal::set_decimal_value(), Item_param::set_from_user_var(), Item_cache_decimal::store(), cmp_item_decimal::store_value(), and Item_func_min_max::val_decimal().
Here is the caller graph for this function:

| int my_decimal2double | ( | uint | mask, | |
| const my_decimal * | d, | |||
| double * | result | |||
| ) | [inline] |
Definition at line 274 of file my_decimal.h.
References decimal2double().
Referenced by field_decimal::std(), Field_new_decimal::store(), Field_real::store_decimal(), Field_str::store_decimal(), Item_std_field::val_decimal(), Item_func_interval::val_int(), Item_std_field::val_real(), Item_sum_hybrid::val_real(), Item_sum_sum::val_real(), Item_decimal_typecast::val_real(), Item_func_numhybrid::val_real(), Item_cache_decimal::val_real(), Item_param::val_real(), Item_decimal::val_real(), Hybrid_type_traits_decimal::val_real(), Field_new_decimal::val_real(), and Item::val_real_from_decimal().
00275 { 00276 /* No need to call check_result as this will always succeed */ 00277 return decimal2double((decimal_t*) d, result); 00278 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int my_decimal2int | ( | uint | mask, | |
| const my_decimal * | d, | |||
| my_bool | unsigned_flag, | |||
| longlong * | l | |||
| ) | [inline] |
Definition at line 261 of file my_decimal.h.
References check_result(), decimal2longlong(), decimal2ulonglong(), decimal_round(), and HALF_UP.
Referenced by Field::convert_decimal2longlong(), Item_func_floor::int_op(), Item_func_ceiling::int_op(), Item_sum_hybrid::val_int(), Item_sum_sum::val_int(), Item_decimal_typecast::val_int(), Item_func_numhybrid::val_int(), Item_cache_decimal::val_int(), Item_param::val_int(), Item_decimal::val_int(), Hybrid_type_traits_decimal::val_int(), Field_new_decimal::val_int(), and Item::val_int_from_decimal().
00263 { 00264 my_decimal rounded; 00265 /* decimal_round can return only E_DEC_TRUNCATED */ 00266 decimal_round((decimal_t*)d, &rounded, 0, HALF_UP); 00267 return check_result(mask, (unsigned_flag ? 00268 decimal2ulonglong(&rounded, (ulonglong *)l) : 00269 decimal2longlong(&rounded, l))); 00270 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int my_decimal2string | ( | uint | mask, | |
| const my_decimal * | d, | |||
| uint | fixed_prec, | |||
| uint | fixed_dec, | |||
| char | filler, | |||
| String * | str | |||
| ) |
Definition at line 83 of file my_decimal.cc.
00086 { 00087 int length= (fixed_prec ? (fixed_prec + 1) : my_decimal_string_length(d)); 00088 int result; 00089 if (str->alloc(length)) 00090 return check_result(mask, E_DEC_OOM); 00091 result= decimal2string((decimal_t*) d, (char*) str->ptr(), 00092 &length, (int)fixed_prec, fixed_dec, 00093 filler); 00094 str->length(length); 00095 return check_result(mask, result); 00096 }
| int my_decimal_add | ( | uint | mask, | |
| my_decimal * | res, | |||
| const my_decimal * | a, | |||
| const my_decimal * | b | |||
| ) | [inline] |
Definition at line 329 of file my_decimal.h.
References check_result_and_overflow(), and decimal_add().
Referenced by field_decimal::add(), Item_sum_variance::add(), Item_sum_sum::add(), Hybrid_type_traits_decimal::add(), Item_func_plus::decimal_op(), Item_sum_avg::update_field(), Item_sum_sum::update_field(), and Item_sum_variance::update_field().
00331 { 00332 return check_result_and_overflow(mask, 00333 decimal_add((decimal_t*)a,(decimal_t*)b,res), 00334 res); 00335 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int my_decimal_ceiling | ( | uint | mask, | |
| const my_decimal * | from, | |||
| my_decimal * | to | |||
| ) | [inline] |
Definition at line 249 of file my_decimal.h.
References CEILING, check_result(), decimal_round(), from, and to.
Referenced by Item_func_ceiling::decimal_op().
00250 { 00251 return check_result(mask, decimal_round((decimal_t*) from, to, 0, CEILING)); 00252 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int my_decimal_cmp | ( | const my_decimal * | a, |
| const my_decimal * |

