20
20
This file is based on ha_berkeley.h of MySQL distribution
22
This file defines the Innodb Cursor: the interface between MySQL and
22
This file defines the Innodb handler: the interface between MySQL and
26
26
#ifndef INNODB_HANDLER_HA_INNODB_H
27
27
#define INNODB_HANDLER_HA_INNODB_H
29
#include <drizzled/cursor.h>
30
#include <drizzled/thr_lock.h>
31
#include <drizzled/plugin/transactional_storage_engine.h>
33
using namespace drizzled;
34
/** InnoDB table share */
29
#include <drizzled/handler.h>
30
#include <mysys/thr_lock.h>
32
#ifdef USE_PRAGMA_INTERFACE
33
#pragma interface /* gcc class implementation */
35
36
typedef struct st_innobase_share {
36
THR_LOCK lock; /*!< MySQL lock protecting
38
const char* table_name; /*!< InnoDB table name */
39
uint use_count; /*!< reference count,
40
incremented in get_share()
41
and decremented in free_share() */
42
void* table_name_hash;/*!< hash table chain node */
38
pthread_mutex_t mutex;
39
const char* table_name;
41
void* table_name_hash;
46
/** InnoDB B-tree index */
47
45
struct dict_index_struct;
48
/** Prebuilt structures in an Innobase table handle used within MySQL */
49
46
struct row_prebuilt_struct;
51
/** InnoDB B-tree index */
52
48
typedef struct dict_index_struct dict_index_t;
53
/** Prebuilt structures in an Innobase table handle used within MySQL */
54
49
typedef struct row_prebuilt_struct row_prebuilt_t;
56
/** The class defining a handle to an Innodb table */
57
class ha_innobase: public Cursor
51
/* The class defining a handle to an Innodb table */
52
class ha_innobase: public handler
59
row_prebuilt_t* prebuilt; /*!< prebuilt struct in InnoDB, used
54
row_prebuilt_t* prebuilt; /* prebuilt struct in InnoDB, used
60
55
to save CPU time with prebuilt data
62
Session* user_session; /*!< the thread handle of the user
57
Session* user_session; /* the thread handle of the user
63
58
currently using the handle; this is
64
59
set in external_lock function */
65
60
THR_LOCK_DATA lock;
66
INNOBASE_SHARE* share; /*!< information for MySQL
61
INNOBASE_SHARE *share;
69
unsigned char* upd_buff; /*!< buffer used in updates */
70
unsigned char* key_val_buff; /*!< buffer used in converting
63
unsigned char* upd_buff; /* buffer used in updates */
64
unsigned char* key_val_buff; /* buffer used in converting
71
65
search key values from MySQL format
72
66
to Innodb format */
73
67
ulong upd_and_key_val_buff_len;
74
68
/* the length of each of the previous
70
Table_flags int_table_flags;
77
ulong start_of_scan; /*!< this is set to 1 when we are
72
ulong start_of_scan; /* this is set to 1 when we are
78
73
starting a table scan but have not
79
74
yet fetched any row, else 0 */
80
75
uint last_match_mode;/* match mode of the latest search:
81
76
ROW_SEL_EXACT, ROW_SEL_EXACT_PREFIX,
83
uint num_write_row; /*!< number of write_row() calls */
78
uint num_write_row; /* number of write_row() calls */
85
80
UNIV_INTERN uint store_key_val_for_row(uint keynr, char* buff,
86
81
uint buff_len, const unsigned char* record);
90
85
UNIV_INTERN int general_fetch(unsigned char* buf, uint32_t direction, uint32_t match_mode);
91
86
UNIV_INTERN ulint innobase_lock_autoinc();
92
87
UNIV_INTERN uint64_t innobase_peek_autoinc();
93
UNIV_INTERN ulint innobase_set_max_autoinc(uint64_t auto_inc);
94
UNIV_INTERN ulint innobase_reset_autoinc(uint64_t auto_inc);
88
ulint innobase_set_max_autoinc(uint64_t auto_inc);
89
ulint innobase_reset_autoinc(uint64_t auto_inc);
95
90
UNIV_INTERN ulint innobase_get_autoinc(uint64_t* value);
96
91
ulint innobase_update_autoinc(uint64_t auto_inc);
97
92
UNIV_INTERN ulint innobase_initialize_autoinc();
101
96
/* Init values for the class: */
103
UNIV_INTERN ha_innobase(plugin::StorageEngine &engine,
104
TableShare &table_arg);
98
UNIV_INTERN ha_innobase(StorageEngine *engine, TableShare *table_arg);
105
99
UNIV_INTERN ~ha_innobase();
107
* Returns the plugin::TransactionStorageEngine pointer
108
* of the cursor's underlying engine.
112
* Have a TransactionalCursor subclass...
114
UNIV_INTERN plugin::TransactionalStorageEngine *getTransactionalEngine()
116
return static_cast<plugin::TransactionalStorageEngine *>(engine);
120
101
Get the row type from the storage engine. If this method returns
121
102
ROW_TYPE_NOT_USED, the information in HA_CREATE_INFO should be used.
123
104
UNIV_INTERN enum row_type get_row_type() const;
125
106
UNIV_INTERN const char* index_type(uint key_number);
107
UNIV_INTERN Table_flags table_flags() const;
108
UNIV_INTERN uint32_t index_flags(uint idx, uint part, bool all_parts) const;
109
UNIV_INTERN uint32_t max_supported_keys() const;
110
UNIV_INTERN uint32_t max_supported_key_length() const;
111
UNIV_INTERN uint32_t max_supported_key_part_length() const;
126
112
UNIV_INTERN const key_map* keys_to_use_for_scanning();
128
114
UNIV_INTERN int open(const char *name, int mode, uint test_if_locked);
137
123
UNIV_INTERN void try_semi_consistent_read(bool yes);
138
124
UNIV_INTERN void unlock_row();
126
#ifdef ROW_MERGE_IS_INDEX_USABLE
127
/** Check if an index can be used by this transaction.
128
* @param keynr key number to check
129
* @return true if available, false if the index
130
* does not contain old records that exist
131
* in the read view of this transaction */
132
bool is_index_available(uint keynr);
133
#endif /* ROW_MERGE_IS_INDEX_USABLE */
140
134
UNIV_INTERN int index_init(uint index, bool sorted);
141
135
UNIV_INTERN int index_end();
142
UNIV_INTERN int index_read(unsigned char * buf, const unsigned char * key,
143
uint key_len, enum ha_rkey_function find_flag);
136
UNIV_INTERN int index_read(unsigned char * buf,
137
const unsigned char * key, uint key_len,
138
enum ha_rkey_function find_flag);
144
139
UNIV_INTERN int index_read_idx(unsigned char * buf, uint index, const unsigned char * key,
145
140
uint key_len, enum ha_rkey_function find_flag);
146
141
UNIV_INTERN int index_read_last(unsigned char * buf, const unsigned char * key, uint key_len);
158
153
UNIV_INTERN void position(const unsigned char *record);
159
154
UNIV_INTERN int info(uint);
160
UNIV_INTERN int analyze(Session* session);
155
UNIV_INTERN int analyze(Session* session,HA_CHECK_OPT* check_opt);
156
UNIV_INTERN int optimize(Session* session,HA_CHECK_OPT* check_opt);
161
157
UNIV_INTERN int discard_or_import_tablespace(bool discard);
162
158
UNIV_INTERN int extra(enum ha_extra_function operation);
163
159
UNIV_INTERN int reset();
164
160
UNIV_INTERN int external_lock(Session *session, int lock_type);
161
UNIV_INTERN int start_stmt(Session *session, thr_lock_type lock_type);
165
162
void position(unsigned char *record);
166
163
UNIV_INTERN ha_rows records_in_range(uint inx, key_range *min_key, key_range
168
165
UNIV_INTERN ha_rows estimate_rows_upper_bound();
167
UNIV_INTERN void update_create_info(HA_CREATE_INFO* create_info);
170
168
UNIV_INTERN int delete_all_rows();
171
UNIV_INTERN int check(Session* session);
169
UNIV_INTERN int check(Session* session, HA_CHECK_OPT* check_opt);
172
170
UNIV_INTERN char* update_table_comment(const char* comment);
173
171
UNIV_INTERN char* get_foreign_key_create_info();
174
172
UNIV_INTERN int get_foreign_key_list(Session *session, List<FOREIGN_KEY_INFO> *f_key_list);
238
249
typedef struct trx_struct trx_t;
239
/********************************************************************//**
240
@file Cursor/ha_innodb.h
250
/************************************************************************
241
251
Converts an InnoDB error code to a MySQL error code and also tells to MySQL
242
252
about a possible transaction rollback inside InnoDB caused by a lock wait
243
timeout or a deadlock.
244
@return MySQL error code */
253
timeout or a deadlock. */
245
254
extern "C" UNIV_INTERN
247
256
convert_error_code_to_mysql(
248
257
/*========================*/
249
int error, /*!< in: InnoDB error code */
250
ulint flags, /*!< in: InnoDB table flags, or 0 */
251
Session *session); /*!< in: user thread handle or NULL */
258
/* out: MySQL error code */
259
int error, /* in: InnoDB error code */
260
ulint flags, /* in: InnoDB table flags, or 0 */
261
Session *session); /* in: user thread handle or NULL */
253
/*********************************************************************//**
254
Allocates an InnoDB transaction for a MySQL Cursor object.
255
@return InnoDB transaction handle */
263
/*************************************************************************
264
Allocates an InnoDB transaction for a MySQL handler object. */
256
265
extern "C" UNIV_INTERN
258
267
innobase_trx_allocate(
259
268
/*==================*/
260
Session *session); /*!< in: user thread handle */
269
/* out: InnoDB transaction handle */
270
Session *session); /* in: user thread handle */
261
271
#endif /* INNODB_HANDLER_HA_INNODB_H */