~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/handler/ha_innodb.h

  • Committer: Padraig O'Sullivan
  • Date: 2009-07-30 02:39:13 UTC
  • mto: (1115.3.11 captain)
  • mto: This revision was merged to the branch mainline in revision 1121.
  • Revision ID: osullivan.padraig@gmail.com-20090730023913-o2zuocp32l6btnc2
Removing references to MY_BITMAP throughout the code base and updating calls
to MyBitmap in various places to use the new interface.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
/*
20
20
  This file is based on ha_berkeley.h of MySQL distribution
21
21
 
22
 
  This file defines the Innodb Cursor: the interface between MySQL and
 
22
  This file defines the Innodb handler: the interface between MySQL and
23
23
  Innodb
24
24
*/
25
25
 
26
26
#ifndef INNODB_HANDLER_HA_INNODB_H
27
27
#define INNODB_HANDLER_HA_INNODB_H
28
28
 
29
 
#include <drizzled/cursor.h>
30
 
#include <drizzled/thr_lock.h>
31
 
#include <drizzled/plugin/transactional_storage_engine.h>
32
 
 
33
 
using namespace drizzled;
34
 
/** InnoDB table share */
 
29
#include <drizzled/handler.h>
 
30
#include <mysys/thr_lock.h>
 
31
 
 
32
#ifdef USE_PRAGMA_INTERFACE
 
33
#pragma interface                       /* gcc class implementation */
 
34
#endif
 
35
 
35
36
typedef struct st_innobase_share {
36
 
        THR_LOCK        lock;           /*!< MySQL lock protecting
37
 
                                        this structure */
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 */
 
37
  THR_LOCK lock;
 
38
  pthread_mutex_t mutex;
 
39
  const char* table_name;
 
40
  uint use_count;
 
41
  void* table_name_hash;
43
42
} INNOBASE_SHARE;
44
43
 
45
44
 
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;
50
47
 
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;
55
50
 
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
58
53
{
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
61
56
                                        structures*/
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
67
 
                                        table locking */
 
61
        INNOBASE_SHARE  *share;
68
62
 
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
75
69
                                        two buffers */
 
70
        Table_flags     int_table_flags;
76
71
        uint            primary_key;
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,
82
77
                                        or undefined */
83
 
        uint            num_write_row;  /*!< number of write_row() calls */
 
78
        uint            num_write_row;  /* number of write_row() calls */
84
79
 
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();
100
95
 
101
96
        /* Init values for the class: */
102
97
 public:
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();
106
 
  /**
107
 
   * Returns the plugin::TransactionStorageEngine pointer
108
 
   * of the cursor's underlying engine.
109
 
   *
110
 
   * @todo
111
 
   *
112
 
   * Have a TransactionalCursor subclass...
113
 
   */
114
 
  UNIV_INTERN plugin::TransactionalStorageEngine *getTransactionalEngine()
115
 
  {
116
 
    return static_cast<plugin::TransactionalStorageEngine *>(engine);
117
 
  }
118
 
 
119
100
        /*
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;
124
105
 
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();
127
113
 
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();
139
125
 
 
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);
157
152
 
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
167
164
                                                                *max_key);
168
165
        UNIV_INTERN ha_rows estimate_rows_upper_bound();
169
166
 
 
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);
177
175
        UNIV_INTERN void free_foreign_key_create_info(char* str);
178
176
        UNIV_INTERN THR_LOCK_DATA **store_lock(Session *session, THR_LOCK_DATA **to,
179
177
                                        enum thr_lock_type lock_type);
 
178
        UNIV_INTERN void init_table_handle_for_HANDLER();
180
179
        UNIV_INTERN virtual void get_auto_increment(uint64_t offset, 
181
180
                                                    uint64_t increment,
182
181
                                                    uint64_t nb_desired_values,
184
183
                                                    uint64_t *nb_reserved_values);
185
184
        UNIV_INTERN int reset_auto_increment(uint64_t value);
186
185
 
 
186
        UNIV_INTERN virtual bool get_error_message(int error, String *buf);
 
187
 
187
188
        UNIV_INTERN bool primary_key_is_clustered();
188
189
        UNIV_INTERN int cmp_ref(const unsigned char *ref1, const unsigned char *ref2);
189
190
        /** Fast index creation (smart ALTER TABLE) @see handler0alter.cc @{ */
196
197
  int read_range_first(const key_range *start_key, const key_range *end_key,
197
198
                       bool eq_range_arg, bool sorted);
198
199
  int read_range_next();
 
200
  Item *idx_cond_push(uint32_t keyno, Item* idx_cond);
 
201
 
199
202
};
200
203
 
201
204
 
202
205
extern "C" {
 
206
char **session_query(Session *session);
203
207
 
204
208
/** Get the file name of the MySQL binlog.
205
209
 * @return the name of the binlog file
228
232
int session_non_transactional_update(const Session *session);
229
233
 
230
234
/**
 
235
  Get the user thread's binary logging format
 
236
  @param session  user thread
 
237
  @return Value to be used as index into the binlog_format_names array
 
238
*/
 
239
int session_binlog_format(const Session *session);
 
240
 
 
241
/**
231
242
  Mark transaction to rollback and mark error as fatal to a sub-statement.
232
243
  @param  session   Thread handle
233
244
  @param  all   TRUE <=> rollback main transaction.
236
247
}
237
248
 
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
246
255
int
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 */
252
262
 
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
257
266
trx_t*
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 */