~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2010-01-02 05:11:55 UTC
  • mto: (1259.3.1 build)
  • mto: This revision was merged to the branch mainline in revision 1262.
  • Revision ID: mordred@inaugust.com-20100102051155-akdm8w5rr6xwzayu
pandora-build - proper detection of memcached.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (c) 2000, 2010, MySQL AB & Innobase Oy. All Rights Reserved.
 
3
Copyright (c) 2000, 2009, MySQL AB & Innobase Oy. All Rights Reserved.
4
4
 
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.
12
12
 
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., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
 
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 
15
Place, Suite 330, Boston, MA 02111-1307 USA
16
16
 
17
17
*****************************************************************************/
18
18
 
28
28
 
29
29
#include <drizzled/cursor.h>
30
30
#include <drizzled/thr_lock.h>
31
 
#include <drizzled/plugin/transactional_storage_engine.h>
32
 
 
33
 
using namespace drizzled;
34
 
 
35
 
/* Structure defines translation table between mysql index and innodb
36
 
index structures */
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
43
 
                                        array index */
44
 
} innodb_idx_translate_t;
45
31
 
46
32
/** InnoDB table share */
47
33
typedef struct st_innobase_share {
48
34
        THR_LOCK        lock;           /*!< MySQL lock protecting
49
35
                                        this structure */
50
 
        char    table_name[FN_REFLEN];  /*!< InnoDB table name */
 
36
        const char*     table_name;     /*!< InnoDB table name */
51
37
        uint            use_count;      /*!< reference count,
52
38
                                        incremented in get_share()
53
39
                                        and decremented in free_share() */
54
40
        void*           table_name_hash;/*!< hash table chain node */
55
 
        innodb_idx_translate_t  idx_trans_tbl;  /*!< index translation
56
 
                                                table between MySQL and
57
 
                                                Innodb */
58
 
 
59
 
        st_innobase_share(const char *arg) :
60
 
          use_count(0)
61
 
        {
62
 
          strncpy(table_name, arg, FN_REFLEN);
63
 
        }
64
 
 
65
41
} INNOBASE_SHARE;
66
42
 
67
43
 
88
64
        INNOBASE_SHARE* share;          /*!< information for MySQL
89
65
                                        table locking */
90
66
 
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
94
 
                                                     to Innodb format */
 
67
        unsigned char*  upd_buff;       /*!< buffer used in updates */
 
68
        unsigned char*  key_val_buff;   /*!< buffer used in converting
 
69
                                        search key values from MySQL format
 
70
                                        to Innodb format */
95
71
        ulong           upd_and_key_val_buff_len;
96
72
                                        /* the length of each of the previous
97
73
                                        two buffers */
102
78
        uint            last_match_mode;/* match mode of the latest search:
103
79
                                        ROW_SEL_EXACT, ROW_SEL_EXACT_PREFIX,
104
80
                                        or undefined */
105
 
        uint            num_write_row;  /*!< number of doInsertRecord() calls */
 
81
        uint            num_write_row;  /*!< number of write_row() calls */
106
82
 
107
83
        UNIV_INTERN uint store_key_val_for_row(uint keynr, char* buff, 
108
84
                                   uint buff_len, const unsigned char* record);
109
85
        UNIV_INTERN void update_session(Session* session);
 
86
        UNIV_INTERN void update_session();
110
87
        UNIV_INTERN int change_active_index(uint32_t keynr);
111
88
        UNIV_INTERN int general_fetch(unsigned char* buf, uint32_t direction, uint32_t match_mode);
112
89
        UNIV_INTERN ulint innobase_lock_autoinc();
115
92
        UNIV_INTERN ulint innobase_reset_autoinc(uint64_t auto_inc);
116
93
        UNIV_INTERN ulint innobase_get_autoinc(uint64_t* value);
117
94
        ulint innobase_update_autoinc(uint64_t  auto_inc);
118
 
        UNIV_INTERN void innobase_initialize_autoinc();
 
95
        UNIV_INTERN ulint innobase_initialize_autoinc();
119
96
        UNIV_INTERN dict_index_t* innobase_get_index(uint keynr);
 
97
        UNIV_INTERN uint64_t innobase_get_int_col_max_value(const Field* field);
120
98
 
121
99
        /* Init values for the class: */
122
100
 public:
123
 
        UNIV_INTERN ha_innobase(plugin::StorageEngine &engine,
124
 
                                Table &table_arg);
 
101
        UNIV_INTERN ha_innobase(drizzled::plugin::StorageEngine &engine,
 
102
                                TableShare &table_arg);
125
103
        UNIV_INTERN ~ha_innobase();
126
 
  /**
127
 
   * Returns the plugin::TransactionStorageEngine pointer
128
 
   * of the cursor's underlying engine.
129
 
   *
130
 
   * @todo
131
 
   *
132
 
   * Have a TransactionalCursor subclass...
133
 
   */
134
 
  UNIV_INTERN plugin::TransactionalStorageEngine *getTransactionalEngine()
135
 
  {
136
 
    return static_cast<plugin::TransactionalStorageEngine *>(getEngine());
137
 
  }
 
104
        /*
 
105
          Get the row type from the storage engine.  If this method returns
 
106
          ROW_TYPE_NOT_USED, the information in HA_CREATE_INFO should be used.
 
107
        */
 
108
        UNIV_INTERN enum row_type get_row_type() const;
138
109
 
139
110
        UNIV_INTERN const char* index_type(uint key_number);
140
111
        UNIV_INTERN const key_map* keys_to_use_for_scanning();
141
112
 
142
 
        UNIV_INTERN int doOpen(const drizzled::TableIdentifier &identifier, int mode, uint test_if_locked);
 
113
        UNIV_INTERN int open(const char *name, int mode, uint test_if_locked);
143
114
        UNIV_INTERN int close(void);
144
115
        UNIV_INTERN double scan_time();
145
116
        UNIV_INTERN double read_time(uint index, uint ranges, ha_rows rows);
146
117
 
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);
 
118
        UNIV_INTERN int write_row(unsigned char * buf);
 
119
        UNIV_INTERN int update_row(const unsigned char * old_data, unsigned char * new_data);
 
120
        UNIV_INTERN int delete_row(const unsigned char * buf);
150
121
        UNIV_INTERN bool was_semi_consistent_read();
151
122
        UNIV_INTERN void try_semi_consistent_read(bool yes);
152
123
        UNIV_INTERN void unlock_row();
153
124
 
154
 
        UNIV_INTERN int doStartIndexScan(uint index, bool sorted);
155
 
        UNIV_INTERN int doEndIndexScan();
 
125
        UNIV_INTERN int index_init(uint index, bool sorted);
 
126
        UNIV_INTERN int index_end();
156
127
        UNIV_INTERN int index_read(unsigned char * buf, const unsigned char * key,
157
128
                uint key_len, enum ha_rkey_function find_flag);
158
129
        UNIV_INTERN int index_read_idx(unsigned char * buf, uint index, const unsigned char * key,
164
135
        UNIV_INTERN int index_first(unsigned char * buf);
165
136
        UNIV_INTERN int index_last(unsigned char * buf);
166
137
 
167
 
        UNIV_INTERN int doStartTableScan(bool scan);
168
 
        UNIV_INTERN int doEndTableScan();
 
138
        UNIV_INTERN int rnd_init(bool scan);
 
139
        UNIV_INTERN int rnd_end();
169
140
        UNIV_INTERN int rnd_next(unsigned char *buf);
170
141
        UNIV_INTERN int rnd_pos(unsigned char * buf, unsigned char *pos);
171
142
 
176
147
        UNIV_INTERN int extra(enum ha_extra_function operation);
177
148
        UNIV_INTERN int reset();
178
149
        UNIV_INTERN int external_lock(Session *session, int lock_type);
 
150
        UNIV_INTERN int start_stmt(Session *session, thr_lock_type lock_type);
179
151
        void position(unsigned char *record);
180
152
        UNIV_INTERN ha_rows records_in_range(uint inx, key_range *min_key, key_range
181
153
                                                                *max_key);
185
157
        UNIV_INTERN int check(Session* session);
186
158
        UNIV_INTERN char* update_table_comment(const char* comment);
187
159
        UNIV_INTERN char* get_foreign_key_create_info();
188
 
        UNIV_INTERN int get_foreign_key_list(Session *session, List<ForeignKeyInfo> *f_key_list);
 
160
        UNIV_INTERN int get_foreign_key_list(Session *session, List<FOREIGN_KEY_INFO> *f_key_list);
189
161
        UNIV_INTERN bool can_switch_engines();
190
162
        UNIV_INTERN uint referenced_by_foreign_key();
191
163
        UNIV_INTERN void free_foreign_key_create_info(char* str);
192
164
        UNIV_INTERN THR_LOCK_DATA **store_lock(Session *session, THR_LOCK_DATA **to,
193
165
                                        enum thr_lock_type lock_type);
 
166
        UNIV_INTERN void init_table_handle_for_HANDLER();
194
167
        UNIV_INTERN virtual void get_auto_increment(uint64_t offset, 
195
168
                                                    uint64_t increment,
196
169
                                                    uint64_t nb_desired_values,
201
174
        UNIV_INTERN bool primary_key_is_clustered();
202
175
        UNIV_INTERN int cmp_ref(const unsigned char *ref1, const unsigned char *ref2);
203
176
        /** Fast index creation (smart ALTER TABLE) @see handler0alter.cc @{ */
204
 
        // Don't use these, I have just left them in here as reference for
205
 
        // the future. -Brian 
206
 
#if 0
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,
209
 
                                           TABLE *table_arg,
210
 
                                           uint *key_num,
 
177
        UNIV_INTERN int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys);
 
178
        UNIV_INTERN int prepare_drop_index(TABLE *table_arg, uint *key_num,
211
179
                                           uint num_of_keys);
212
 
        UNIV_INTERN int final_drop_index(Session *session, TABLE *table_arg);
213
 
#endif
 
180
        UNIV_INTERN int final_drop_index(TABLE *table_arg);
214
181
        /** @} */
215
182
public:
216
183
  int read_range_first(const key_range *start_key, const key_range *end_key,
220
187
 
221
188
 
222
189
extern "C" {
 
190
char **session_query(Session *session);
223
191
 
224
192
/** Get the file name of the MySQL binlog.
225
193
 * @return the name of the binlog file
239
207
*/
240
208
int session_slave_thread(const Session *session);
241
209
 
 
210
/**
 
211
  Check if a user thread is running a non-transactional update
 
212
  @param session  user thread
 
213
  @retval 0 the user thread is not running a non-transactional update
 
214
  @retval 1 the user thread is running a non-transactional update
 
215
*/
 
216
int session_non_transactional_update(const Session *session);
 
217
 
 
218
/**
 
219
  Get the user thread's binary logging format
 
220
  @param session  user thread
 
221
  @return Value to be used as index into the binlog_format_names array
 
222
*/
 
223
int session_binlog_format(const Session *session);
 
224
 
 
225
/**
 
226
  Mark transaction to rollback and mark error as fatal to a sub-statement.
 
227
  @param  session   Thread handle
 
228
  @param  all   TRUE <=> rollback main transaction.
 
229
*/
 
230
void session_mark_transaction_to_rollback(Session *session, bool all);
242
231
}
243
232
 
244
233
typedef struct trx_struct trx_t;
264
253
innobase_trx_allocate(
265
254
/*==================*/
266
255
        Session         *session);      /*!< in: user thread handle */
267
 
 
268
 
/***********************************************************************
269
 
This function checks each index name for a table against reserved
270
 
system default primary index name 'GEN_CLUST_INDEX'. If a name matches,
271
 
this function pushes an error message to the client, and returns true. */
272
 
extern "C"
273
 
bool
274
 
innobase_index_name_is_reserved(
275
 
/*============================*/
276
 
                                        /* out: true if index name matches a
277
 
                                        reserved name */
278
 
        const trx_t*    trx,            /* in: InnoDB transaction handle */
279
 
        const drizzled::KeyInfo*        key_info,/* in: Indexes to be created */
280
 
        ulint           num_of_keys);   /* in: Number of indexes to
281
 
                                        be created. */
282
 
 
283
256
#endif /* INNODB_HANDLER_HA_INNODB_H */