From 29c2a655327569f913545491ea63c04e13223612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=A8=E8=B6=85?= Date: Mon, 14 Oct 2024 15:59:00 +0800 Subject: [PATCH] bug-115707 Change the LOAD XML processor to choose the matched column names to elements by the depth that they are away from the tag from ROWS IDENTIFIED BY, such that those at the same level are chosen if present, then down through the nested XML. --- sql/sql_load.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sql/sql_load.cc b/sql/sql_load.cc index e27dcabe432b..ee5f06ee1414 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -1658,6 +1658,17 @@ bool Sql_cmd_load_table::read_xml_field(THD *thd, COPY_INFO &info, while (tag && strcmp(tag->field.c_ptr(), item->item_name.ptr()) != 0) tag = xmlit++; + if (tag) { // bug-115707 use lower level tag + XML_TAG *tmp = xmlit++; + while (tmp) { + if (strcmp(tmp->field.c_ptr(), item->item_name.ptr()) == 0 && + tmp->level < tag->level) { + tag = tmp; + } + tmp = xmlit++; + } + } + item = item->real_item(); if (!tag) // found null