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> |
24 |
||
575.1.5
by Monty Taylor
Moved stuff to handlerton.cc |
25 |
#include <drizzled/definitions.h> |
26 |
#include <drizzled/sql_plugin.h> |
|
575.1.3
by Monty Taylor
Moved some stuff out of handler.h. |
27 |
|
28 |
class TableList; |
|
575.1.5
by Monty Taylor
Moved stuff to handlerton.cc |
29 |
class Session; |
30 |
class XID; |
|
31 |
class handler; |
|
32 |
||
33 |
typedef struct st_mysql_lex_string LEX_STRING; |
|
575.1.3
by Monty Taylor
Moved some stuff out of handler.h. |
34 |
typedef struct st_table_share TABLE_SHARE; |
35 |
typedef bool (stat_print_fn)(Session *session, const char *type, uint32_t type_len, |
|
36 |
const char *file, uint32_t file_len, |
|
37 |
const char *status, uint32_t status_len); |
|
38 |
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX }; |
|
39 |
||
40 |
/*
|
|
41 |
handlerton is a singleton structure - one instance per storage engine -
|
|
42 |
to provide access to storage engine functionality that works on the
|
|
43 |
"global" level (unlike handler class that works on a per-table basis)
|
|
44 |
||
45 |
usually handlerton instance is defined statically in ha_xxx.cc as
|
|
46 |
||
47 |
static handlerton { ... } xxx_hton;
|
|
48 |
||
49 |
savepoint_*, prepare, recover, and *_by_xid pointers can be 0.
|
|
50 |
*/
|
|
51 |
struct handlerton |
|
52 |
{
|
|
53 |
/*
|
|
584.2.5
by Stewart Smith
store a protobuf tabledefinition along with FRM |
54 |
Name used for storage engine.
|
55 |
*/
|
|
56 |
const char *name; |
|
57 |
||
58 |
/*
|
|
575.1.3
by Monty Taylor
Moved some stuff out of handler.h. |
59 |
Historical marker for if the engine is available of not
|
60 |
*/
|
|
61 |
SHOW_COMP_OPTION state; |
|
62 |
||
63 |
/*
|
|
64 |
Historical number used for frm file to determine the correct storage engine.
|
|
65 |
This is going away and new engines will just use "name" for this.
|
|
66 |
*/
|
|
67 |
enum legacy_db_type db_type; |
|
68 |
/*
|
|
69 |
each storage engine has it's own memory area (actually a pointer)
|
|
70 |
in the session, for storing per-connection information.
|
|
71 |
It is accessed as
|
|
72 |
||
73 |
session->ha_data[xxx_hton.slot]
|
|
74 |
||
75 |
slot number is initialized by MySQL after xxx_init() is called.
|
|
76 |
*/
|
|
77 |
uint32_t slot; |
|
78 |
/*
|
|
79 |
to store per-savepoint data storage engine is provided with an area
|
|
80 |
of a requested size (0 is ok here).
|
|
81 |
savepoint_offset must be initialized statically to the size of
|
|
82 |
the needed memory to store per-savepoint information.
|
|
83 |
After xxx_init it is changed to be an offset to savepoint storage
|
|
84 |
area and need not be used by storage engine.
|
|
85 |
see binlog_hton and binlog_savepoint_set/rollback for an example.
|
|
86 |
*/
|
|
87 |
uint32_t savepoint_offset; |
|
88 |
/*
|
|
89 |
handlerton methods:
|
|
90 |
||
91 |
close_connection is only called if
|
|
92 |
session->ha_data[xxx_hton.slot] is non-zero, so even if you don't need
|
|
93 |
this storage area - set it to something, so that MySQL would know
|
|
94 |
this storage engine was accessed in this connection
|
|
95 |
*/
|
|
96 |
int (*close_connection)(handlerton *hton, Session *session); |
|
97 |
/*
|
|
98 |
sv points to an uninitialized storage area of requested size
|
|
99 |
(see savepoint_offset description)
|
|
100 |
*/
|
|
101 |
int (*savepoint_set)(handlerton *hton, Session *session, void *sv); |
|
102 |
/*
|
|
103 |
sv points to a storage area, that was earlier passed
|
|
104 |
to the savepoint_set call
|
|
105 |
*/
|
|
106 |
int (*savepoint_rollback)(handlerton *hton, Session *session, void *sv); |
|
107 |
int (*savepoint_release)(handlerton *hton, Session *session, void *sv); |
|
108 |
/*
|
|
109 |
'all' is true if it's a real commit, that makes persistent changes
|
|
110 |
'all' is false if it's not in fact a commit but an end of the
|
|
111 |
statement that is part of the transaction.
|
|
112 |
NOTE 'all' is also false in auto-commit mode where 'end of statement'
|
|
113 |
and 'real commit' mean the same event.
|
|
114 |
*/
|
|
115 |
int (*commit)(handlerton *hton, Session *session, bool all); |
|
116 |
int (*rollback)(handlerton *hton, Session *session, bool all); |
|
117 |
int (*prepare)(handlerton *hton, Session *session, bool all); |
|
118 |
int (*recover)(handlerton *hton, XID *xid_list, uint32_t len); |
|
119 |
int (*commit_by_xid)(handlerton *hton, XID *xid); |
|
120 |
int (*rollback_by_xid)(handlerton *hton, XID *xid); |
|
121 |
void *(*create_cursor_read_view)(handlerton *hton, Session *session); |
|
122 |
void (*set_cursor_read_view)(handlerton *hton, Session *session, void *read_view); |
|
123 |
void (*close_cursor_read_view)(handlerton *hton, Session *session, void *read_view); |
|
124 |
handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root); |
|
125 |
void (*drop_database)(handlerton *hton, char* path); |
|
126 |
int (*start_consistent_snapshot)(handlerton *hton, Session *session); |
|
127 |
bool (*flush_logs)(handlerton *hton); |
|
128 |
bool (*show_status)(handlerton *hton, Session *session, stat_print_fn *print, enum ha_stat_type stat); |
|
129 |
int (*fill_files_table)(handlerton *hton, Session *session, |
|
130 |
TableList *tables, |
|
131 |
class Item *cond); |
|
132 |
uint32_t flags; /* global handler flags */ |
|
133 |
int (*release_temporary_latches)(handlerton *hton, Session *session); |
|
134 |
||
135 |
int (*discover)(handlerton *hton, Session* session, const char *db, |
|
136 |
const char *name, |
|
137 |
unsigned char **frmblob, |
|
138 |
size_t *frmlen); |
|
139 |
int (*table_exists_in_engine)(handlerton *hton, Session* session, const char *db, |
|
140 |
const char *name); |
|
141 |
uint32_t license; /* Flag for Engine License */ |
|
142 |
void *data; /* Location for engines to keep personal structures */ |
|
143 |
};
|
|
144 |
||
145 |
||
575.1.5
by Monty Taylor
Moved stuff to handlerton.cc |
146 |
/* lookups */
|
147 |
handlerton *ha_default_handlerton(Session *session); |
|
148 |
plugin_ref ha_resolve_by_name(Session *session, const LEX_STRING *name); |
|
149 |
plugin_ref ha_lock_engine(Session *session, handlerton *hton); |
|
150 |
handlerton *ha_resolve_by_legacy_type(Session *session, |
|
151 |
enum legacy_db_type db_type); |
|
152 |
handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc, |
|
153 |
handlerton *db_type); |
|
154 |
handlerton *ha_checktype(Session *session, enum legacy_db_type database_type, |
|
155 |
bool no_substitute, bool report_error); |
|
156 |
||
157 |
enum legacy_db_type ha_legacy_type(const handlerton *db_type); |
|
158 |
const char *ha_resolve_storage_engine_name(const handlerton *db_type); |
|
159 |
bool ha_check_storage_engine_flag(const handlerton *db_type, uint32_t flag); |
|
160 |
bool ha_storage_engine_is_enabled(const handlerton *db_type); |
|
161 |
LEX_STRING *ha_storage_engine_name(const handlerton *hton); |
|
575.1.3
by Monty Taylor
Moved some stuff out of handler.h. |
162 |
|
163 |
#endif /* DRIZZLED_HANDLERTON_H */ |