MySQL 8.0.29
Source Code Documentation
item_xmlfunc.h
Go to the documentation of this file.
1#ifndef ITEM_XMLFUNC_INCLUDED
2#define ITEM_XMLFUNC_INCLUDED
3
4/* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2.0,
8 as published by the Free Software Foundation.
9
10 This program is also distributed with certain software (including
11 but not limited to OpenSSL) that is licensed under separate terms,
12 as designated in a particular file or component or in included license
13 documentation. The authors of MySQL hereby grant you an additional
14 permission to link the program and your derivative works with the
15 separately licensed software that they have included with MySQL.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License, version 2.0, for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25
26#include <sys/types.h> // uint
27
28#include <vector>
29
30#include "my_inttypes.h"
31#include "my_xml.h" // my_xml_node_type
32#include "sql/item.h" // Check_function_as_value_generator_parameters
33#include "sql/item_strfunc.h" // Item_str_func
34#include "sql/parse_location.h" // POS
35#include "sql_string.h"
36#include "template_utils.h" // pointer_cast
37
38class THD;
39
40/* This file defines all XML functions */
41
42/* Structure to store a parsed XML tree */
44 uint level; /* level in XML tree, 0 means root node */
45 enum my_xml_node_type type; /* node type: node, or attribute, or text */
46 uint parent; /* link to the parent */
47 const char *beg; /* beginning of the name or text */
48 const char *end; /* end of the name or text */
49 const char *tagend; /* where this tag ends */
50};
51
52using ParsedXML = std::vector<MY_XML_NODE>;
53
55 protected:
57 Item *nodeset_func{nullptr};
58 /// True if nodeset_func assigned during resolving
61
62 public:
65 set_nullable(true);
66 }
67 Item_xml_str_func(const POS &pos, Item *a, Item *b, Item *c)
69 set_nullable(true);
70 }
71 bool resolve_type(THD *thd) override;
72 void cleanup() override {
75 }
76 bool check_function_as_value_generator(uchar *) override { return false; }
77
78 protected:
79 /**
80 Parse the specified XPATH expression and initialize @c nodeset_func.
81
82 @note This is normally called in resolve phase since we only support
83 constant XPATH expressions, but it may be called upon execution when
84 const value is not yet known at resolve time.
85
86 @param xpath_expr XPATH expression to be parsed
87
88 @returns false on success, true on error
89 */
90 bool parse_xpath(Item *xpath_expr);
91};
92
95
96 public:
98 : Item_xml_str_func(pos, a, b) {}
99 const char *func_name() const override { return "extractvalue"; }
100 String *val_str(String *) override;
101};
102
105
106 public:
108 : Item_xml_str_func(pos, a, b, c) {}
109 const char *func_name() const override { return "updatexml"; }
110 String *val_str(String *) override;
111 bool check_function_as_value_generator(uchar *checker_args) override {
112 auto *func_arg =
113 pointer_cast<Check_function_as_value_generator_parameters *>(
114 checker_args);
115 func_arg->banned_function_name = func_name();
116 return true;
117 }
118};
119
120#endif /* ITEM_XMLFUNC_INCLUDED */
Definition: item_xmlfunc.h:93
String tmp_value
Definition: item_xmlfunc.h:94
const char * func_name() const override
Definition: item_xmlfunc.h:99
String * val_str(String *) override
Definition: item_xmlfunc.cc:2482
Item_func_xml_extractvalue(const POS &pos, Item *a, Item *b)
Definition: item_xmlfunc.h:97
Definition: item_xmlfunc.h:103
bool check_function_as_value_generator(uchar *checker_args) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_xmlfunc.h:111
Item_func_xml_update(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_xmlfunc.h:107
const char * func_name() const override
Definition: item_xmlfunc.h:109
String * val_str(String *) override
Definition: item_xmlfunc.cc:2500
String tmp_value
Definition: item_xmlfunc.h:104
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item.cc:10495
Definition: item_strfunc.h:75
Definition: item_xmlfunc.h:54
bool resolve_type(THD *thd) override
Resolve type-related information for this item, such as result field type, maximum size,...
Definition: item_xmlfunc.cc:2283
Item * nodeset_func
Definition: item_xmlfunc.h:57
bool check_function_as_value_generator(uchar *) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_xmlfunc.h:76
bool nodeset_func_permanent
True if nodeset_func assigned during resolving.
Definition: item_xmlfunc.h:59
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_xmlfunc.h:72
Item_xml_str_func(const POS &pos, Item *a, Item *b, Item *c)
Definition: item_xmlfunc.h:67
Item_xml_str_func(const POS &pos, Item *a, Item *b)
Definition: item_xmlfunc.h:63
ParsedXML pxml
Definition: item_xmlfunc.h:56
String xpath_tmp_value
Definition: item_xmlfunc.h:60
bool parse_xpath(Item *xpath_expr)
Parse the specified XPATH expression and initialize nodeset_func.
Definition: item_xmlfunc.cc:2311
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:802
void set_nullable(bool nullable)
Definition: item.h:3344
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:166
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:945
char * pos
Definition: do_ctype.cc:76
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
std::vector< MY_XML_NODE > ParsedXML
Definition: item_xmlfunc.h:52
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:51
my_xml_node_type
Definition: my_xml.h:50
Our own string classes, used pervasively throughout the executor.
Definition: item_xmlfunc.h:43
const char * beg
Definition: item_xmlfunc.h:47
uint level
Definition: item_xmlfunc.h:44
enum my_xml_node_type type
Definition: item_xmlfunc.h:45
const char * end
Definition: item_xmlfunc.h:48
uint parent
Definition: item_xmlfunc.h:46
const char * tagend
Definition: item_xmlfunc.h:49
Bison "location" class.
Definition: parse_location.h:42
unsigned int uint
Definition: uca-dump.cc:29