diff options
author | Alexander Barkov <bar@mariadb.org> | 2015-09-17 11:05:07 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2015-09-17 11:05:07 +0400 |
commit | d9b25ae3db8584bde809c0ab3230cbe151fa489b (patch) | |
tree | cb0ae8c91d4f1bcd614c3c1b2d7847f3ef7a130f /sql/my_decimal.cc | |
parent | c69cf93bfb3a221d9106f3695aa16e11f7e8b7fb (diff) | |
download | mariadb-git-d9b25ae3db8584bde809c0ab3230cbe151fa489b.tar.gz |
MDEV-8466 CAST works differently for DECIMAL/INT vs DOUBLE for empty strings
MDEV-8468 CAST and INSERT work differently for DECIMAL/INT vs DOUBLE for a string with trailing spaces
Diffstat (limited to 'sql/my_decimal.cc')
-rw-r--r-- | sql/my_decimal.cc | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc index 5ec3fe7ff28..91455c7cb84 100644 --- a/sql/my_decimal.cc +++ b/sql/my_decimal.cc @@ -239,9 +239,9 @@ int my_decimal2binary(uint mask, const my_decimal *d, uchar *bin, int prec, */ int str2my_decimal(uint mask, const char *from, uint length, - CHARSET_INFO *charset, my_decimal *decimal_value) + CHARSET_INFO *charset, my_decimal *decimal_value, + const char **end_ptr) { - char *end, *from_end; int err; char buff[STRING_BUFFER_USUAL_SIZE]; String tmp(buff, sizeof(buff), &my_charset_bin); @@ -253,20 +253,11 @@ int str2my_decimal(uint mask, const char *from, uint length, length= tmp.length(); charset= &my_charset_bin; } - from_end= end= (char*) from+length; + char *end= (char*) from + length; err= string2decimal((char *)from, (decimal_t*) decimal_value, &end); - if (end != from_end && !err) - { - /* Give warning 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; - } - } - } + if (charset->mbminlen > 1) + end= (char *) from + charset->mbminlen * (size_t) (end - buff); + *end_ptr= end; check_result_and_overflow(mask, err, decimal_value); return err; } |