Skip to content
/ server Public

Commit e367470

Browse files
author
Alexey Botchkov
committed
MDEV-38688 UpdateXML should retuln xmltype.
type_handler changed for the UpdateXML.
1 parent bd19453 commit e367470

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

plugin/type_xmltype/mysql-test/type_xmltype/type_xmltype.result

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,11 @@ CREATE SEQUENCE s;
219219
CREATE TABLE t ( a XMLTYPE DEFAULT NEXTVAL(s));
220220
ERROR HY000: Cannot cast 'bigint' as 'xmltype' in assignment of `test`.`t`.`a`
221221
DROP SEQUENCE s;
222+
CREATE TABLE t1 AS SELECT UpdateXML('<a><b>ccc</b><d></d></a>', '/a', '<e>fff</e>') as x;
223+
SHOW CREATE TABLE t1;
224+
Table Create Table
225+
t1 CREATE TABLE `t1` (
226+
`x` xmltype CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL
227+
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
228+
DROP TABLE t1;
222229
# End of 11.8 tests

plugin/type_xmltype/mysql-test/type_xmltype/type_xmltype.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,9 @@ CREATE SEQUENCE s;
151151
CREATE TABLE t ( a XMLTYPE DEFAULT NEXTVAL(s));
152152
DROP SEQUENCE s;
153153

154+
CREATE TABLE t1 AS SELECT UpdateXML('<a><b>ccc</b><d></d></a>', '/a', '<e>fff</e>') as x;
155+
SHOW CREATE TABLE t1;
156+
DROP TABLE t1;
157+
154158
--echo # End of 11.8 tests
155159

sql/item_xmlfunc.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3072,6 +3072,26 @@ String *Item_func_xml_extractvalue::val_str(String *str)
30723072
}
30733073

30743074

3075+
const Type_handler *Item_func_xml_update::xml_handler= NULL;
3076+
3077+
3078+
bool Item_func_xml_update::fix_length_and_dec(THD *thd)
3079+
{
3080+
static LEX_CSTRING name= {STRING_WITH_LEN("XMLTYPE")};
3081+
3082+
if (!xml_handler)
3083+
xml_handler= Type_handler::handler_by_name(thd, name);
3084+
3085+
return Item_xml_str_func::fix_length_and_dec(thd);
3086+
}
3087+
3088+
3089+
const Type_handler *Item_func_xml_update::type_handler() const
3090+
{
3091+
return xml_handler ? xml_handler : Item_xml_str_func::type_handler();
3092+
}
3093+
3094+
30753095
bool Item_func_xml_update::collect_result(String *str,
30763096
const MY_XML_NODE *cut,
30773097
const String *replace)

sql/item_xmlfunc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ class Item_func_xml_update: public Item_xml_str_func
157157
static LEX_CSTRING name= {STRING_WITH_LEN("updatexml") };
158158
return name;
159159
}
160+
static const Type_handler *xml_handler;
161+
const Type_handler *type_handler() const override;
162+
bool fix_length_and_dec(THD *thd) override;
163+
160164
String *val_str(String *) override;
161165
Item *do_get_copy(THD *thd) const override
162166
{ return get_item_copy<Item_func_xml_update>(thd, this); }

0 commit comments

Comments
 (0)