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
26
typedef struct st_table_share TABLE_SHARE;
27
typedef bool (stat_print_fn)(Session *session, const char *type, uint32_t type_len,
28
const char *file, uint32_t file_len,
29
const char *status, uint32_t status_len);
30
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
31
extern st_plugin_int *hton2plugin[MAX_HA];
34
handlerton is a singleton structure - one instance per storage engine -
35
to provide access to storage engine functionality that works on the
36
"global" level (unlike handler class that works on a per-table basis)
38
usually handlerton instance is defined statically in ha_xxx.cc as
40
static handlerton { ... } xxx_hton;
42
savepoint_*, prepare, recover, and *_by_xid pointers can be 0.
47
Historical marker for if the engine is available of not
49
SHOW_COMP_OPTION state;
52
Historical number used for frm file to determine the correct storage engine.
53
This is going away and new engines will just use "name" for this.
55
enum legacy_db_type db_type;
57
each storage engine has it's own memory area (actually a pointer)
58
in the session, for storing per-connection information.
61
session->ha_data[xxx_hton.slot]
63
slot number is initialized by MySQL after xxx_init() is called.
67
to store per-savepoint data storage engine is provided with an area
68
of a requested size (0 is ok here).
69
savepoint_offset must be initialized statically to the size of
70
the needed memory to store per-savepoint information.
71
After xxx_init it is changed to be an offset to savepoint storage
72
area and need not be used by storage engine.
73
see binlog_hton and binlog_savepoint_set/rollback for an example.
75
uint32_t savepoint_offset;
79
close_connection is only called if
80
session->ha_data[xxx_hton.slot] is non-zero, so even if you don't need
81
this storage area - set it to something, so that MySQL would know
82
this storage engine was accessed in this connection
84
int (*close_connection)(handlerton *hton, Session *session);
86
sv points to an uninitialized storage area of requested size
87
(see savepoint_offset description)
89
int (*savepoint_set)(handlerton *hton, Session *session, void *sv);
91
sv points to a storage area, that was earlier passed
92
to the savepoint_set call
94
int (*savepoint_rollback)(handlerton *hton, Session *session, void *sv);
95
int (*savepoint_release)(handlerton *hton, Session *session, void *sv);
97
'all' is true if it's a real commit, that makes persistent changes
98
'all' is false if it's not in fact a commit but an end of the
99
statement that is part of the transaction.
100
NOTE 'all' is also false in auto-commit mode where 'end of statement'
101
and 'real commit' mean the same event.
103
int (*commit)(handlerton *hton, Session *session, bool all);
104
int (*rollback)(handlerton *hton, Session *session, bool all);
105
int (*prepare)(handlerton *hton, Session *session, bool all);
106
int (*recover)(handlerton *hton, XID *xid_list, uint32_t len);
107
int (*commit_by_xid)(handlerton *hton, XID *xid);
108
int (*rollback_by_xid)(handlerton *hton, XID *xid);
109
void *(*create_cursor_read_view)(handlerton *hton, Session *session);
110
void (*set_cursor_read_view)(handlerton *hton, Session *session, void *read_view);
111
void (*close_cursor_read_view)(handlerton *hton, Session *session, void *read_view);
112
handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root);
113
void (*drop_database)(handlerton *hton, char* path);
114
int (*start_consistent_snapshot)(handlerton *hton, Session *session);
115
bool (*flush_logs)(handlerton *hton);
116
bool (*show_status)(handlerton *hton, Session *session, stat_print_fn *print, enum ha_stat_type stat);
117
int (*fill_files_table)(handlerton *hton, Session *session,
120
uint32_t flags; /* global handler flags */
121
int (*release_temporary_latches)(handlerton *hton, Session *session);
123
int (*discover)(handlerton *hton, Session* session, const char *db,
125
unsigned char **frmblob,
127
int (*table_exists_in_engine)(handlerton *hton, Session* session, const char *db,
129
uint32_t license; /* Flag for Engine License */
130
void *data; /* Location for engines to keep personal structures */
135
#endif /* DRIZZLED_HANDLERTON_H */