1#ifndef SQL_HANDLER_INCLUDED
2#define SQL_HANDLER_INCLUDED
3/* Copyright (c) 2006, 2015, Oracle and/or its affiliates.
4 Copyright (C) 2010, 2015, MariaDB
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; version 2 of the License.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
18
19#ifdef USE_PRAGMA_INTERFACE
20#pragma interface /* gcc class implementation */
21#endif
22
23#include "sql_class.h" /* enum_ha_read_mode */
24#include "my_base.h" /* ha_rkey_function, ha_rows */
25#include "sql_list.h" /* List */
26
27/* Open handlers are stored here */
28
29class SQL_HANDLER {
30public:
31 TABLE *table;
32 List<Item> fields; /* Fields, set on open */
33 THD *thd;
34 LEX_CSTRING handler_name;
35 LEX_CSTRING db;
36 LEX_CSTRING table_name;
37 MEM_ROOT mem_root;
38 MYSQL_LOCK *lock;
39 MDL_request mdl_request;
40
41 key_part_map keypart_map;
42 int keyno; /* Used key */
43 uint key_len;
44 enum enum_ha_read_modes mode;
45
46 /* This is only used when deleting many handler objects */
47 SQL_HANDLER *next;
48
49 Query_arena arena;
50 char *base_data;
51 SQL_HANDLER(THD *thd_arg) :
52 thd(thd_arg), arena(&mem_root, Query_arena::STMT_INITIALIZED)
53 { init(); clear_alloc_root(&mem_root); base_data= 0; }
54 void init()
55 {
56 keyno= -1;
57 table= 0;
58 lock= 0;
59 mdl_request.ticket= 0;
60 }
61 void reset();
62
63 ~SQL_HANDLER();
64};
65
66class THD;
67struct TABLE_LIST;
68
69bool mysql_ha_open(THD *thd, TABLE_LIST *tables, SQL_HANDLER *reopen);
70bool mysql_ha_close(THD *thd, TABLE_LIST *tables);
71bool mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes, const char *,
72 List<Item> *,enum ha_rkey_function,Item *,ha_rows,ha_rows);
73void mysql_ha_flush(THD *thd);
74void mysql_ha_flush_tables(THD *thd, TABLE_LIST *all_tables);
75void mysql_ha_rm_tables(THD *thd, TABLE_LIST *tables);
76void mysql_ha_cleanup(THD *thd);
77void mysql_ha_set_explicit_lock_duration(THD *thd);
78void mysql_ha_rm_temporary_tables(THD *thd);
79
80SQL_HANDLER *mysql_ha_read_prepare(THD *thd, TABLE_LIST *tables,
81 enum enum_ha_read_modes mode,
82 const char *keyname,
83 List<Item> *key_expr, enum ha_rkey_function ha_rkey_mode,
84 Item *cond);
85#endif
86