Commit 08de2540 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-20674 Reuse val_native() in ExtractValue() and UpdateXML()

parent a340af92
......@@ -1467,7 +1467,6 @@ class Item: public Value_source,
{
return type_handler()->Item_val_bool(this);
}
virtual String *val_raw(String*) { return 0; }
bool eval_const_cond()
{
......
This diff is collapsed.
......@@ -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 @@ class Item_func_xml_extractvalue: public Item_xml_str_func
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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment