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
This commit is contained in:
Alexander Barkov
2015-09-17 11:05:07 +04:00
parent c69cf93bfb
commit d9b25ae3db
60 changed files with 2779 additions and 390 deletions

View File

@ -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;
}