Bug #87100 | "Incorrect string value" is diplayed instead of "Data too long" sometimes. | ||
---|---|---|---|
Submitted: | 17 Jul 2017 20:13 | Modified: | 9 Jul 2018 19:21 |
Reporter: | Taku Amano (OCA) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Errors | Severity: | S3 (Non-critical) |
Version: | 5.7.17, 8.0, 5.7.18 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[17 Jul 2017 20:13]
Taku Amano
[18 Jul 2017 7:59]
MySQL Verification Team
Hello Taku AMANO, Thank you for the report and test case. Thanks, Umesh
[18 Jul 2017 8:01]
MySQL Verification Team
In order to submit contributions you must first sign the Oracle Contribution Agreement (OCA). For additional information please check http://www.oracle.com/technetwork/community/oca-486395.html. If you have any questions, please contact the MySQL community team - https://www.mysql.com/about/contact/?topic=community.
[18 Jul 2017 23:50]
Taku Amano
Revised version of suggested fix.
Attachment: check-extra-well-formed-char.patch (application/octet-stream, text), 3.21 KiB.
[18 Jul 2017 23:53]
Taku Amano
Thank you for reviewing. I have submitted a document of OCA at yesterday. (And not yet accepted) I have revised a suggested fix. check-extra-well-formed-char.patch Skipping extra check for real incorrect string, by this patch. Difference from first version to this patch. ``` diff --git a/sql-common/sql_string.cc b/sql-common/sql_string.cc index a4d4ddf2b3a..f64daf88cbc 100644 --- a/sql-common/sql_string.cc +++ b/sql-common/sql_string.cc @@ -1008,6 +1008,7 @@ size_t well_formed_copy_nchars(const CHARSET_INFO *to_cs, { int well_formed_error; uint from_offset; + size_t min_length; if ((from_offset= (from_length % to_cs->mbminlen)) && (from_cs == &my_charset_bin)) @@ -1045,24 +1046,25 @@ size_t well_formed_copy_nchars(const CHARSET_INFO *to_cs, to_length-= to_cs->mbminlen; } + min_length = min(from_length, to_length); res= to_cs->cset->well_formed_len(to_cs, - from, from + min(from_length, to_length), + from, from + min_length, nchars, &well_formed_error); if (res > 0) memmove(to, from, res); *from_end_pos= from + res; - if (well_formed_error) { + if (well_formed_error && + (min_length - res < to_cs->mbmaxlen)) + { const char *from_end= from + min(res + to_cs->mbmaxlen, from_length); size_t extra; extra= to_cs->cset->well_formed_len(to_cs, - from + res, from_end, + *from_end_pos, from_end, 1, &well_formed_error); - *well_formed_error_pos= extra == 0 ? from + res : NULL; - } - else { - *well_formed_error_pos= NULL; + well_formed_error= extra >= 1 ? 0 : 1; } + *well_formed_error_pos= well_formed_error ? *from_end_pos : NULL; *cannot_convert_error_pos= NULL; if (from_offset) res+= to_cs->mbminlen; ```
[1 Aug 2017 9:06]
Taku Amano
Revised version of suggested fix. (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: check-extra-well-formed-char.patch (application/octet-stream, text), 3.21 KiB.
[23 Aug 2017 4:14]
Taku Amano
Hello Umesh, Do I need to take any action? Regards, Taku AMANO
[9 Jul 2018 19:21]
Paul DuBois
Posted by developer: Fixed in 8.0.13. In some cases when ER_DATA_TOO_LONG was the appropriate error, ER_TRUNCATED_WRONG_VALUE_FOR_FIELD was reported instead.