summaryrefslogtreecommitdiff
path: root/sql/item_xmlfunc.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-09-26 11:06:54 +0400
committerAlexander Barkov <bar@mariadb.com>2019-09-26 11:06:54 +0400
commit08de2540acc6a9e1aa24f26a18ac467ffc8284fd (patch)
tree947b36a6454aa327b4479fd2815b1abf12c07e89 /sql/item_xmlfunc.h
parenta340af922361e3958e5d6653c8b840771db282f2 (diff)
downloadmariadb-git-08de2540acc6a9e1aa24f26a18ac467ffc8284fd.tar.gz
MDEV-20674 Reuse val_native() in ExtractValue() and UpdateXML()
Diffstat (limited to 'sql/item_xmlfunc.h')
-rw-r--r--sql/item_xmlfunc.h40
1 files changed, 39 insertions, 1 deletions
diff --git a/sql/item_xmlfunc.h b/sql/item_xmlfunc.h
index ce34697d9bd..806739d1139 100644
--- a/sql/item_xmlfunc.h
+++ b/sql/item_xmlfunc.h
@@ -2,6 +2,7 @@
#define ITEM_XMLFUNC_INCLUDED
/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2009, 2019, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -23,6 +24,42 @@
typedef struct my_xml_node_st MY_XML_NODE;
+/* Structure to store nodeset elements */
+class MY_XPATH_FLT
+{
+public:
+ uint num; // Absolute position in MY_XML_NODE array
+ uint pos; // Relative position in context
+ uint size; // Context size
+public:
+ MY_XPATH_FLT(uint32 num_arg, uint32 pos_arg)
+ :num(num_arg), pos(pos_arg), size(0)
+ { }
+ MY_XPATH_FLT(uint32 num_arg, uint32 pos_arg, uint32 size_arg)
+ :num(num_arg), pos(pos_arg), size(size_arg)
+ { }
+ bool append_to(Native *to) const
+ {
+ return to->append((const char*) this, (uint32) sizeof(*this));
+ }
+};
+
+
+class NativeNodesetBuffer: public NativeBuffer<16*sizeof(MY_XPATH_FLT)>
+{
+public:
+ const MY_XPATH_FLT &element(uint i) const
+ {
+ const MY_XPATH_FLT *p= (MY_XPATH_FLT*) (ptr() + i * sizeof(MY_XPATH_FLT));
+ return *p;
+ }
+ uint32 elements() const
+ {
+ return length() / sizeof(MY_XPATH_FLT);
+ }
+};
+
+
class Item_xml_str_func: public Item_str_func
{
protected:
@@ -103,7 +140,8 @@ public:
class Item_func_xml_update: public Item_xml_str_func
{
- String tmp_value2, tmp_value3;
+ NativeNodesetBuffer tmp_native_value2;
+ String tmp_value3;
bool collect_result(String *str,
const MY_XML_NODE *cut,
const String *replace);