Bug #73382 load xml infile only reads first inline tag: <tag .../> <tag2 .../>

Submitted: 24 Jul 2014 22:47 Modified: 25 Jul 2014 19:30
Reporter: Mike Stevens Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: XML functions Severity:S3 (Non-critical)
Version:5.6.19, 5.5.39, 5.6.21, 5.7.5 OS:MacOS (Maverick)
Assigned to: CPU Architecture:Any

[24 Jul 2014 22:47] Mike Stevens
Description:
Load xml infile reads only first of  inline <tag .../> series data.

How to repeat:
-- xml file: --------------------
<?xml version="1.0"?>
<home>
  <tag1 attr1="1"/>
  <tag2 attr2="2"/>
</home>
-- xml file: --------------------

-- sql cmds: --------------------
create table if not exists home_tag1 (attr1 smallint);
create table if not exists home_tag2 (attr2 smallint);

load xml local infile 'home.xml'
into table home_tag1
rows identified by '<tag1>';

load xml local infile 'home.xml'
into table home_tag2
rows identified by '<tag2>';
-- sql cmds: --------------------

-- results: ---------------------
mysql> create table if not exists home_tag1 (attr1 smallint);
Query OK, 0 rows affected (0.01 sec)

mysql> create table if not exists home_tag2 (attr2 smallint);
Query OK, 0 rows affected (0.01 sec)

mysql> 
mysql> 
mysql> load xml local infile 'home.xml'
    -> into table home_tag1
    -> rows identified by '<tag1>';
Query OK, 1 row affected (0.00 sec)
Records: 1  Deleted: 0  Skipped: 0  Warnings: 0

mysql> 
mysql> 
mysql> load xml local infile 'home.xml'
    -> into table home_tag2
    -> rows identified by '<tag2>';
Query OK, 0 rows affected (0.00 sec)
Records: 0  Deleted: 0  Skipped: 0  Warnings: 0
-- results: ---------------------

Suggested fix:
Current workaround is altering the xml source data to comment or remove <tag1 ../> after reading it.  Only after the first tag is removed can the second be read. 

<?xml version="1.0"?>
<home>
  <!--tag1 attr1="1"/-->
  <tag2 attr2="2"/>
</home>

-- results ---
mysql> load xml local infile 'home.xml'
    -> into table home_tag2
    -> rows identified by '<tag2>';
Query OK, 1 row affected (0.00 sec)
Records: 1  Deleted: 0  Skipped: 0  Warnings: 0
[25 Jul 2014 19:30] Sveta Smirnova
Thank you for the report.

Verified as described.
[25 Jul 2014 19:31] Sveta Smirnova
test case for MTR

Attachment: bug73382.test (application/octet-stream, text), 695 bytes.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.050 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.