Bug #86898 | Suboptimal String::append() usage in JSON processing | ||
---|---|---|---|
Submitted: | 2 Jul 2017 14:33 | Modified: | 5 Jul 2017 14:47 |
Reporter: | Alexey Kopytov | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: JSON | Severity: | S3 (Non-critical) |
Version: | 5.7, 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[2 Jul 2017 14:33]
Alexey Kopytov
[3 Jul 2017 14:57]
OCA Admin
Contribution submitted via Github - Bug #86898: Suboptimal String::append() usage in JSON processing (*) Contribution by Alexey Kopytov (Github akopytov, mysql-server/pull/153#issuecomment-312630209): I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: git_patch_128523160.txt (text/plain), 2.57 KiB.
[4 Jul 2017 8:44]
Knut Anders Hatlen
Thanks for the patch, Alexey! I'll try to get it incorporated into the code.
[4 Jul 2017 18:35]
Knut Anders Hatlen
Posted by developer: The contributed patch also partially fixes Bug#25977595 - JSON OUTPUT DOES NOT QUOTE ASCII 31. select cast(cast(cast('"\\u001f"' as json) as char) as json) now works without raising a parse error in non-debug builds. In debug builds this query now hits an assertion. I'll add a test case and fix the assertion.
[5 Jul 2017 14:47]
Jon Stephens
Documented fix in the MySQL 8.0.3 changelog as follows: Creating a representation of a JSON string now optimizes for the common case, that the string contains no special characters that need to be escaped, scanning for the first special character in the string, and copying each sequence of characters which do not require escaping in a single memcpy() call, rather than checking each character and then copying it one by one, as was done previously. This fix also corrects failure to escape the special character 1F (Unit Separator). Closed.
[6 Oct 2017 15:17]
Jon Stephens
Also fixed in MySQL 5.7.21, documentation as above. See also BUG#87722.
[8 Oct 2017 16:22]
Knut Anders Hatlen
Just to clarify: Only the part of the patch that fixes bug#87722 has been backported to 5.7. The part that improves the performance has not yet been backported to 5.7.