1 /* Copyright (c) 2006, 2015, 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 "sql_cmd.h" // Sql_cmd 28 #include "sql_lex.h" // enum_ha_read_modes 29 #include "sql_list.h" /* List */ 30 31 class THD; 32 struct TABLE_LIST; 33 34 /** 35 Sql_cmd_handler_open represents HANDLER OPEN statement. 36 37 @note Some information about this statement, for example, table to be 38 opened is still kept in LEX class. 39 */ 40 41 class Sql_cmd_handler_open : public Sql_cmd 42 { 43 public: Sql_cmd_handler_open()44 Sql_cmd_handler_open() 45 {} 46 ~Sql_cmd_handler_open()47 virtual ~Sql_cmd_handler_open() 48 {} 49 sql_command_code()50 virtual enum_sql_command sql_command_code() const 51 { 52 return SQLCOM_HA_OPEN; 53 } 54 55 virtual bool execute(THD *thd); 56 }; 57 58 59 /** 60 Sql_cmd_handler_read represents HANDLER READ statement. 61 62 @note Some information about this statement, for example, table 63 list element which identifies HANDLER to be read from, 64 WHERE and LIMIT clauses is still kept in LEX class. 65 */ 66 67 class Sql_cmd_handler_read : public Sql_cmd 68 { 69 public: Sql_cmd_handler_read(enum_ha_read_modes read_mode,const char * key_name,List<Item> * key_expr,ha_rkey_function rkey_mode)70 Sql_cmd_handler_read(enum_ha_read_modes read_mode, 71 const char *key_name, 72 List<Item> *key_expr, 73 ha_rkey_function rkey_mode) 74 : m_read_mode(read_mode), m_key_name(key_name), m_key_expr(key_expr), 75 m_rkey_mode(rkey_mode) 76 {} 77 ~Sql_cmd_handler_read()78 virtual ~Sql_cmd_handler_read() 79 {} 80 sql_command_code()81 virtual enum_sql_command sql_command_code() const 82 { 83 return SQLCOM_HA_READ; 84 } 85 86 virtual bool execute(THD *thd); 87 88 private: 89 /** Read mode for HANDLER READ: FIRST, NEXT, LAST, ... */ 90 enum enum_ha_read_modes m_read_mode; 91 92 /** 93 Name of key to be used for reading, 94 NULL in cases when natural row-order is to be used. 95 */ 96 const char *m_key_name; 97 98 /** Key values to be satisfied. */ 99 List<Item> *m_key_expr; 100 101 /** Type of condition for key values to be satisfied. */ 102 enum ha_rkey_function m_rkey_mode; 103 }; 104 105 106 /** 107 Sql_cmd_handler_close represents HANDLER CLOSE statement. 108 109 @note Table list element which identifies HANDLER to be closed 110 still resides in LEX class. 111 */ 112 113 class Sql_cmd_handler_close : public Sql_cmd 114 { 115 public: Sql_cmd_handler_close()116 Sql_cmd_handler_close() 117 {} 118 ~Sql_cmd_handler_close()119 virtual ~Sql_cmd_handler_close() 120 {} 121 sql_command_code()122 virtual enum_sql_command sql_command_code() const 123 { 124 return SQLCOM_HA_CLOSE; 125 } 126 127 virtual bool execute(THD *thd); 128 }; 129 130 131 void mysql_ha_flush(THD *thd); 132 void mysql_ha_flush_tables(THD *thd, TABLE_LIST *all_tables); 133 void mysql_ha_rm_tables(THD *thd, TABLE_LIST *tables); 134 void mysql_ha_rm_temporary_tables(THD *thd); 135 void mysql_ha_cleanup(THD *thd); 136 void mysql_ha_set_explicit_lock_duration(THD *thd); 137 138 typedef bool Log_func(THD*, TABLE*, bool, 139 const uchar*, const uchar*); 140 141 int binlog_log_row(TABLE* table, 142 const uchar *before_record, 143 const uchar *after_record, 144 Log_func *log_func); 145 146 #endif /* SQL_HANDLER_INCLUDED */ 147