#include "mysql_priv.h"Include dependency graph for my_decimal.cc:

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

Go to the source code of this file.
Defines | |
| #define | DIG_PER_DEC1 9 |
| #define | ROUND_UP(X) (((X)+DIG_PER_DEC1-1)/DIG_PER_DEC1) |
Functions | |
| int | decimal_operation_results (int result) |
| int | my_decimal2string (uint mask, const my_decimal *d, uint fixed_prec, uint fixed_dec, char filler, String *str) |
| int | my_decimal2binary (uint mask, const my_decimal *d, char *bin, int prec, int scale) |
| int | str2my_decimal (uint mask, const char *from, uint length, CHARSET_INFO *charset, my_decimal *decimal_value) |
| void | print_decimal (const my_decimal *dec) |
| void | print_decimal_buff (const my_decimal *dec, const byte *ptr, int length) |
| const char * | dbug_decimal_as_string (char *buff, const my_decimal *val) |
| #define DIG_PER_DEC1 9 |
Definition at line 196 of file my_decimal.cc.
| #define ROUND_UP | ( | X | ) | (((X)+DIG_PER_DEC1-1)/DIG_PER_DEC1) |
Definition at line 197 of file my_decimal.cc.
| const char* dbug_decimal_as_string | ( | char * | buff, | |
| const my_decimal * | val | |||
| ) |
Definition at line 230 of file my_decimal.cc.
Referenced by Field_new_decimal::store(), and Field_new_decimal::store_value().
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 caller graph for this function:

| int decimal_operation_results | ( | int | result | ) |
Definition at line 34 of file my_decimal.cc.
Referenced by check_result().
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 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.
Referenced by field_decimal::add(), make_sortkey(), Item_sum_avg::reset_field(), Item_sum_variance::reset_field(), Field_new_decimal::store_value(), Item_sum_avg::update_field(), and Item_sum_variance::update_field().
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 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.
Referenced by field_decimal::avg(), collect_decimal(), field_decimal::get_max_arg(), field_decimal::get_min_arg(), Item_decimal::print(), Item_param::query_val_str(), Field_longstr::store_decimal(), Protocol_prep::store_decimal(), Protocol_simple::store_decimal(), Item_sum_hybrid::val_str(), Item_func_format::val_str(), Item_func_min_max::val_str(), Item_decimal_typecast::val_str(), Item_func_numhybrid::val_str(), Item_cache_decimal::val_str(), Item_param::val_str(), Item_decimal::val_str(), Hybrid_type_traits_decimal::val_str(), and Item::val_string_from_decimal().
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 caller graph for this function:

| void print_decimal | ( | const my_decimal * | dec | ) |
Definition at line 201 of file my_decimal.cc.
Referenced by print_decimal_buff().
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 caller 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.
Referenced by Field_new_decimal::store_value(), and Field_new_decimal::val_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 caller 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.
Referenced by Item_decimal::Item_decimal(), Item_param::set_decimal(), Field_new_decimal::store(), Item_str_func::val_decimal(), Item_func_numhybrid::val_decimal(), Field_blob::val_decimal(), Field_varstring::val_decimal(), Field_string::val_decimal(), and Item::val_decimal_from_string().
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 caller graph for this function:

1.4.7

