1
1
/*****************************************************************************
3
Copyright (c) 2000, 2009, MySQL AB & Innobase Oy. All Rights Reserved.
3
Copyright (C) 2000, 2010, MySQL AB & Innobase Oy. All Rights Reserved.
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
11
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
14
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
17
17
*****************************************************************************/
31
31
#include <drizzled/plugin/transactional_storage_engine.h>
33
33
using namespace drizzled;
35
/* Structure defines translation table between mysql index and innodb
37
typedef struct innodb_idx_translate_struct {
38
ulint index_count; /*!< number of valid index entries
39
in the index_mapping array */
40
ulint array_size; /*!< array size of index_mapping */
41
dict_index_t** index_mapping; /*!< index pointer array directly
42
maps to index in Innodb from MySQL
44
} innodb_idx_translate_t;
34
46
/** InnoDB table share */
35
47
typedef struct st_innobase_share {
36
48
THR_LOCK lock; /*!< MySQL lock protecting
38
const char* table_name; /*!< InnoDB table name */
50
char table_name[FN_REFLEN]; /*!< InnoDB table name */
39
51
uint use_count; /*!< reference count,
40
52
incremented in get_share()
41
53
and decremented in free_share() */
42
54
void* table_name_hash;/*!< hash table chain node */
55
innodb_idx_translate_t idx_trans_tbl; /*!< index translation
56
table between MySQL and
59
st_innobase_share(const char *arg) :
62
strncpy(table_name, arg, FN_REFLEN);
66
88
INNOBASE_SHARE* share; /*!< information for MySQL
69
unsigned char* upd_buff; /*!< buffer used in updates */
70
unsigned char* key_val_buff; /*!< buffer used in converting
71
search key values from MySQL format
91
std::vector<unsigned char> upd_buff; /*!< buffer used in updates */
92
std::vector<unsigned char> key_val_buff; /*!< buffer used in converting
93
search key values from MySQL format
73
95
ulong upd_and_key_val_buff_len;
74
96
/* the length of each of the previous
80
102
uint last_match_mode;/* match mode of the latest search:
81
103
ROW_SEL_EXACT, ROW_SEL_EXACT_PREFIX,
83
uint num_write_row; /*!< number of write_row() calls */
105
uint num_write_row; /*!< number of doInsertRecord() calls */
85
107
UNIV_INTERN uint store_key_val_for_row(uint keynr, char* buff,
86
108
uint buff_len, const unsigned char* record);
87
109
UNIV_INTERN void update_session(Session* session);
88
UNIV_INTERN void update_session();
89
110
UNIV_INTERN int change_active_index(uint32_t keynr);
90
111
UNIV_INTERN int general_fetch(unsigned char* buf, uint32_t direction, uint32_t match_mode);
91
112
UNIV_INTERN ulint innobase_lock_autoinc();
94
115
UNIV_INTERN ulint innobase_reset_autoinc(uint64_t auto_inc);
95
116
UNIV_INTERN ulint innobase_get_autoinc(uint64_t* value);
96
117
ulint innobase_update_autoinc(uint64_t auto_inc);
97
UNIV_INTERN ulint innobase_initialize_autoinc();
118
UNIV_INTERN void innobase_initialize_autoinc();
98
119
UNIV_INTERN dict_index_t* innobase_get_index(uint keynr);
99
UNIV_INTERN uint64_t innobase_get_int_col_max_value(const Field* field);
101
121
/* Init values for the class: */
103
123
UNIV_INTERN ha_innobase(plugin::StorageEngine &engine,
104
TableShare &table_arg);
105
125
UNIV_INTERN ~ha_innobase();
107
127
* Returns the plugin::TransactionStorageEngine pointer
114
134
UNIV_INTERN plugin::TransactionalStorageEngine *getTransactionalEngine()
116
return static_cast<plugin::TransactionalStorageEngine *>(engine);
136
return static_cast<plugin::TransactionalStorageEngine *>(getEngine());
120
Get the row type from the storage engine. If this method returns
121
ROW_TYPE_NOT_USED, the information in HA_CREATE_INFO should be used.
123
UNIV_INTERN enum row_type get_row_type() const;
125
139
UNIV_INTERN const char* index_type(uint key_number);
126
140
UNIV_INTERN const key_map* keys_to_use_for_scanning();
128
UNIV_INTERN int open(const char *name, int mode, uint test_if_locked);
142
UNIV_INTERN int doOpen(const drizzled::identifier::Table &identifier, int mode, uint test_if_locked);
129
143
UNIV_INTERN int close(void);
130
144
UNIV_INTERN double scan_time();
131
145
UNIV_INTERN double read_time(uint index, uint ranges, ha_rows rows);
133
UNIV_INTERN int write_row(unsigned char * buf);
134
UNIV_INTERN int update_row(const unsigned char * old_data, unsigned char * new_data);
135
UNIV_INTERN int delete_row(const unsigned char * buf);
147
UNIV_INTERN int doInsertRecord(unsigned char * buf);
148
UNIV_INTERN int doUpdateRecord(const unsigned char * old_data, unsigned char * new_data);
149
UNIV_INTERN int doDeleteRecord(const unsigned char * buf);
136
150
UNIV_INTERN bool was_semi_consistent_read();
137
151
UNIV_INTERN void try_semi_consistent_read(bool yes);
138
152
UNIV_INTERN void unlock_row();
140
UNIV_INTERN int index_init(uint index, bool sorted);
141
UNIV_INTERN int index_end();
154
UNIV_INTERN int doStartIndexScan(uint index, bool sorted);
155
UNIV_INTERN int doEndIndexScan();
142
156
UNIV_INTERN int index_read(unsigned char * buf, const unsigned char * key,
143
157
uint key_len, enum ha_rkey_function find_flag);
144
158
UNIV_INTERN int index_read_idx(unsigned char * buf, uint index, const unsigned char * key,
150
164
UNIV_INTERN int index_first(unsigned char * buf);
151
165
UNIV_INTERN int index_last(unsigned char * buf);
153
UNIV_INTERN int rnd_init(bool scan);
154
UNIV_INTERN int rnd_end();
167
UNIV_INTERN int doStartTableScan(bool scan);
168
UNIV_INTERN int doEndTableScan();
155
169
UNIV_INTERN int rnd_next(unsigned char *buf);
156
170
UNIV_INTERN int rnd_pos(unsigned char * buf, unsigned char *pos);
171
185
UNIV_INTERN int check(Session* session);
172
186
UNIV_INTERN char* update_table_comment(const char* comment);
173
187
UNIV_INTERN char* get_foreign_key_create_info();
174
UNIV_INTERN int get_foreign_key_list(Session *session, List<FOREIGN_KEY_INFO> *f_key_list);
188
UNIV_INTERN int get_foreign_key_list(Session *session, List<ForeignKeyInfo> *f_key_list);
175
189
UNIV_INTERN bool can_switch_engines();
176
190
UNIV_INTERN uint referenced_by_foreign_key();
177
191
UNIV_INTERN void free_foreign_key_create_info(char* str);
187
201
UNIV_INTERN bool primary_key_is_clustered();
188
202
UNIV_INTERN int cmp_ref(const unsigned char *ref1, const unsigned char *ref2);
189
203
/** Fast index creation (smart ALTER TABLE) @see handler0alter.cc @{ */
190
UNIV_INTERN int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys);
191
UNIV_INTERN int prepare_drop_index(TABLE *table_arg, uint *key_num,
204
// Don't use these, I have just left them in here as reference for
205
// the future. -Brian
207
UNIV_INTERN int add_index(Session *session, TABLE *table_arg, KeyInfo *key_info, uint num_of_keys);
208
UNIV_INTERN int prepare_drop_index(Session *session,
192
211
uint num_of_keys);
193
UNIV_INTERN int final_drop_index(TABLE *table_arg);
212
UNIV_INTERN int final_drop_index(Session *session, TABLE *table_arg);
196
216
int read_range_first(const key_range *start_key, const key_range *end_key,
220
238
int session_slave_thread(const Session *session);
223
Check if a user thread is running a non-transactional update
224
@param session user thread
225
@retval 0 the user thread is not running a non-transactional update
226
@retval 1 the user thread is running a non-transactional update
228
int session_non_transactional_update(const Session *session);
231
Mark transaction to rollback and mark error as fatal to a sub-statement.
232
@param session Thread handle
233
@param all TRUE <=> rollback main transaction.
235
void session_mark_transaction_to_rollback(Session *session, bool all);
238
240
typedef struct trx_struct trx_t;
239
241
/********************************************************************//**
240
242
@file Cursor/ha_innodb.h
253
255
/*********************************************************************//**
254
256
Allocates an InnoDB transaction for a MySQL Cursor object.
255
257
@return InnoDB transaction handle */
256
extern "C" UNIV_INTERN
258
260
innobase_trx_allocate(
259
261
/*==================*/
260
262
Session *session); /*!< in: user thread handle */
264
/***********************************************************************
265
This function checks each index name for a table against reserved
266
system default primary index name 'GEN_CLUST_INDEX'. If a name matches,
267
this function pushes an error message to the client, and returns true. */
269
innobase_index_name_is_reserved(
270
/*============================*/
271
/* out: true if index name matches a
273
const trx_t* trx, /* in: InnoDB transaction handle */
274
const drizzled::KeyInfo* key_info,/* in: Indexes to be created */
275
ulint num_of_keys); /* in: Number of indexes to
261
278
#endif /* INNODB_HANDLER_HA_INNODB_H */