MySQL 8.0.31
Source Code Documentation
sql_handler.h
Go to the documentation of this file.
1/* Copyright (c) 2006, 2022, 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 SQL_HANDLER_INCLUDED
24#define SQL_HANDLER_INCLUDED
25
26#include "my_base.h" /* ha_rkey_function, ha_rows */
27#include "my_sqlcommand.h"
28#include "sql/sql_cmd.h" // Sql_cmd
29
30class Item;
31class THD;
32struct TABLE_LIST;
33
35template <class T>
36class mem_root_deque;
37
38/**
39 Sql_cmd_handler_open represents HANDLER OPEN statement.
40
41 @note Some information about this statement, for example, table to be
42 opened is still kept in LEX class.
43*/
44
46 public:
48
49 ~Sql_cmd_handler_open() override = default;
50
52
53 bool execute(THD *thd) override;
54};
55
56/**
57 Sql_cmd_handler_read represents HANDLER READ statement.
58
59 @note Some information about this statement, for example, table
60 list element which identifies HANDLER to be read from,
61 WHERE and LIMIT clauses is still kept in LEX class.
62*/
63
65 public:
66 Sql_cmd_handler_read(enum_ha_read_modes read_mode, const char *key_name,
67 mem_root_deque<Item *> *key_expr,
68 ha_rkey_function rkey_mode)
69 : m_read_mode(read_mode),
70 m_key_name(key_name),
71 m_key_expr(key_expr),
72 m_rkey_mode(rkey_mode) {}
73
74 ~Sql_cmd_handler_read() override = default;
75
77
78 bool execute(THD *thd) override;
79
80 private:
81 /** Read mode for HANDLER READ: FIRST, NEXT, LAST, ... */
83
84 /**
85 Name of key to be used for reading,
86 NULL in cases when natural row-order is to be used.
87 */
88 const char *m_key_name;
89
90 /** Key values to be satisfied. */
92
93 /** Type of condition for key values to be satisfied. */
95};
96
97/**
98 Sql_cmd_handler_close represents HANDLER CLOSE statement.
99
100 @note Table list element which identifies HANDLER to be closed
101 still resides in LEX class.
102*/
103
105 public:
107
108 ~Sql_cmd_handler_close() override = default;
109
111
112 bool execute(THD *thd) override;
113};
114
115void mysql_ha_flush(THD *thd);
116void mysql_ha_flush_tables(THD *thd, TABLE_LIST *all_tables);
117void mysql_ha_flush_table(THD *thd, const char *db_name,
118 const char *table_name);
119void mysql_ha_rm_tables(THD *thd, TABLE_LIST *tables);
121void mysql_ha_cleanup(THD *thd);
123
124#endif /* SQL_HANDLER_INCLUDED */
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:802
Sql_cmd_handler_close represents HANDLER CLOSE statement.
Definition: sql_handler.h:104
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_handler.h:110
~Sql_cmd_handler_close() override=default
Sql_cmd_handler_close()=default
bool execute(THD *thd) override
Execute a HANDLER CLOSE statement.
Definition: sql_handler.cc:340
Sql_cmd_handler_open represents HANDLER OPEN statement.
Definition: sql_handler.h:45
Sql_cmd_handler_open()=default
bool execute(THD *thd) override
Execute a HANDLER OPEN statement.
Definition: sql_handler.cc:145
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_handler.h:51
~Sql_cmd_handler_open() override=default
Sql_cmd_handler_read represents HANDLER READ statement.
Definition: sql_handler.h:64
bool execute(THD *thd) override
Execute a HANDLER READ statement.
Definition: sql_handler.cc:384
enum ha_rkey_function m_rkey_mode
Type of condition for key values to be satisfied.
Definition: sql_handler.h:94
Sql_cmd_handler_read(enum_ha_read_modes read_mode, const char *key_name, mem_root_deque< Item * > *key_expr, ha_rkey_function rkey_mode)
Definition: sql_handler.h:66
mem_root_deque< Item * > * m_key_expr
Key values to be satisfied.
Definition: sql_handler.h:91
const char * m_key_name
Name of key to be used for reading, NULL in cases when natural row-order is to be used.
Definition: sql_handler.h:88
~Sql_cmd_handler_read() override=default
enum_ha_read_modes m_read_mode
Read mode for HANDLER READ: FIRST, NEXT, LAST, ...
Definition: sql_handler.h:82
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_handler.h:76
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:922
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:109
This file includes constants used by all storage engines.
ha_rkey_function
Definition: my_base.h:77
enum_sql_command
Definition: my_sqlcommand.h:45
@ SQLCOM_HA_OPEN
Definition: my_sqlcommand.h:116
@ SQLCOM_HA_CLOSE
Definition: my_sqlcommand.h:117
@ SQLCOM_HA_READ
Definition: my_sqlcommand.h:118
const char * table_name
Definition: rules_table_service.cc:55
const char * db_name
Definition: rules_table_service.cc:54
Representation of an SQL command.
void mysql_ha_rm_tables(THD *thd, TABLE_LIST *tables)
Remove matching tables from the HANDLER's hash table.
Definition: sql_handler.cc:836
void mysql_ha_cleanup(THD *thd)
Close all HANDLER's tables.
Definition: sql_handler.cc:985
enum_ha_read_modes
Definition: sql_handler.h:34
void mysql_ha_rm_temporary_tables(THD *thd)
Remove temporary tables from the HANDLER's hash table.
Definition: sql_handler.cc:948
void mysql_ha_set_explicit_lock_duration(THD *thd)
Set explicit duration for metadata locks corresponding to open HANDLERs to protect them from being re...
Definition: sql_handler.cc:1003
void mysql_ha_flush(THD *thd)
Flush (close and mark for re-open) all tables that should be should be reopen.
Definition: sql_handler.cc:912
void mysql_ha_flush_tables(THD *thd, TABLE_LIST *all_tables)
Close cursors of matching tables from the HANDLER's hash table.
Definition: sql_handler.cc:866
void mysql_ha_flush_table(THD *thd, const char *db_name, const char *table_name)
Close cursors on the table from the HANDLER's hash.
Definition: sql_handler.cc:888
Definition: table.h:2756