24#ifndef PARSE_TREE_NODE_BASE_INCLUDED
25#define PARSE_TREE_NODE_BASE_INCLUDED
50#define UNCACHEABLE_DEPENDENT 1
51#define UNCACHEABLE_RAND 2
52#define UNCACHEABLE_SIDEEFFECT 4
54#define UNCACHEABLE_UNITED 8
55#define UNCACHEABLE_CHECKOPTION 16
157 const Json_object *obj_a = down_cast<const Json_object *>(a.get());
158 const Json_object *obj_b = down_cast<const Json_object *>(b.get());
160 longlong inta = down_cast<Json_int *>(obj_a->
get(
"startpos"))->value();
161 longlong intb = down_cast<Json_int *>(obj_b->
get(
"startpos"))->value();
230template <
typename Context>
247 const std::nothrow_t &arg
248 [[maybe_unused]] = std::nothrow)
noexcept {
251 static void operator delete(
void *ptr [[maybe_unused]],
252 size_t size [[maybe_unused]]) {
256 const std::nothrow_t &)
noexcept {}
322 if (pc->m_show_parse_tree ==
nullptr || this->m_pos.is_empty())
345 pc->thd->syntax_error_at(pos);
356 void error(Context *pc,
const POS &pos,
const char *msg)
const {
357 pc->thd->syntax_error_at(pos,
"%s", msg);
368 void errorf(Context *pc,
const POS &pos,
const char *format, ...) const
369 MY_ATTRIBUTE((format(printf, 4, 5)));
372template <typename Context>
377 va_start(args, format);
378 pc->thd->vsyntax_error_at(pos, format, args);
382template <
typename Context>
384 if (tree ==
nullptr)
return false;
385 if (tree->
push_level(this->m_pos,
typeid(*this).name()))
return true;
391 assert(json_obj !=
nullptr);
397template <
typename Context>
399 if (tree ==
nullptr)
return false;
404 std::unique_ptr<Show_parse_tree> m_show_parse_tree =
nullptr;
407 bool show_parse_tree =
false,
409 if (show_parse_tree) {
410 m_show_parse_tree = std::unique_ptr<Show_parse_tree>(
413 m_show_parse_tree =
nullptr;
427 bool finalize_query_expression();
435 parent_show_parent_tree) {}
437 bool is_top_level_union_all(
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
bool check_stack_overrun(const THD *thd, long margin, unsigned char *buf)
Check stack for a overrun.
Definition: check_stack.cc:110
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:936
Represents a JSON container value of type "object" (ECMA), type J_OBJECT here.
Definition: json_dom.h:369
Json_dom * get(const std::string &key) const
Return the value at key.
Definition: json_dom.cc:866
Base class for parse tree nodes (excluding the Parse_tree_root hierarchy)
Definition: parse_tree_node_base.h:231
Parse_tree_node_tmpl(const Parse_tree_node_tmpl &)
Context context_t
Definition: parse_tree_node_base.h:243
Parse_tree_node_tmpl(const POS &start_pos, const POS &end_pos)
Definition: parse_tree_node_base.h:263
virtual bool contextualize(Context *pc) final
Definition: parse_tree_node_base.h:319
bool is_contextualized() const
Definition: parse_tree_node_base.h:309
void operator=(const Parse_tree_node_tmpl &)
virtual ~Parse_tree_node_tmpl()=default
void error(Context *pc, const POS &pos) const
syntax_error() function replacement for deferred reporting of syntax errors
Definition: parse_tree_node_base.h:344
void error(Context *pc, const POS &pos, const char *msg) const
syntax_error() function replacement for deferred reporting of syntax errors
Definition: parse_tree_node_base.h:356
Parse_tree_node_tmpl()=delete
virtual void add_json_info(Json_object *json_obj)
Add all the node-specific json fields.
Definition: parse_tree_node_base.h:303
virtual bool do_contextualize(Context *pc)
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_node_base.h:283
bool end_parse_tree(Show_parse_tree *tree)
Definition: parse_tree_node_base.h:398
Parse_tree_node_tmpl(const POS &pos)
Definition: parse_tree_node_base.h:261
bool contextualized
Definition: parse_tree_node_base.h:239
void errorf(Context *pc, const POS &pos, const char *format,...) const
syntax_error() function replacement for deferred reporting of syntax errors
Definition: parse_tree_node_base.h:373
bool begin_parse_tree(Show_parse_tree *tree)
Definition: parse_tree_node_base.h:383
POS m_pos
Definition: parse_tree_node_base.h:244
Base class for all top-level nodes of SQL statements.
Definition: parse_tree_nodes.h:161
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1163
Query term tree structure.
Definition: query_term.h:209
Holds the json parse tree being generated by the SHOW PARSE_TREE command.
Definition: parse_tree_node_base.h:140
bool make_child(Json_object *obj)
Make the obj a child of the current parent object in the object stack.
Definition: parse_tree_node_base.cc:178
static constexpr Parse_tree_comparator m_comparator
Definition: parse_tree_node_base.h:165
std::string get_parse_tree()
Generate the json tree text from the json tree, and return it.
Definition: parse_tree_node_base.cc:159
Show_parse_tree(Show_parse_tree *parent_tree=nullptr)
Definition: parse_tree_node_base.h:182
bool push_level(const POS &pos, const char *typname)
Create a json node out of the parse tree node position and type name, and push it onto the json objec...
Definition: parse_tree_node_base.cc:113
Json_object * pop_json_object()
Pop the current object in the object stack, and return it.
Definition: parse_tree_node_base.cc:141
std::vector< Json_object * > m_json_obj_stack
Definition: parse_tree_node_base.h:142
const char * m_reference_pos
Definition: parse_tree_node_base.h:148
Show_parse_tree * m_parent_show_parse_tree
Definition: parse_tree_node_base.h:144
bool pop_level()
Pop out the json node pushed by push_level() and make it a child of the inner json object in the stac...
Definition: parse_tree_node_base.h:224
Json_object * get_current_parent()
Get the current object under which new json objects are to be added as children.
Definition: parse_tree_node_base.h:204
Json_object_ptr m_root_obj
Definition: parse_tree_node_base.h:143
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:111
static MEM_ROOT mem_root
Definition: client_plugin.cc:114
std::unique_ptr< Json_dom > Json_dom_ptr
Definition: json_dom.h:65
std::unique_ptr< Json_object > Json_object_ptr
Definition: json_dom.h:67
Various macros useful for communicating with memory debuggers, such as Valgrind.
void TRASH(void *ptr, size_t length)
Put bad content in memory to be sure it will segfault if dereferenced.
Definition: memory_debugging.h:71
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
Header for compiler-dependent features.
#define MY_COMPILER_MSVC_DIAGNOSTIC_IGNORE(X)
Definition: my_compiler.h:255
#define MY_COMPILER_DIAGNOSTIC_PUSH()
save the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:285
#define MY_COMPILER_DIAGNOSTIC_POP()
restore the compiler's diagnostic (enabled warnings, errors, ...) state
Definition: my_compiler.h:286
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:52
long long int longlong
Definition: my_inttypes.h:55
size_t size(const char *const c)
Definition: base64.h:46
enum_parsing_context
Names for different query parse tree parts.
Definition: parse_tree_node_base.h:61
@ CTX_QEP_TAB
Definition: parse_tree_node_base.h:70
@ CTX_SIMPLE_DISTINCT
DISTINCT clause execution context.
Definition: parse_tree_node_base.h:84
@ CTX_ORDER_BY
ORDER BY clause execution context.
Definition: parse_tree_node_base.h:79
@ CTX_HAVING
Inside HAVING condition.
Definition: parse_tree_node_base.h:77
@ CTX_UNARY_RESULT
Pseudo-table context.
Definition: parse_tree_node_base.h:96
@ CTX_BUFFER_RESULT
see SQL_BUFFER_RESULT in the manual
Definition: parse_tree_node_base.h:85
@ CTX_MESSAGE
"No tables used" messages etc.
Definition: parse_tree_node_base.h:63
@ CTX_UNION_RESULT
Pseudo-table context for UNION result.
Definition: parse_tree_node_base.h:90
@ CTX_DERIVED
"Derived" subquery
Definition: parse_tree_node_base.h:73
@ CTX_EXCEPT
Definition: parse_tree_node_base.h:93
@ CTX_SELECT_LIST
SELECT (subquery), (subquery)...
Definition: parse_tree_node_base.h:65
@ CTX_ORDER_BY_SQ
Subquery in ORDER BY clause item tree.
Definition: parse_tree_node_base.h:86
@ CTX_UNARY
Definition: parse_tree_node_base.h:95
@ CTX_QUALIFY
Inside QUALIFY condition.
Definition: parse_tree_node_base.h:78
@ CTX_SIMPLE_ORDER_BY
ORDER BY clause execution context.
Definition: parse_tree_node_base.h:81
@ CTX_SIMPLE_GROUP_BY
GROUP BY clause execution context.
Definition: parse_tree_node_base.h:82
@ CTX_INTERSECT
Definition: parse_tree_node_base.h:91
@ CTX_INSERT_UPDATE
INSERT ... ON DUPLICATE KEY UPDATE ...
Definition: parse_tree_node_base.h:68
@ CTX_GROUP_BY_SQ
Subquery in GROUP BY clause item tree.
Definition: parse_tree_node_base.h:87
@ CTX_INTERSECT_RESULT
Pseudo-table context.
Definition: parse_tree_node_base.h:92
@ CTX_MATERIALIZATION
Definition: parse_tree_node_base.h:71
@ CTX_NONE
Empty value.
Definition: parse_tree_node_base.h:62
@ CTX_DISTINCT
DISTINCT clause execution context.
Definition: parse_tree_node_base.h:83
@ CTX_UPDATE_VALUE
UPDATE ... SET field=(subquery)...
Definition: parse_tree_node_base.h:66
@ CTX_DUPLICATES_WEEDOUT
Definition: parse_tree_node_base.h:72
@ CTX_JOIN
Definition: parse_tree_node_base.h:69
@ CTX_OPTIMIZED_AWAY_SUBQUERY
Subquery executed once during optimization.
Definition: parse_tree_node_base.h:88
@ CTX_GROUP_BY
GROUP BY clause execution context.
Definition: parse_tree_node_base.h:80
@ CTX_QUERY_SPEC
Inner SELECTs of UNION expression.
Definition: parse_tree_node_base.h:97
@ CTX_TABLE
for single-table UPDATE/DELETE/INSERT/REPLACE
Definition: parse_tree_node_base.h:64
@ CTX_INSERT_VALUES
INSERT ... VALUES.
Definition: parse_tree_node_base.h:67
@ CTX_WHERE
Inside WHERE condition.
Definition: parse_tree_node_base.h:74
@ CTX_WINDOW
Named or unnamed window.
Definition: parse_tree_node_base.h:76
@ CTX_ON
Inside ON condition.
Definition: parse_tree_node_base.h:75
@ CTX_UNION
Definition: parse_tree_node_base.h:89
@ CTX_EXCEPT_RESULT
Pseudo-table context.
Definition: parse_tree_node_base.h:94
Surrounding_context
Definition: parse_tree_node_base.h:101
@ SC_SUBQUERY
Definition: parse_tree_node_base.h:106
@ SC_QUERY_EXPRESSION
Definition: parse_tree_node_base.h:105
@ SC_EXCEPT_ALL
Definition: parse_tree_node_base.h:112
@ SC_TABLE_VALUE_CONSTRUCTOR
Definition: parse_tree_node_base.h:104
@ SC_TOP
Definition: parse_tree_node_base.h:102
@ SC_INTERSECT_ALL
Definition: parse_tree_node_base.h:110
@ SC_QUERY_SPECIFICATION
Definition: parse_tree_node_base.h:103
@ SC_EXCEPT_DISTINCT
Definition: parse_tree_node_base.h:111
@ SC_UNION_DISTINCT
Definition: parse_tree_node_base.h:107
@ SC_UNION_ALL
Definition: parse_tree_node_base.h:108
@ SC_INTERSECT_DISTINCT
Definition: parse_tree_node_base.h:109
Parse_tree_node_tmpl< Parse_context > Parse_tree_node
Definition: parse_tree_node_base.h:442
File containing constants that can be used throughout the server.
constexpr const long STACK_MIN_SIZE
Stack reservation.
Definition: sql_const.h:143
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
void * Alloc(size_t length)
Allocate memory.
Definition: my_alloc.h:145
Bison "location" class.
Definition: parse_location.h:43
Symbol_location cpp
Definition: parse_location.h:44
Symbol_location raw
Definition: parse_location.h:45
Definition: parse_tree_node_base.h:403
Parse_context_base(bool show_parse_tree=false, Show_parse_tree *parent_show_parent_tree=nullptr)
Definition: parse_tree_node_base.h:406
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:420
Parse_context(THD *thd_arg, Query_block *sl_arg, Show_parse_tree *parent_show_parent_tree)
Definition: parse_tree_node_base.h:432
Parse_context(THD *thd_arg, Query_block *sl_arg, bool show_parse_tree=false)
Definition: parse_tree_node_base.h:430
Query_block * select
Current Query_block object.
Definition: parse_tree_node_base.h:423
THD *const thd
Current thread handler.
Definition: parse_tree_node_base.h:421
MEM_ROOT * mem_root
Current MEM_ROOT.
Definition: parse_tree_node_base.h:422
mem_root_deque< QueryLevel > m_stack
Aids query term tree construction.
Definition: parse_tree_node_base.h:424
Definition: parse_tree_node_base.h:115
QueryLevel(MEM_ROOT *mem_root, Surrounding_context sc, bool has_order=false)
Definition: parse_tree_node_base.h:119
mem_root_deque< Query_term * > m_elts
Definition: parse_tree_node_base.h:117
bool m_has_order
Definition: parse_tree_node_base.h:118
Surrounding_context m_type
Definition: parse_tree_node_base.h:116
Definition: parse_tree_node_base.h:155
bool operator()(const Json_dom_ptr &a, const Json_dom_ptr &b) const
Definition: parse_tree_node_base.h:156
const char * start
Definition: parse_location.h:33
const char * end
Definition: parse_location.h:34