1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
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.
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.
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
20
#ifndef DRIZZLED_HANDLERTON_H
21
#define DRIZZLED_HANDLERTON_H
23
#include <drizzled/definitions.h>
25
#include <drizzled/sql_plugin.h>
32
typedef struct st_mysql_lex_string LEX_STRING;
33
typedef struct st_table_share TABLE_SHARE;
34
typedef bool (stat_print_fn)(Session *session, const char *type, uint32_t type_len,
35
const char *file, uint32_t file_len,
36
const char *status, uint32_t status_len);
37
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
40
handlerton is a singleton structure - one instance per storage engine -
41
to provide access to storage engine functionality that works on the
42
"global" level (unlike handler class that works on a per-table basis)
44
usually handlerton instance is defined statically in ha_xxx.cc as
46
static handlerton { ... } xxx_hton;
48
savepoint_*, prepare, recover, and *_by_xid pointers can be 0.
53
Historical marker for if the engine is available of not
55
SHOW_COMP_OPTION state;
58
Historical number used for frm file to determine the correct storage engine.
59
This is going away and new engines will just use "name" for this.
61
enum legacy_db_type db_type;
63
each storage engine has it's own memory area (actually a pointer)
64
in the session, for storing per-connection information.
67
session->ha_data[xxx_hton.slot]
69
slot number is initialized by MySQL after xxx_init() is called.
73
to store per-savepoint data storage engine is provided with an area
74
of a requested size (0 is ok here).
75
savepoint_offset must be initialized statically to the size of
76
the needed memory to store per-savepoint information.
77
After xxx_init it is changed to be an offset to savepoint storage
78
area and need not be used by storage engine.
79
see binlog_hton and binlog_savepoint_set/rollback for an example.
81
uint32_t savepoint_offset;
85
close_connection is only called if
86
session->ha_data[xxx_hton.slot] is non-zero, so even if you don't need
87
this storage area - set it to something, so that MySQL would know
88
this storage engine was accessed in this connection
90
int (*close_connection)(handlerton *hton, Session *session);
92
sv points to an uninitialized storage area of requested size
93
(see savepoint_offset description)
95
int (*savepoint_set)(handlerton *hton, Session *session, void *sv);
97
sv points to a storage area, that was earlier passed
98
to the savepoint_set call
100
int (*savepoint_rollback)(handlerton *hton, Session *session, void *sv);
101
int (*savepoint_release)(handlerton *hton, Session *session, void *sv);
103
'all' is true if it's a real commit, that makes persistent changes
104
'all' is false if it's not in fact a commit but an end of the
105
statement that is part of the transaction.
106
NOTE 'all' is also false in auto-commit mode where 'end of statement'
107
and 'real commit' mean the same event.
109
int (*commit)(handlerton *hton, Session *session, bool all);
110
int (*rollback)(handlerton *hton, Session *session, bool all);
111
int (*prepare)(handlerton *hton, Session *session, bool all);
112
int (*recover)(handlerton *hton, XID *xid_list, uint32_t len);
113
int (*commit_by_xid)(handlerton *hton, XID *xid);
114
int (*rollback_by_xid)(handlerton *hton, XID *xid);
115
void *(*create_cursor_read_view)(handlerton *hton, Session *session);
116
void (*set_cursor_read_view)(handlerton *hton, Session *session, void *read_view);
117
void (*close_cursor_read_view)(handlerton *hton, Session *session, void *read_view);
118
handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root);
119
void (*drop_database)(handlerton *hton, char* path);
120
int (*start_consistent_snapshot)(handlerton *hton, Session *session);
121
bool (*flush_logs)(handlerton *hton);
122
bool (*show_status)(handlerton *hton, Session *session, stat_print_fn *print, enum ha_stat_type stat);
123
int (*fill_files_table)(handlerton *hton, Session *session,
126
uint32_t flags; /* global handler flags */
127
int (*release_temporary_latches)(handlerton *hton, Session *session);
129
int (*discover)(handlerton *hton, Session* session, const char *db,
131
unsigned char **frmblob,
133
int (*table_exists_in_engine)(handlerton *hton, Session* session, const char *db,
135
uint32_t license; /* Flag for Engine License */
136
void *data; /* Location for engines to keep personal structures */
141
handlerton *ha_default_handlerton(Session *session);
142
plugin_ref ha_resolve_by_name(Session *session, const LEX_STRING *name);
143
plugin_ref ha_lock_engine(Session *session, handlerton *hton);
144
handlerton *ha_resolve_by_legacy_type(Session *session,
145
enum legacy_db_type db_type);
146
handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc,
147
handlerton *db_type);
148
handlerton *ha_checktype(Session *session, enum legacy_db_type database_type,
149
bool no_substitute, bool report_error);
151
enum legacy_db_type ha_legacy_type(const handlerton *db_type);
152
const char *ha_resolve_storage_engine_name(const handlerton *db_type);
153
bool ha_check_storage_engine_flag(const handlerton *db_type, uint32_t flag);
154
bool ha_storage_engine_is_enabled(const handlerton *db_type);
155
LEX_STRING *ha_storage_engine_name(const handlerton *hton);
157
#endif /* DRIZZLED_HANDLERTON_H */