MySQL  8.0.20
Source Code Documentation
sql_handler.h
Go to the documentation of this file.
1 /* Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
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 
30 class Item;
31 class THD;
32 struct TABLE_LIST;
33 
35 template <class T>
36 class List;
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 
45 class Sql_cmd_handler_open : public Sql_cmd {
46  public:
48 
49  virtual ~Sql_cmd_handler_open() {}
50 
51  virtual enum_sql_command sql_command_code() const { return SQLCOM_HA_OPEN; }
52 
53  virtual bool execute(THD *thd);
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 
64 class Sql_cmd_handler_read : public Sql_cmd {
65  public:
66  Sql_cmd_handler_read(enum_ha_read_modes read_mode, const char *key_name,
67  List<Item> *key_expr, ha_rkey_function rkey_mode)
68  : m_read_mode(read_mode),
69  m_key_name(key_name),
70  m_key_expr(key_expr),
71  m_rkey_mode(rkey_mode) {}
72 
73  virtual ~Sql_cmd_handler_read() {}
74 
75  virtual enum_sql_command sql_command_code() const { return SQLCOM_HA_READ; }
76 
77  virtual bool execute(THD *thd);
78 
79  private:
80  /** Read mode for HANDLER READ: FIRST, NEXT, LAST, ... */
82 
83  /**
84  Name of key to be used for reading,
85  NULL in cases when natural row-order is to be used.
86  */
87  const char *m_key_name;
88 
89  /** Key values to be satisfied. */
91 
92  /** Type of condition for key values to be satisfied. */
93  enum ha_rkey_function m_rkey_mode;
94 };
95 
96 /**
97  Sql_cmd_handler_close represents HANDLER CLOSE statement.
98 
99  @note Table list element which identifies HANDLER to be closed
100  still resides in LEX class.
101 */
102 
104  public:
106 
108 
110 
111  virtual bool execute(THD *thd);
112 };
113 
114 void mysql_ha_flush(THD *thd);
115 void mysql_ha_flush_tables(THD *thd, TABLE_LIST *all_tables);
116 void mysql_ha_flush_table(THD *thd, const char *db_name,
117  const char *table_name);
118 void mysql_ha_rm_tables(THD *thd, TABLE_LIST *tables);
120 void mysql_ha_cleanup(THD *thd);
122 
123 #endif /* SQL_HANDLER_INCLUDED */
void mysql_ha_flush_table(THD *thd, const char *db_name, const char *table_name)
Close cursors on the table from the HANDLER&#39;s hash.
Definition: sql_handler.cc:895
virtual ~Sql_cmd_handler_open()
Definition: sql_handler.h:49
Representation of an SQL command.
Definition: sql_cmd.h:63
const char * db_name
Definition: rules_table_service.cc:54
Sql_cmd_handler_read(enum_ha_read_modes read_mode, const char *key_name, List< Item > *key_expr, ha_rkey_function rkey_mode)
Definition: sql_handler.h:66
enum_sql_command
Definition: my_sqlcommand.h:45
enum_ha_read_modes
Definition: sql_handler.h:34
static bool execute(MYSQL_STMT *stmt, char *packet, ulong length)
Definition: libmysql.cc:1918
List< Item > * m_key_expr
Key values to be satisfied.
Definition: sql_handler.h:90
Representation of an SQL command.
ha_rkey_function
Definition: my_base.h:77
Sql_cmd_handler_close()
Definition: sql_handler.h:105
virtual ~Sql_cmd_handler_read()
Definition: sql_handler.h:73
This file includes constants used by all storage engines.
Sql_cmd_handler_close represents HANDLER CLOSE statement.
Definition: sql_handler.h:103
Sql_cmd_handler_open()
Definition: sql_handler.h:47
virtual enum_sql_command sql_command_code() const
Return the command code for this statement.
Definition: sql_handler.h:75
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:919
Definition: aggregate_check.h:523
Definition: item.h:740
enum_ha_read_modes m_read_mode
Read mode for HANDLER READ: FIRST, NEXT, LAST, ...
Definition: sql_handler.h:81
Sql_cmd_handler_read represents HANDLER READ statement.
Definition: sql_handler.h:64
void mysql_ha_rm_temporary_tables(THD *thd)
Remove temporary tables from the HANDLER&#39;s hash table.
Definition: sql_handler.cc:955
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:87
void mysql_ha_rm_tables(THD *thd, TABLE_LIST *tables)
Remove matching tables from the HANDLER&#39;s hash table.
Definition: sql_handler.cc:843
Sql_cmd_handler_open represents HANDLER OPEN statement.
Definition: sql_handler.h:45
Definition: my_sqlcommand.h:117
void mysql_ha_flush_tables(THD *thd, TABLE_LIST *all_tables)
Close cursors of matching tables from the HANDLER&#39;s hash table.
Definition: sql_handler.cc:873
virtual enum_sql_command sql_command_code() const
Return the command code for this statement.
Definition: sql_handler.h:109
virtual ~Sql_cmd_handler_close()
Definition: sql_handler.h:107
virtual enum_sql_command sql_command_code() const
Return the command code for this statement.
Definition: sql_handler.h:51
Definition: my_sqlcommand.h:118
Definition: table.h:2481
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:1010
Definition: my_sqlcommand.h:116
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:765
void mysql_ha_cleanup(THD *thd)
Close all HANDLER&#39;s tables.
Definition: sql_handler.cc:992
const char * table_name
Definition: rules_table_service.cc:55