#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.
| #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 |
Definition at line 34 of file my_decimal.h.
| #define DECIMAL_MAX_FIELD_SIZE DECIMAL_MAX_PRECISION |
Definition at line 58 of file my_decimal.h.
| #define DECIMAL_MAX_PRECISION ((DECIMAL_BUFF_LENGTH * 9) - 8*2) |
Definition at line 46 of file my_decimal.h.
| #define DECIMAL_MAX_SCALE 30 |
Definition at line 47 of file my_decimal.h.
| #define DECIMAL_MAX_STR_LENGTH (DECIMAL_MAX_PRECISION + 2) |
Definition at line 54 of file my_decimal.h.
| #define DECIMAL_NOT_SPECIFIED 31 |
Definition at line 48 of file my_decimal.h.
| 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().
00211 { 00212 return check_result(mask, bin2decimal((char *)bin, (decimal_t*) d, prec, 00213 scale)); 00214 }
Here is the call 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().
00143 { 00144 if (result & mask) 00145 decimal_operation_results(result); 00146 return result; 00147 }
Here is the call 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().
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:

| const char* dbug_decimal_as_string | ( | char * | buff, | |
| const my_decimal * | val | |||
| ) |
Definition at line 230 of file my_decimal.cc.
References decimal2string(), and DECIMAL_MAX_STR_LENGTH.
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 }
Here is the call graph for this function:

| int decimal_operation_results | ( | int | result | ) |
Definition at line 34 of file my_decimal.cc.
References current_thd, DBUG_ASSERT, E_DEC_BAD_NUM, E_DEC_DIV_ZERO, E_DEC_OK, E_DEC_OOM, E_DEC_OVERFLOW, E_DEC_TRUNCATED, ER, ER_DIVISION_BY_ZERO, ER_OUT_OF_RESOURCES, ER_TRUNCATED_WRONG_VALUE, ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, my_error(), MYF, push_warning_printf(), WARN_DATA_TRUNCATED, MYSQL_ERROR::WARN_LEVEL_ERROR, and MYSQL_ERROR::WARN_LEVEL_WARN.
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 }
Here is the call graph for this function:

| 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().
00302 { 00303 return check_result_and_overflow(mask, double2decimal(val, (decimal_t*)d), d); 00304 }
Here is the call 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().
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:

| 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.
00138 { 00139 max_my_decimal(to, DECIMAL_MAX_PRECISION, 0); 00140 }
Here is the call 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.
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:

| int my_decimal2binary | ( | uint | mask, | |
| const my_decimal * | d, | |||
| char * | bin, | |||
| int | prec, | |||
| int | scale | |||
| ) |
Definition at line 120 of file my_decimal.cc.
References check_result(), decimal2bin(), decimal_actual_fraction(), decimal_round(), E_DEC_OK, E_DEC_TRUNCATED, st_decimal_t::frac, HALF_UP, and my_decimal2decimal().
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 }
Here is the call graph for this function:

| void my_decimal2decimal | ( | const my_decimal * | from, | |
| my_decimal * | to | |||
| ) | [inline] |
| int my_decimal2double | ( | uint | mask, | |
| const my_decimal * | d, | |||
| double * | result | |||
| ) | [inline] |
Definition at line 274 of file my_decimal.h.
References decimal2double().
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:

| 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.
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:

| 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.
References String::alloc(), check_result(), decimal2string(), E_DEC_OOM, int(), String::length(), my_decimal_string_length(), and String::ptr().
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 }
Here is the call graph for this function:

| 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().
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:

| 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.
00250 { 00251 return check_result(mask, decimal_round((decimal_t*) from, to, 0, CEILING)); 00252 }
Here is the call graph for this function:

| int my_decimal_cmp | ( | const my_decimal * | a, | |
| const my_decimal * | b | |||
| ) | [inline] |
Definition at line 381 of file my_decimal.h.
References decimal_cmp().
00382 { 00383 return decimal_cmp((decimal_t*) a, (decimal_t*) b); 00384 }
Here is the call graph for this function:

| int my_decimal_div | ( | uint | mask, | |
| my_decimal * | res, | |||
| const my_decimal * | a, | |||
| const my_decimal * | b, | |||
| int | div_scale_inc | |||
| ) | [inline] |
Definition at line 359 of file my_decimal.h.
References check_result_and_overflow(), and decimal_div().
00361 { 00362 return check_result_and_overflow(mask, 00363 decimal_div((decimal_t*)a,(decimal_t*)b,res, 00364 div_scale_inc), 00365 res); 00366 }
Here is the call graph for this function:

| int my_decimal_floor | ( | uint | mask, | |
| const my_decimal * | from, | |||
| my_decimal * | to | |||
| ) | [inline] |
Definition at line 242 of file my_decimal.h.
References check_result(), decimal_round(), FLOOR, from, and to.
00243 { 00244 return check_result(mask, decimal_round((decimal_t*) from, to, 0, FLOOR)); 00245 }
Here is the call graph for this function:

Definition at line 190 of file my_decimal.h.
References decimal_bin_size().
00191 { 00192 return decimal_bin_size((int)precision, (int)scale); 00193 }
Here is the call graph for this function:

Definition at line 71 of file my_decimal.h.
References DECIMAL_NOT_SPECIFIED.
00072 { 00073 return precision - ((decimals == DECIMAL_NOT_SPECIFIED) ? 0 : decimals); 00074 }
| int my_decimal_intg | ( | const my_decimal * | a | ) | [inline] |
Definition at line 388 of file my_decimal.h.
References decimal_intg().
00389 { 00390 return decimal_intg((decimal_t*) a); 00391 }
Here is the call graph for this function:

| bool my_decimal_is_zero | ( | const my_decimal * | decimal_value | ) | [inline] |
Definition at line 226 of file my_decimal.h.
References decimal_is_zero().
00227 { 00228 return decimal_is_zero((decimal_t*) decimal_value); 00229 }
Here is the call graph for this function:

Definition at line 161 of file my_decimal.h.
00163 { 00164 return (uint) (length - (scale>0 ? 1:0) - (unsigned_flag ? 0:1)); 00165 }
| int my_decimal_max_length | ( | const my_decimal * | d | ) | [inline] |
Definition at line 182 of file my_decimal.h.
References decimal_string_size.
00183 { 00184 /* -1 because we do not count \0 */ 00185 return decimal_string_size(d) - 1; 00186 }
| int my_decimal_mod | ( | uint | mask, | |
| my_decimal * | res, | |||
| const my_decimal * | a, | |||
| const my_decimal * | b | |||
| ) | [inline] |
Definition at line 370 of file my_decimal.h.
References check_result_and_overflow(), and decimal_mod().
00372 { 00373 return check_result_and_overflow(mask, 00374 decimal_mod((decimal_t*)a,(decimal_t*)b,res), 00375 res); 00376 }
Here is the call graph for this function:

| int my_decimal_mul | ( | uint | mask, | |
| my_decimal * | res, | |||
| const my_decimal * | a, | |||
| const my_decimal * | b | |||
| ) | [inline] |
Definition at line 349 of file my_decimal.h.
References check_result_and_overflow(), and decimal_mul().
00351 { 00352 return check_result_and_overflow(mask, 00353 decimal_mul((decimal_t*)a,(decimal_t*)b,res), 00354 res); 00355 }
Here is the call graph for this function:

| void my_decimal_neg | ( | decimal_t * | arg | ) | [inline] |
Definition at line 317 of file my_decimal.h.
References decimal_is_zero(), decimal_neg, and st_decimal_t::sign.
00318 { 00319 if (decimal_is_zero(arg)) 00320 { 00321 arg->sign= 0; 00322 return; 00323 } 00324 decimal_neg(arg); 00325 }
Here is the call graph for this function:

Definition at line 167 of file my_decimal.h.
References DECIMAL_MAX_PRECISION, and set_if_smaller.
00169 { 00170 set_if_smaller(precision, DECIMAL_MAX_PRECISION); 00171 return (uint32)(precision + (scale>0 ? 1:0) + (unsigned_flag ? 0:1)); 00172 }
| int my_decimal_round | ( | uint | mask, | |
| const my_decimal * | from, | |||
| int | scale, | |||
| bool | truncate, | |||
| my_decimal * | to | |||
| ) | [inline] |
Definition at line 233 of file my_decimal.h.
References check_result(), decimal_round(), from, HALF_UP, to, and TRUNCATE.
00235 { 00236 return check_result(mask, decimal_round((decimal_t*) from, to, scale, 00237 (truncate ? TRUNCATE : HALF_UP))); 00238 }
Here is the call graph for this function:

| int my_decimal_set_zero | ( | my_decimal * | d | ) | [inline] |
Definition at line 218 of file my_decimal.h.
References decimal_make_zero.
00219 { 00220 decimal_make_zero(((decimal_t*) d)); 00221 return 0; 00222 }
Definition at line 61 of file my_decimal.h.
References decimal_size().
00062 { 00063 /* 00064 Always allocate more space to allow library to put decimal point 00065 where it want 00066 */ 00067 return decimal_size(precision, scale) + 1; 00068 }
Here is the call graph for this function:

| int my_decimal_string_length | ( | const my_decimal * | d | ) | [inline] |
Definition at line 175 of file my_decimal.h.
References decimal_string_size.
00176 { 00177 return decimal_string_size(d); 00178 }
| int my_decimal_sub | ( | uint | mask, | |
| my_decimal * | res, | |||
| const my_decimal * | a, | |||
| const my_decimal * | b | |||
| ) | [inline] |
Definition at line 339 of file my_decimal.h.
References check_result_and_overflow(), and decimal_sub().
00341 { 00342 return check_result_and_overflow(mask, 00343 decimal_sub((decimal_t*)a,(decimal_t*)b,res), 00344 res); 00345 }
Here is the call graph for this function:

| void print_decimal | ( | const my_decimal * | dec | ) |
Definition at line 201 of file my_decimal.cc.
References st_decimal_t::buf, DBUG_FILE, st_decimal_t::frac, st_decimal_t::intg, my_sprintf, pos(), ROUND_UP, and my_decimal::sign().
00202 { 00203 int i, end; 00204 char buff[512], *pos; 00205 pos= buff; 00206 pos+= my_sprintf(buff, (buff, "Decimal: sign: %d intg: %d frac: %d { ", 00207 dec->sign(), dec->intg, dec->frac)); 00208 end= ROUND_UP(dec->frac)+ROUND_UP(dec->intg)-1; 00209 for (i=0; i < end; i++) 00210 pos+= my_sprintf(pos, (pos, "%09d, ", dec->buf[i])); 00211 pos+= my_sprintf(pos, (pos, "%09d }\n", dec->buf[i])); 00212 fputs(buff, DBUG_FILE); 00213 }
Here is the call graph for this function:

| void print_decimal_buff | ( | const my_decimal * | dec, | |
| const byte * | ptr, | |||
| int | length | |||
| ) |
Definition at line 218 of file my_decimal.cc.
References DBUG_FILE, and print_decimal().
00219 { 00220 print_decimal(dec); 00221 fprintf(DBUG_FILE, "Record: "); 00222 for (int i= 0; i < length; i++) 00223 { 00224 fprintf(DBUG_FILE, "%02X ", (uint)((uchar *)ptr)[i]); 00225 } 00226 fprintf(DBUG_FILE, "\n"); 00227 }
Here is the call graph for this function:

| int str2my_decimal | ( | uint | mask, | |
| const char * | from, | |||
| uint | length, | |||
| CHARSET_INFO * | charset, | |||
| my_decimal * | decimal_value | |||
| ) |
Definition at line 159 of file my_decimal.cc.
References charset, check_result_and_overflow(), String::copy(), E_DEC_TRUNCATED, err, String::length(), my_charset_bin, my_charset_latin1, my_isspace, String::ptr(), string2decimal, and STRING_BUFFER_USUAL_SIZE.
00161 { 00162 char *end, *from_end; 00163 int err; 00164 char buff[STRING_BUFFER_USUAL_SIZE]; 00165 String tmp(buff, sizeof(buff), &my_charset_bin); 00166 if (charset->mbminlen > 1) 00167 { 00168 uint dummy_errors; 00169 tmp.copy(from, length, charset, &my_charset_latin1, &dummy_errors); 00170 from= tmp.ptr(); 00171 length= tmp.length(); 00172 charset= &my_charset_bin; 00173 } 00174 from_end= end= (char*) from+length; 00175 err= string2decimal((char *)from, (decimal_t*) decimal_value, &end); 00176 if (end != from_end && !err) 00177 { 00178 /* Give warning if there is something other than end space */ 00179 for ( ; end < from_end; end++) 00180 { 00181 if (!my_isspace(&my_charset_latin1, *end)) 00182 { 00183 err= E_DEC_TRUNCATED; 00184 break; 00185 } 00186 } 00187 } 00188 check_result_and_overflow(mask, err, decimal_value); 00189 return err; 00190 }
Here is the call graph for this function:

| int str2my_decimal | ( | uint | mask, | |
| const char * | str, | |||
| my_decimal * | d, | |||
| char ** | end | |||
| ) | [inline] |
Definition at line 282 of file my_decimal.h.
References check_result_and_overflow(), and string2decimal.
00283 { 00284 return check_result_and_overflow(mask, string2decimal(str,(decimal_t*)d,end), 00285 d); 00286 }
Here is the call graph for this function:

1.4.7

