[MDEV-9874] LOAD XML INFILE does not handle well broken multi-byte characters Created: 2016-04-06  Updated: 2016-11-29  Resolved: 2016-04-08

Status: Closed
Project: MariaDB Server
Component/s: Character Sets
Affects Version/s: 5.5, 10.0, 10.1, 10.2
Fix Version/s: 10.2.0

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-6353 my_ismbchar() and my_mbcharlen() refa... Closed

 Description   

I create an XML file with a broken utf8 byte sequence:

printf "<table><row><a>a\xD0</a></row></table>" >/tmp/test.xml

Notice, 0xD0 is a utf8 leading byte of a 2-byte character, but it is not followed by a tail byte.

Now I try to load this file into a table:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a TEXT CHARACTER SET utf8);
LOAD XML INFILE '/tmp/test.xml' INTO TABLE t1 CHARACTER SET utf8 ROWS IDENTIFIED BY '<row>';
SHOW WARNINGS;
SELECT * FROM t1;

It produces this warning:

+---------+------+------------------------------------------------------------+
| Level   | Code | Message                                                    |
+---------+------+------------------------------------------------------------+
| Warning | 1366 | Incorrect string value: '\xD0</a>' for column 'a' at row 1 |
+---------+------+------------------------------------------------------------+

and this result set:

+--------+
| a      |
+--------+
| a?</a> |
+--------+

This is wrong. The closing tag '</a>' was interpreted as data rather than markup.
The expected result would be to return 'a?' rather than 'a?</a>'.


Generated at Thu Feb 08 07:37:58 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.