diff options
author | monty@mysql.com <> | 2005-02-19 18:58:27 +0200 |
---|---|---|
committer | monty@mysql.com <> | 2005-02-19 18:58:27 +0200 |
commit | 218e00ac681c300ddfb59889d8b6dd7faa0e71f6 (patch) | |
tree | 45069dd14961944b02845ab6e42f1993666f63e8 /sql/my_decimal.cc | |
parent | 7bc48798fce1b4010adbd074aa18784fcf0eb07e (diff) | |
download | mariadb-git-218e00ac681c300ddfb59889d8b6dd7faa0e71f6.tar.gz |
Fixed BUILD script to use --with-berkeley-db instead of --with-bdb
Lots of small fixes to multi-precision-math path
Give Note for '123.4e'
Added helper functions type 'val_string_from_real()
Don't give warnings for end space for string2decimal()
Changed storage of values for SP so that we can detect length of argument without strlen()
Changed interface for str2dec() so that we must supple the pointer to the last character in the buffer
Diffstat (limited to 'sql/my_decimal.cc')
-rw-r--r-- | sql/my_decimal.cc | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc index f028b1fa1a1..94b473a8c36 100644 --- a/sql/my_decimal.cc +++ b/sql/my_decimal.cc @@ -13,6 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include "mysql_priv.h" #ifndef MYSQL_CLIENT @@ -154,10 +155,11 @@ int my_decimal2binary(uint mask, const my_decimal *d, byte *bin, int prec, E_DEC_BAD_NUM E_DEC_OOM */ + int str2my_decimal(uint mask, const char *from, uint length, CHARSET_INFO *charset, my_decimal *decimal_value) { - char *end; + char *end, *from_end; int err; char buff[STRING_BUFFER_USUAL_SIZE]; String tmp(buff, sizeof(buff), &my_charset_bin); @@ -169,10 +171,20 @@ int str2my_decimal(uint mask, const char *from, uint length, length= tmp.length(); charset= &my_charset_bin; } - my_decimal_set_zero(decimal_value); + from_end= end= (char*) from+length; err= string2decimal((char *)from, (decimal *)decimal_value, &end); - if ((uint) (end-from) != length && !err) - err= E_DEC_TRUNCATED; + if (end != from_end && !err) + { + /* Give warining if there is something other than end space */ + for ( ; end < from_end; end++) + { + if (!my_isspace(&my_charset_latin1, *end)) + { + err= E_DEC_TRUNCATED; + break; + } + } + } check_result(mask, err); return err; } @@ -200,12 +212,25 @@ print_decimal_buff(const my_decimal *dec, const byte* ptr, int length) { print_decimal(dec); fprintf(DBUG_FILE, "Record: "); - for(int i= 0; i < length; i++) + for (int i= 0; i < length; i++) { fprintf(DBUG_FILE, "%02X ", (uint)((uchar *)ptr)[i]); } fprintf(DBUG_FILE, "\n"); } + + +void dbug_print_decimal(const char *tag, const char *format, my_decimal *val) +{ + char buff[DECIMAL_MAX_STR_LENGTH]; + String str(buff, sizeof(buff), &my_charset_bin); + if (!val) + str.set("NULL", 4, &my_charset_bin); + else + my_decimal2string(0, val, 0, 0, 0, &str); + DBUG_PRINT(tag, (format, val)); +} + #endif |