Drizzled Public API Documentation

ha_innodb.h
1 /*****************************************************************************
2 
3 Copyright (C) 2000, 2010, MySQL AB & Innobase Oy. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; version 2 of the License.
8 
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 
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., 51 Franklin
15 St, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 *****************************************************************************/
18 
19 /*
20  This file is based on ha_berkeley.h of MySQL distribution
21 
22  This file defines the Innodb Cursor: the interface between MySQL and
23  Innodb
24 */
25 
26 #pragma once
27 #ifndef INNODB_HANDLER_HA_INNODB_H
28 #define INNODB_HANDLER_HA_INNODB_H
29 
30 #include <drizzled/cursor.h>
31 #include <drizzled/thr_lock.h>
32 #include <drizzled/plugin/transactional_storage_engine.h>
33 
34 using namespace drizzled;
35 
36 /* Structure defines translation table between mysql index and innodb
37 index structures */
39  ulint index_count;
41  ulint array_size;
46 
48 typedef struct st_innobase_share {
51  char table_name[FN_REFLEN];
52  uint use_count;
60  st_innobase_share(const char *arg) :
61  use_count(0)
62  {
63  strncpy(table_name, arg, FN_REFLEN);
64  }
65 
67 
68 
70 struct dict_index_struct;
72 struct row_prebuilt_struct;
73 
75 typedef struct dict_index_struct dict_index_t;
77 typedef struct row_prebuilt_struct row_prebuilt_t;
78 
80 class ha_innobase: public Cursor
81 {
88  THR_LOCK_DATA lock;
92  std::vector<unsigned char> upd_buff;
93  std::vector<unsigned char> key_val_buff;
96  ulong upd_and_key_val_buff_len;
97  /* the length of each of the previous
98  two buffers */
99  uint primary_key;
103  uint last_match_mode;/* match mode of the latest search:
104  ROW_SEL_EXACT, ROW_SEL_EXACT_PREFIX,
105  or undefined */
108  UNIV_INTERN uint store_key_val_for_row(uint keynr, char* buff,
109  uint buff_len, const unsigned char* record);
110  UNIV_INTERN void update_session(Session* session);
111  UNIV_INTERN int change_active_index(uint32_t keynr);
112  UNIV_INTERN int general_fetch(unsigned char* buf, uint32_t direction, uint32_t match_mode);
113  UNIV_INTERN ulint innobase_lock_autoinc();
114  UNIV_INTERN uint64_t innobase_peek_autoinc();
115  UNIV_INTERN ulint innobase_set_max_autoinc(uint64_t auto_inc);
116  UNIV_INTERN ulint innobase_reset_autoinc(uint64_t auto_inc);
117  UNIV_INTERN ulint innobase_get_autoinc(uint64_t* value);
118  ulint innobase_update_autoinc(uint64_t auto_inc);
119  UNIV_INTERN void innobase_initialize_autoinc();
120  UNIV_INTERN dict_index_t* innobase_get_index(uint keynr);
121 
122  /* Init values for the class: */
123  public:
124  UNIV_INTERN ha_innobase(plugin::StorageEngine &engine,
125  Table &table_arg);
126  UNIV_INTERN ~ha_innobase();
135  UNIV_INTERN plugin::TransactionalStorageEngine *getTransactionalEngine()
136  {
137  return static_cast<plugin::TransactionalStorageEngine *>(getEngine());
138  }
139 
140  UNIV_INTERN const char* index_type(uint key_number);
141  UNIV_INTERN const key_map* keys_to_use_for_scanning();
142 
143  UNIV_INTERN int doOpen(const drizzled::identifier::Table &identifier, int mode, uint test_if_locked);
144  UNIV_INTERN int close(void);
145  UNIV_INTERN double scan_time();
146  UNIV_INTERN double read_time(uint index, uint ranges, ha_rows rows);
147 
148  UNIV_INTERN int doInsertRecord(unsigned char * buf);
149  UNIV_INTERN int doUpdateRecord(const unsigned char * old_data, unsigned char * new_data);
150  UNIV_INTERN int doDeleteRecord(const unsigned char * buf);
151  UNIV_INTERN bool was_semi_consistent_read();
152  UNIV_INTERN void try_semi_consistent_read(bool yes);
153  UNIV_INTERN void unlock_row();
154 
155  UNIV_INTERN int doStartIndexScan(uint index, bool sorted);
156  UNIV_INTERN int doEndIndexScan();
157  UNIV_INTERN int index_read(unsigned char * buf, const unsigned char * key,
158  uint key_len, enum ha_rkey_function find_flag);
159  UNIV_INTERN int index_read_idx(unsigned char * buf, uint index, const unsigned char * key,
160  uint key_len, enum ha_rkey_function find_flag);
161  UNIV_INTERN int index_read_last(unsigned char * buf, const unsigned char * key, uint key_len);
162  UNIV_INTERN int index_next(unsigned char * buf);
163  UNIV_INTERN int index_next_same(unsigned char * buf, const unsigned char *key, uint keylen);
164  UNIV_INTERN int index_prev(unsigned char * buf);
165  UNIV_INTERN int index_first(unsigned char * buf);
166  UNIV_INTERN int index_last(unsigned char * buf);
167 
168  UNIV_INTERN int doStartTableScan(bool scan);
169  UNIV_INTERN int doEndTableScan();
170  UNIV_INTERN int rnd_next(unsigned char *buf);
171  UNIV_INTERN int rnd_pos(unsigned char * buf, unsigned char *pos);
172 
173  UNIV_INTERN void position(const unsigned char *record);
174  UNIV_INTERN int info(uint);
175  UNIV_INTERN int analyze(Session* session);
176  UNIV_INTERN int discard_or_import_tablespace(bool discard);
177  UNIV_INTERN int extra(enum ha_extra_function operation);
178  UNIV_INTERN int reset();
179  UNIV_INTERN int external_lock(Session *session, int lock_type);
180  void position(unsigned char *record);
181  UNIV_INTERN ha_rows records_in_range(uint inx, key_range *min_key, key_range
182  *max_key);
183  UNIV_INTERN ha_rows estimate_rows_upper_bound();
184 
185  UNIV_INTERN int delete_all_rows();
186  UNIV_INTERN int check(Session* session);
187  UNIV_INTERN char* update_table_comment(const char* comment);
188  UNIV_INTERN char* get_foreign_key_create_info();
189  UNIV_INTERN int get_foreign_key_list(Session *session, List<ForeignKeyInfo> *f_key_list);
190  UNIV_INTERN bool can_switch_engines();
191  UNIV_INTERN uint referenced_by_foreign_key();
192  UNIV_INTERN void free_foreign_key_create_info(char* str);
193  UNIV_INTERN THR_LOCK_DATA **store_lock(Session *session, THR_LOCK_DATA **to,
194  enum thr_lock_type lock_type);
195  UNIV_INTERN virtual void get_auto_increment(uint64_t offset,
196  uint64_t increment,
197  uint64_t nb_desired_values,
198  uint64_t *first_value,
199  uint64_t *nb_reserved_values);
200  UNIV_INTERN int reset_auto_increment(uint64_t value);
201 
202  UNIV_INTERN bool primary_key_is_clustered();
203  UNIV_INTERN int cmp_ref(const unsigned char *ref1, const unsigned char *ref2);
205  // Don't use these, I have just left them in here as reference for
206  // the future. -Brian
207 #if 0
208  UNIV_INTERN int add_index(Session *session, TABLE *table_arg, KeyInfo *key_info, uint num_of_keys);
209  UNIV_INTERN int prepare_drop_index(Session *session,
210  TABLE *table_arg,
211  uint *key_num,
212  uint num_of_keys);
213  UNIV_INTERN int final_drop_index(Session *session, TABLE *table_arg);
214 #endif
215 
216 public:
217  int read_range_first(const key_range *start_key, const key_range *end_key,
218  bool eq_range_arg, bool sorted);
219  int read_range_next();
220 };
221 
222 
226 const char* drizzle_bin_log_file_name(void);
227 
231 uint64_t drizzle_bin_log_file_pos(void);
232 
239 int session_slave_thread(const Session *session);
240 
241 typedef struct trx_struct trx_t;
242 /********************************************************************/
248 UNIV_INTERN
249 int
251 /*========================*/
252  int error,
253  ulint flags,
254  Session *session);
256 /*********************************************************************/
259 UNIV_INTERN
260 trx_t*
262 /*==================*/
263  Session *session);
265 /***********************************************************************
266 This function checks each index name for a table against reserved
267 system default primary index name 'GEN_CLUST_INDEX'. If a name matches,
268 this function pushes an error message to the client, and returns true. */
269 bool
270 innobase_index_name_is_reserved(
271 /*============================*/
272  /* out: true if index name matches a
273  reserved name */
274  const trx_t* trx, /* in: InnoDB transaction handle */
275  const drizzled::KeyInfo* key_info,/* in: Indexes to be created */
276  ulint num_of_keys); /* in: Number of indexes to
277  be created. */
278 
279 #endif /* INNODB_HANDLER_HA_INNODB_H */
void * table_name_hash
Definition: ha_innodb.h:55
INNOBASE_SHARE * share
Definition: ha_innodb.h:89
Session * user_session
Definition: ha_innodb.h:85
TODO: Rename this file - func.h is stupid.
UNIV_INTERN plugin::TransactionalStorageEngine * getTransactionalEngine()
Definition: ha_innodb.h:135
uint num_write_row
Definition: ha_innodb.h:106
dict_index_t ** index_mapping
Definition: ha_innodb.h:42
UNIV_INTERN int convert_error_code_to_mysql(int error, ulint flags, Session *session)
Definition: ha_innodb.cc:1120
std::vector< unsigned char > key_val_buff
Definition: ha_innodb.h:93
row_prebuilt_t * prebuilt
Definition: ha_innodb.h:82
THR_LOCK lock
Definition: ha_innodb.h:49
std::vector< unsigned char > upd_buff
Definition: ha_innodb.h:92
UNIV_INTERN trx_t * innobase_trx_allocate(Session *session)
Definition: ha_innodb.cc:1638
innodb_idx_translate_t idx_trans_tbl
Definition: ha_innodb.h:56
ulong start_of_scan
Definition: ha_innodb.h:100