MySQL 8.4.2
Source Code Documentation
sql_handler.h
Go to the documentation of this file.
1/* Copyright (c) 2006, 2024, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef SQL_HANDLER_INCLUDED
25#define SQL_HANDLER_INCLUDED
26
27#include "my_base.h" /* ha_rkey_function, ha_rows */
28#include "my_sqlcommand.h"
29#include "sql/sql_cmd.h" // Sql_cmd
30
31class Item;
32class THD;
33class Table_ref;
34
36template <class T>
37class mem_root_deque;
38
39/**
40 Sql_cmd_handler_open represents HANDLER OPEN statement.
41
42 @note Some information about this statement, for example, table to be
43 opened is still kept in LEX class.
44*/
45
47 public:
49
50 ~Sql_cmd_handler_open() override = default;
51
53
54 bool execute(THD *thd) override;
55};
56
57/**
58 Sql_cmd_handler_read represents HANDLER READ statement.
59
60 @note Some information about this statement, for example, table
61 list element which identifies HANDLER to be read from,
62 WHERE and LIMIT clauses is still kept in LEX class.
63*/
64
66 public:
67 Sql_cmd_handler_read(enum_ha_read_modes read_mode, const char *key_name,
68 mem_root_deque<Item *> *key_expr,
69 ha_rkey_function rkey_mode)
70 : m_read_mode(read_mode),
71 m_key_name(key_name),
72 m_key_expr(key_expr),
73 m_rkey_mode(rkey_mode) {}
74
75 ~Sql_cmd_handler_read() override = default;
76
78
79 bool execute(THD *thd) override;
80
81 private:
82 /** Read mode for HANDLER READ: FIRST, NEXT, LAST, ... */
84
85 /**
86 Name of key to be used for reading,
87 NULL in cases when natural row-order is to be used.
88 */
89 const char *m_key_name;
90
91 /** Key values to be satisfied. */
93
94 /** Type of condition for key values to be satisfied. */
96};
97
98/**
99 Sql_cmd_handler_close represents HANDLER CLOSE statement.
100
101 @note Table list element which identifies HANDLER to be closed
102 still resides in LEX class.
103*/
104
106 public:
108
109 ~Sql_cmd_handler_close() override = default;
110
112
113 bool execute(THD *thd) override;
114};
115
116void mysql_ha_flush(THD *thd);
117void mysql_ha_flush_tables(THD *thd, Table_ref *all_tables);
118void mysql_ha_flush_table(THD *thd, const char *db_name,
119 const char *table_name);
120void mysql_ha_rm_tables(THD *thd, Table_ref *tables);
122void mysql_ha_cleanup(THD *thd);
124
125#endif /* SQL_HANDLER_INCLUDED */
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:936
Sql_cmd_handler_close represents HANDLER CLOSE statement.
Definition: sql_handler.h:105
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_handler.h:111
~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:342
Sql_cmd_handler_open represents HANDLER OPEN statement.
Definition: sql_handler.h:46
Sql_cmd_handler_open()=default
bool execute(THD *thd) override
Execute a HANDLER OPEN statement.
Definition: sql_handler.cc:147
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_handler.h:52
~Sql_cmd_handler_open() override=default
Sql_cmd_handler_read represents HANDLER READ statement.
Definition: sql_handler.h:65
bool execute(THD *thd) override
Execute a HANDLER READ statement.
Definition: sql_handler.cc:386
enum ha_rkey_function m_rkey_mode
Type of condition for key values to be satisfied.
Definition: sql_handler.h:95
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:67
mem_root_deque< Item * > * m_key_expr
Key values to be satisfied.
Definition: sql_handler.h:92
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:89
~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:83
enum_sql_command sql_command_code() const override
Return the command code for this statement.
Definition: sql_handler.h:77
Representation of an SQL command.
Definition: sql_cmd.h:83
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: table.h:2864
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:111
This file includes constants used by all storage engines.
ha_rkey_function
Definition: my_base.h:78
enum_sql_command
Definition: my_sqlcommand.h:46
@ SQLCOM_HA_OPEN
Definition: my_sqlcommand.h:117
@ SQLCOM_HA_CLOSE
Definition: my_sqlcommand.h:118
@ SQLCOM_HA_READ
Definition: my_sqlcommand.h:119
const char * table_name
Definition: rules_table_service.cc:56
const char * db_name
Definition: rules_table_service.cc:55
Representation of an SQL command.
void mysql_ha_rm_tables(THD *thd, Table_ref *tables)
Remove matching tables from the HANDLER's hash table.
Definition: sql_handler.cc:837
void mysql_ha_cleanup(THD *thd)
Close all HANDLER's tables.
Definition: sql_handler.cc:986
enum_ha_read_modes
Definition: sql_handler.h:35
void mysql_ha_rm_temporary_tables(THD *thd)
Remove temporary tables from the HANDLER's hash table.
Definition: sql_handler.cc:949
void mysql_ha_flush_tables(THD *thd, Table_ref *all_tables)
Close cursors of matching tables from the HANDLER's hash table.
Definition: sql_handler.cc:867
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:1004
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:913
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:889