MySQL  8.0.27
Source Code Documentation
parse_tree_handler.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, 2021, Oracle and/or its affiliates.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef PARSE_TREE_HANDLER_INCLUDED
24 #define PARSE_TREE_HANDLER_INCLUDED
25 
26 #include <assert.h>
27 #include "lex_string.h"
28 #include "my_base.h"
29 
30 #include "parse_tree_nodes.h"
31 #include "sql/sql_handler.h" // Sql_cmd_handler_open
32 
33 class Item;
34 class PT_item_list;
35 class Sql_cmd;
36 class THD;
37 class Table_ident;
38 struct Parse_context;
39 
40 class PT_handler_open final : public Parse_tree_root {
41  public:
42  PT_handler_open(Table_ident *table, const LEX_CSTRING &opt_table_alias)
43  : m_table(table), m_opt_table_alias(opt_table_alias.str) {}
44 
45  Sql_cmd *make_cmd(THD *thd) override;
46 
47  private:
49  const char *const m_opt_table_alias;
50 
52 };
53 
54 class PT_handler_close final : public Parse_tree_root {
55  public:
56  explicit PT_handler_close(const LEX_CSTRING &table) : m_table(table) {}
57 
58  Sql_cmd *make_cmd(THD *thd) override;
59 
60  private:
62 
64 };
65 
67  public:
68  ~PT_handler_read_base() override = 0; // force abstract class
69 
70  PT_handler_read_base(const LEX_CSTRING &table, Item *opt_where_clause,
71  PT_limit_clause *opt_limit_clause)
72  : m_table(table),
73  m_opt_where_clause(opt_where_clause),
74  m_opt_limit_clause(opt_limit_clause) {}
75 
76  protected:
77  bool contextualize(Parse_context *pc);
78 
79  private:
83 };
84 
86 
89 
90  public:
92  Item *opt_where_clause,
93  PT_limit_clause *opt_limit_clause)
94  : super(table, opt_where_clause, opt_limit_clause),
95  m_direction(direction) {}
96 
97  Sql_cmd *make_cmd(THD *thd) override;
98 
99  private:
101 };
102 
105 
106  public:
107  PT_handler_index_scan(const LEX_CSTRING &table, const LEX_CSTRING &index,
108  enum_ha_read_modes direction, Item *opt_where_clause,
109  PT_limit_clause *opt_limit_clause)
110  : super(table, opt_where_clause, opt_limit_clause),
111  m_index(index.str),
112  m_direction(direction) {
113  assert(direction != enum_ha_read_modes::RKEY);
114  }
115 
116  Sql_cmd *make_cmd(THD *thd) override;
117 
118  private:
119  const char *const m_index;
121 };
122 
125 
126  public:
128  const LEX_CSTRING &index,
129  ha_rkey_function key_function,
130  PT_item_list *keypart_values,
131  Item *opt_where_clause,
132  PT_limit_clause *opt_limit_clause)
133  : super(table, opt_where_clause, opt_limit_clause),
134  m_index(index.str),
135  m_key_function(key_function),
136  m_keypart_values(keypart_values) {}
137 
138  Sql_cmd *make_cmd(THD *thd) override;
139 
140  private:
141  const char *const m_index;
144 };
145 
146 #endif // PARSE_TREE_HANDLER_INCLUDED
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:802
Definition: parse_tree_handler.h:54
Sql_cmd_handler_close m_cmd
Definition: parse_tree_handler.h:63
const LEX_CSTRING m_table
Definition: parse_tree_handler.h:61
PT_handler_close(const LEX_CSTRING &table)
Definition: parse_tree_handler.h:56
Sql_cmd * make_cmd(THD *thd) override
Definition: parse_tree_handler.cc:58
Definition: parse_tree_handler.h:123
PT_handler_read_base super
Definition: parse_tree_handler.h:124
Sql_cmd * make_cmd(THD *thd) override
Definition: parse_tree_handler.cc:142
const ha_rkey_function m_key_function
Definition: parse_tree_handler.h:142
PT_handler_index_range_scan(const LEX_CSTRING &table, const LEX_CSTRING &index, ha_rkey_function key_function, PT_item_list *keypart_values, Item *opt_where_clause, PT_limit_clause *opt_limit_clause)
Definition: parse_tree_handler.h:127
const char *const m_index
Definition: parse_tree_handler.h:141
PT_item_list *const m_keypart_values
Definition: parse_tree_handler.h:143
Definition: parse_tree_handler.h:103
Sql_cmd * make_cmd(THD *thd) override
Definition: parse_tree_handler.cc:132
const char *const m_index
Definition: parse_tree_handler.h:119
PT_handler_index_scan(const LEX_CSTRING &table, const LEX_CSTRING &index, enum_ha_read_modes direction, Item *opt_where_clause, PT_limit_clause *opt_limit_clause)
Definition: parse_tree_handler.h:107
const enum_ha_read_modes m_direction
Definition: parse_tree_handler.h:120
PT_handler_read_base super
Definition: parse_tree_handler.h:104
Definition: parse_tree_handler.h:40
PT_handler_open(Table_ident *table, const LEX_CSTRING &opt_table_alias)
Definition: parse_tree_handler.h:42
const char *const m_opt_table_alias
Definition: parse_tree_handler.h:49
Table_ident *const m_table
Definition: parse_tree_handler.h:48
Sql_cmd_handler_open m_cmd
Definition: parse_tree_handler.h:51
Sql_cmd * make_cmd(THD *thd) override
Definition: parse_tree_handler.cc:42
Definition: parse_tree_handler.h:66
~PT_handler_read_base() override=0
const LEX_CSTRING m_table
Definition: parse_tree_handler.h:80
PT_handler_read_base(const LEX_CSTRING &table, Item *opt_where_clause, PT_limit_clause *opt_limit_clause)
Definition: parse_tree_handler.h:70
PT_limit_clause *const m_opt_limit_clause
Definition: parse_tree_handler.h:82
Item * m_opt_where_clause
Definition: parse_tree_handler.h:81
bool contextualize(Parse_context *pc)
Definition: parse_tree_handler.cc:77
Definition: parse_tree_handler.h:87
const enum_ha_read_modes m_direction
Definition: parse_tree_handler.h:100
PT_handler_read_base super
Definition: parse_tree_handler.h:88
PT_handler_table_scan(const LEX_CSTRING &table, enum_ha_read_modes direction, Item *opt_where_clause, PT_limit_clause *opt_limit_clause)
Definition: parse_tree_handler.h:91
Sql_cmd * make_cmd(THD *thd) override
Definition: parse_tree_handler.cc:122
Wrapper class for an Item list head, used to allocate Item lists in the parser in a context-independe...
Definition: parse_tree_helpers.h:101
Definition: parse_tree_nodes.h:389
Base class for all top-level nodes of SQL statements.
Definition: parse_tree_nodes.h:157
Sql_cmd_handler_close represents HANDLER CLOSE statement.
Definition: sql_handler.h:104
Sql_cmd_handler_open represents HANDLER OPEN statement.
Definition: sql_handler.h:45
Representation of an SQL command.
Definition: sql_cmd.h:64
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:821
Definition: sql_lex.h:292
This file includes constants used by all storage engines.
ha_rkey_function
Definition: my_base.h:77
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1056
enum_ha_read_modes
Definition: sql_handler.h:34
Definition: mysql_lex_string.h:39
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:90