575.1.3
by Monty Taylor
Moved some stuff out of handler.h. |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2008 Sun Microsystems
|
|
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 |
||
20 |
#ifndef DRIZZLED_HANDLERTON_H
|
|
21 |
#define DRIZZLED_HANDLERTON_H
|
|
22 |
||
575.4.7
by Monty Taylor
More header cleanup. |
23 |
#include <stdint.h> |
631.1.1
by Yoshinori Sano
Replace "uint_32 flags" member of handlerton with std::bitset. Add some TODOs as comments for this change. |
24 |
#include <bitset> |
575.4.7
by Monty Taylor
More header cleanup. |
25 |
|
575.1.5
by Monty Taylor
Moved stuff to handlerton.cc |
26 |
#include <drizzled/definitions.h> |
27 |
#include <drizzled/sql_plugin.h> |
|
575.1.3
by Monty Taylor
Moved some stuff out of handler.h. |
28 |
|
29 |
class TableList; |
|
575.1.5
by Monty Taylor
Moved stuff to handlerton.cc |
30 |
class Session; |
31 |
class XID; |
|
32 |
class handler; |
|
33 |
||
34 |
typedef struct st_mysql_lex_string LEX_STRING; |
|
575.1.3
by Monty Taylor
Moved some stuff out of handler.h. |
35 |
typedef struct st_table_share TABLE_SHARE; |
36 |
typedef bool (stat_print_fn)(Session *session, const char *type, uint32_t type_len, |
|
37 |
const char *file, uint32_t file_len, |
|
38 |
const char *status, uint32_t status_len); |
|
39 |
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX }; |
|
40 |
||
631.1.2
by Yoshinori Sano
Move hton_flag_bits and HTON_* to handlerton.h. Remove TODOs previously added. |
41 |
/* Possible flags of a handlerton (there can be 32 of them) */
|
42 |
enum hton_flag_bits { |
|
43 |
HTON_BIT_CLOSE_CURSORS_AT_COMMIT, |
|
44 |
HTON_BIT_ALTER_NOT_SUPPORTED, // Engine does not support alter |
|
45 |
HTON_BIT_CAN_RECREATE, // Delete all is used for truncate |
|
46 |
HTON_BIT_HIDDEN, // Engine does not appear in lists |
|
47 |
HTON_BIT_FLUSH_AFTER_RENAME, |
|
48 |
HTON_BIT_NOT_USER_SELECTABLE, |
|
49 |
HTON_BIT_TEMPORARY_NOT_SUPPORTED, // Having temporary tables not supported |
|
50 |
HTON_BIT_SUPPORT_LOG_TABLES, // Engine supports log tables |
|
51 |
HTON_BIT_NO_PARTITION, // You can not partition these tables |
|
52 |
HTON_BIT_SIZE
|
|
53 |
};
|
|
54 |
||
55 |
static const std::bitset<HTON_BIT_SIZE> HTON_NO_FLAGS(0); |
|
56 |
static const std::bitset<HTON_BIT_SIZE> HTON_CLOSE_CURSORS_AT_COMMIT(1 << HTON_BIT_CLOSE_CURSORS_AT_COMMIT); |
|
57 |
static const std::bitset<HTON_BIT_SIZE> HTON_ALTER_NOT_SUPPORTED(1 << HTON_BIT_ALTER_NOT_SUPPORTED); |
|
58 |
static const std::bitset<HTON_BIT_SIZE> HTON_CAN_RECREATE(1 << HTON_BIT_CAN_RECREATE); |
|
59 |
static const std::bitset<HTON_BIT_SIZE> HTON_HIDDEN(1 << HTON_BIT_HIDDEN); |
|
60 |
static const std::bitset<HTON_BIT_SIZE> HTON_FLUSH_AFTER_RENAME(1 << HTON_BIT_FLUSH_AFTER_RENAME); |
|
61 |
static const std::bitset<HTON_BIT_SIZE> HTON_NOT_USER_SELECTABLE(1 << HTON_BIT_NOT_USER_SELECTABLE); |
|
62 |
static const std::bitset<HTON_BIT_SIZE> HTON_TEMPORARY_NOT_SUPPORTED(1 << HTON_BIT_TEMPORARY_NOT_SUPPORTED); |
|
63 |
static const std::bitset<HTON_BIT_SIZE> HTON_SUPPORT_LOG_TABLES(1 << HTON_BIT_SUPPORT_LOG_TABLES); |
|
64 |
static const std::bitset<HTON_BIT_SIZE> HTON_NO_PARTITION(1 << HTON_BIT_NO_PARTITION); |
|
65 |
||
575.1.3
by Monty Taylor
Moved some stuff out of handler.h. |
66 |
/*
|
67 |
handlerton is a singleton structure - one instance per storage engine -
|
|
68 |
to provide access to storage engine functionality that works on the
|
|
69 |
"global" level (unlike handler class that works on a per-table basis)
|
|
70 |
||
71 |
usually handlerton instance is defined statically in ha_xxx.cc as
|
|
72 |
||
73 |
static handlerton { ... } xxx_hton;
|
|
74 |
||
75 |
savepoint_*, prepare, recover, and *_by_xid pointers can be 0.
|
|
76 |
*/
|
|
77 |
struct handlerton |
|
78 |
{
|
|
79 |
/*
|
|
584.2.5
by Stewart Smith
store a protobuf tabledefinition along with FRM |
80 |
Name used for storage engine.
|
81 |
*/
|
|
82 |
const char *name; |
|
83 |
||
84 |
/*
|
|
575.1.3
by Monty Taylor
Moved some stuff out of handler.h. |
85 |
Historical marker for if the engine is available of not
|
86 |
*/
|
|
87 |
SHOW_COMP_OPTION state; |
|
88 |
||
89 |
/*
|
|
90 |
Historical number used for frm file to determine the correct storage engine.
|
|
91 |
This is going away and new engines will just use "name" for this.
|
|
92 |
*/
|
|
93 |
enum legacy_db_type db_type; |
|
94 |
/*
|
|
95 |
each storage engine has it's own memory area (actually a pointer)
|
|
96 |
in the session, for storing per-connection information.
|
|
97 |
It is accessed as
|
|
98 |
||
99 |
session->ha_data[xxx_hton.slot]
|
|
100 |
||
101 |
slot number is initialized by MySQL after xxx_init() is called.
|
|
102 |
*/
|
|
103 |
uint32_t slot; |
|
104 |
/*
|
|
105 |
to store per-savepoint data storage engine is provided with an area
|
|
106 |
of a requested size (0 is ok here).
|
|
107 |
savepoint_offset must be initialized statically to the size of
|
|
108 |
the needed memory to store per-savepoint information.
|
|
109 |
After xxx_init it is changed to be an offset to savepoint storage
|
|
110 |
area and need not be used by storage engine.
|
|
111 |
see binlog_hton and binlog_savepoint_set/rollback for an example.
|
|
112 |
*/
|
|
113 |
uint32_t savepoint_offset; |
|
114 |
/*
|
|
115 |
handlerton methods:
|
|
116 |
||
117 |
close_connection is only called if
|
|
118 |
session->ha_data[xxx_hton.slot] is non-zero, so even if you don't need
|
|
119 |
this storage area - set it to something, so that MySQL would know
|
|
120 |
this storage engine was accessed in this connection
|
|
121 |
*/
|
|
122 |
int (*close_connection)(handlerton *hton, Session *session); |
|
123 |
/*
|
|
124 |
sv points to an uninitialized storage area of requested size
|
|
125 |
(see savepoint_offset description)
|
|
126 |
*/
|
|
127 |
int (*savepoint_set)(handlerton *hton, Session *session, void *sv); |
|
128 |
/*
|
|
129 |
sv points to a storage area, that was earlier passed
|
|
130 |
to the savepoint_set call
|
|
131 |
*/
|
|
132 |
int (*savepoint_rollback)(handlerton *hton, Session *session, void *sv); |
|
133 |
int (*savepoint_release)(handlerton *hton, Session *session, void *sv); |
|
134 |
/*
|
|
135 |
'all' is true if it's a real commit, that makes persistent changes
|
|
136 |
'all' is false if it's not in fact a commit but an end of the
|
|
137 |
statement that is part of the transaction.
|
|
138 |
NOTE 'all' is also false in auto-commit mode where 'end of statement'
|
|
139 |
and 'real commit' mean the same event.
|
|
140 |
*/
|
|
141 |
int (*commit)(handlerton *hton, Session *session, bool all); |
|
142 |
int (*rollback)(handlerton *hton, Session *session, bool all); |
|
143 |
int (*prepare)(handlerton *hton, Session *session, bool all); |
|
144 |
int (*recover)(handlerton *hton, XID *xid_list, uint32_t len); |
|
145 |
int (*commit_by_xid)(handlerton *hton, XID *xid); |
|
146 |
int (*rollback_by_xid)(handlerton *hton, XID *xid); |
|
147 |
handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root); |
|
148 |
void (*drop_database)(handlerton *hton, char* path); |
|
149 |
int (*start_consistent_snapshot)(handlerton *hton, Session *session); |
|
150 |
bool (*flush_logs)(handlerton *hton); |
|
151 |
bool (*show_status)(handlerton *hton, Session *session, stat_print_fn *print, enum ha_stat_type stat); |
|
152 |
int (*fill_files_table)(handlerton *hton, Session *session, |
|
153 |
TableList *tables, |
|
154 |
class Item *cond); |
|
631.1.2
by Yoshinori Sano
Move hton_flag_bits and HTON_* to handlerton.h. Remove TODOs previously added. |
155 |
std::bitset<HTON_BIT_SIZE> flags; /* global handler flags */ |
575.1.3
by Monty Taylor
Moved some stuff out of handler.h. |
156 |
int (*release_temporary_latches)(handlerton *hton, Session *session); |
157 |
||
158 |
int (*table_exists_in_engine)(handlerton *hton, Session* session, const char *db, |
|
159 |
const char *name); |
|
160 |
uint32_t license; /* Flag for Engine License */ |
|
161 |
void *data; /* Location for engines to keep personal structures */ |
|
162 |
};
|
|
163 |
||
164 |
||
575.1.5
by Monty Taylor
Moved stuff to handlerton.cc |
165 |
/* lookups */
|
166 |
handlerton *ha_default_handlerton(Session *session); |
|
167 |
plugin_ref ha_resolve_by_name(Session *session, const LEX_STRING *name); |
|
168 |
plugin_ref ha_lock_engine(Session *session, handlerton *hton); |
|
169 |
handlerton *ha_resolve_by_legacy_type(Session *session, |
|
170 |
enum legacy_db_type db_type); |
|
171 |
handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc, |
|
172 |
handlerton *db_type); |
|
173 |
handlerton *ha_checktype(Session *session, enum legacy_db_type database_type, |
|
174 |
bool no_substitute, bool report_error); |
|
175 |
||
176 |
enum legacy_db_type ha_legacy_type(const handlerton *db_type); |
|
177 |
const char *ha_resolve_storage_engine_name(const handlerton *db_type); |
|
631.1.2
by Yoshinori Sano
Move hton_flag_bits and HTON_* to handlerton.h. Remove TODOs previously added. |
178 |
bool ha_check_storage_engine_flag(const handlerton *db_type, const hton_flag_bits flag); |
575.1.5
by Monty Taylor
Moved stuff to handlerton.cc |
179 |
bool ha_storage_engine_is_enabled(const handlerton *db_type); |
180 |
LEX_STRING *ha_storage_engine_name(const handlerton *hton); |
|
575.1.3
by Monty Taylor
Moved some stuff out of handler.h. |
181 |
|
182 |
#endif /* DRIZZLED_HANDLERTON_H */ |