~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/handler.h

  • Committer: mordred
  • Date: 2008-11-01 00:46:20 UTC
  • mto: (572.1.1 devel) (575.1.1 devel)
  • mto: This revision was merged to the branch mainline in revision 573.
  • Revision ID: mordred@opensolaris-20081101004620-vd0kzsl9k40hvf4p
Some updates to dtrace support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
 
20
#ifndef DRIZZLED_HANDLER_H
 
21
#define DRIZZLED_HANDLER_H
 
22
 
 
23
#include <drizzled/xid.h>
20
24
 
21
25
/* Definitions for parameters to do with handler-routines */
22
26
 
23
 
#ifdef USE_PRAGMA_INTERFACE
24
 
#pragma interface                       /* gcc class implementation */
25
 
#endif
26
 
 
27
 
#include <mysys/my_handler.h>
28
27
#include <storage/myisam/keycache.h>
29
 
 
30
 
#ifndef NO_HASH
31
 
#define NO_HASH                         /* Not yet implemented */
32
 
#endif
33
 
 
34
 
// the following is for checking tables
35
 
 
36
 
#define HA_ADMIN_ALREADY_DONE     1
37
 
#define HA_ADMIN_OK               0
38
 
#define HA_ADMIN_NOT_IMPLEMENTED -1
39
 
#define HA_ADMIN_FAILED          -2
40
 
#define HA_ADMIN_CORRUPT         -3
41
 
#define HA_ADMIN_INTERNAL_ERROR  -4
42
 
#define HA_ADMIN_INVALID         -5
43
 
#define HA_ADMIN_REJECT          -6
44
 
#define HA_ADMIN_TRY_ALTER       -7
45
 
#define HA_ADMIN_WRONG_CHECKSUM  -8
46
 
#define HA_ADMIN_NOT_BASE_TABLE  -9
47
 
#define HA_ADMIN_NEEDS_UPGRADE  -10
48
 
#define HA_ADMIN_NEEDS_ALTER    -11
49
 
#define HA_ADMIN_NEEDS_CHECK    -12
 
28
#include <mysys/thr_lock.h>
 
29
#include <mysys/hash.h>
 
30
#include <drizzled/sql_string.h>
 
31
#include <drizzled/sql_list.h>
50
32
 
51
33
/* Bits to show what an alter table will do */
52
34
#include <drizzled/sql_bitmap.h>
53
35
 
54
 
#define HA_MAX_ALTER_FLAGS 39
 
36
#define HA_MAX_ALTER_FLAGS 40
55
37
typedef Bitmap<HA_MAX_ALTER_FLAGS> HA_ALTER_FLAGS;
56
38
 
57
 
#define HA_ADD_INDEX                  (0)
58
 
#define HA_DROP_INDEX                 (1)
59
 
#define HA_ALTER_INDEX                (2)
60
 
#define HA_RENAME_INDEX               (3)
61
 
#define HA_ADD_UNIQUE_INDEX           (4)
62
 
#define HA_DROP_UNIQUE_INDEX          (5)
63
 
#define HA_ALTER_UNIQUE_INDEX         (6)
64
 
#define HA_RENAME_UNIQUE_INDEX        (7)
65
 
#define HA_ADD_PK_INDEX               (8)
66
 
#define HA_DROP_PK_INDEX              (9)
67
 
#define HA_ALTER_PK_INDEX             (10)
68
 
#define HA_ADD_COLUMN                 (11)
69
 
#define HA_DROP_COLUMN                (12)
70
 
#define HA_CHANGE_COLUMN              (13)
71
 
#define HA_ALTER_COLUMN_NAME          (14)
72
 
#define HA_ALTER_COLUMN_TYPE          (15)
73
 
#define HA_ALTER_COLUMN_ORDER         (16)
74
 
#define HA_ALTER_COLUMN_NULLABLE      (17)
75
 
#define HA_COLUMN_DEFAULT_VALUE       (18)
76
 
#define HA_COLUMN_STORAGE             (19)
77
 
#define HA_COLUMN_FORMAT              (20)
78
 
#define HA_ADD_FOREIGN_KEY            (21)
79
 
#define HA_DROP_FOREIGN_KEY           (22)
80
 
#define HA_ALTER_FOREIGN_KEY          (23)
81
 
#define HA_ADD_CONSTRAINT             (24)
82
 
#define HA_CHANGE_CHARACTER_SET       (30)
83
 
#define HA_SET_DEFAULT_CHARACTER_SET  (31)
84
 
#define HA_CHANGE_AUTOINCREMENT_VALUE (32)
85
 
#define HA_ALTER_STORAGE              (33)
86
 
#define HA_ALTER_TABLESPACE           (34)
87
 
#define HA_ALTER_ROW_FORMAT           (35)
88
 
#define HA_RENAME_TABLE               (36)
89
 
#define HA_ALTER_STORAGE_ENGINE       (37)
90
 
#define HA_RECREATE                   (38)
91
 
/* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
92
 
 
93
 
/* Return values for check_if_supported_alter */
94
 
 
95
 
#define HA_ALTER_ERROR               -1
96
 
#define HA_ALTER_SUPPORTED_WAIT_LOCK  0
97
 
#define HA_ALTER_SUPPORTED_NO_LOCK    1
98
 
#define HA_ALTER_NOT_SUPPORTED        2
99
 
 
100
 
/* Bits in table_flags() to show what database can do */
101
 
 
102
 
#define HA_NO_TRANSACTIONS     (1 << 0) /* Doesn't support transactions */
103
 
#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */
104
 
#define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */
105
 
/*
106
 
  The following should be set if the following is not true when scanning
107
 
  a table with rnd_next()
108
 
  - We will see all rows (including deleted ones)
109
 
  - Row positions are 'table->s->db_record_offset' apart
110
 
  If this flag is not set, filesort will do a postion() call for each matched
111
 
  row to be able to find the row later.
112
 
*/
113
 
#define HA_REC_NOT_IN_SEQ      (1 << 3)
114
 
 
115
 
/*
116
 
  Reading keys in random order is as fast as reading keys in sort order
117
 
  (Used in records.cc to decide if we should use a record cache and by
118
 
  filesort to decide if we should sort key + data or key + pointer-to-row
119
 
*/
120
 
#define HA_FAST_KEY_READ       (1 << 5)
121
 
/*
122
 
  Set the following flag if we on delete should force all key to be read
123
 
  and on update read all keys that changes
124
 
*/
125
 
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6)
126
 
#define HA_NULL_IN_KEY         (1 << 7) /* One can have keys with NULL */
127
 
#define HA_DUPLICATE_POS       (1 << 8)    /* ha_position() gives dup row */
128
 
#define HA_NO_BLOBS            (1 << 9) /* Doesn't support blobs */
129
 
#define HA_CAN_INDEX_BLOBS     (1 << 10)
130
 
#define HA_AUTO_PART_KEY       (1 << 11) /* auto-increment in multi-part key */
131
 
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */
132
 
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */
133
 
/*
134
 
  If we get the primary key columns for free when we do an index read
135
 
  It also implies that we have to retrive the primary key when using
136
 
  position() and rnd_pos().
137
 
*/
138
 
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
139
 
/*
140
 
  If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
141
 
  uses a primary key. Without primary key, we can't call position().
142
 
*/ 
143
 
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16) 
144
 
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
145
 
/*
146
 
  The following is we need to a primary key to delete (and update) a row.
147
 
  If there is no primary key, all columns needs to be read on update and delete
148
 
*/
149
 
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
150
 
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
151
 
#define HA_NO_AUTO_INCREMENT   (1 << 23)
152
 
#define HA_HAS_CHECKSUM        (1 << 24)
153
 
/* Table data are stored in separate files (for lower_case_table_names) */
154
 
#define HA_FILE_BASED          (1 << 26)
155
 
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
156
 
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
157
 
#define HA_NO_COPY_ON_ALTER    (INT64_C(1) << 31)
158
 
#define HA_HAS_RECORDS         (INT64_C(1) << 32) /* records() gives exact count*/
159
 
#define HA_MRR_CANT_SORT       (INT64_C(1) << 34)
160
 
 
161
 
/*
162
 
  Engine is capable of row-format and statement-format logging,
163
 
  respectively
164
 
*/
165
 
#define HA_BINLOG_ROW_CAPABLE  (INT64_C(1) << 35)
166
 
#define HA_BINLOG_STMT_CAPABLE (INT64_C(1) << 36)
167
 
 
168
 
#define HA_ONLINE_ALTER        (INT64_C(1) << 37)
169
 
 
170
 
/*
171
 
  Set of all binlog flags. Currently only contain the capabilities
172
 
  flags.
173
 
 */
174
 
#define HA_BINLOG_FLAGS (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE)
175
 
 
176
 
/* bits in index_flags(index_number) for what you can do with index */
177
 
#define HA_READ_NEXT            1       /* TODO really use this flag */
178
 
#define HA_READ_PREV            2       /* supports ::index_prev */
179
 
#define HA_READ_ORDER           4       /* index_next/prev follow sort order */
180
 
#define HA_READ_RANGE           8       /* can find all records in a range */
181
 
#define HA_ONLY_WHOLE_INDEX     16      /* Can't use part key searches */
182
 
#define HA_KEYREAD_ONLY         64      /* Support HA_EXTRA_KEYREAD */
183
 
/*
184
 
  Index scan will not return records in rowid order. Not guaranteed to be
185
 
  set for unordered (e.g. HASH) indexes.
186
 
*/
187
 
#define HA_KEY_SCAN_NOT_ROR     128 
188
 
#define HA_DO_INDEX_COND_PUSHDOWN  256 /* Supports Index Condition Pushdown */
189
 
 
190
 
 
191
 
 
192
 
/*
193
 
  HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is
194
 
  supported at all.
195
 
  HA_FAST_CHANGE_PARTITION means that optimised variants of the changes
196
 
  exists but they are not necessarily done online.
197
 
 
198
 
  HA_ONLINE_DOUBLE_WRITE means that the handler supports writing to both
199
 
  the new partition and to the old partitions when updating through the
200
 
  old partitioning schema while performing a change of the partitioning.
201
 
  This means that we can support updating of the table while performing
202
 
  the copy phase of the change. For no lock at all also a double write
203
 
  from new to old must exist and this is not required when this flag is
204
 
  set.
205
 
  This is actually removed even before it was introduced the first time.
206
 
  The new idea is that handlers will handle the lock level already in
207
 
  store_lock for ALTER Table partitions.
208
 
 
209
 
  HA_PARTITION_ONE_PHASE is a flag that can be set by handlers that take
210
 
  care of changing the partitions online and in one phase. Thus all phases
211
 
  needed to handle the change are implemented inside the storage engine.
212
 
  The storage engine must also support auto-discovery since the frm file
213
 
  is changed as part of the change and this change must be controlled by
214
 
  the storage engine. A typical engine to support this is NDB (through
215
 
  WL #2498).
216
 
*/
217
 
#define HA_PARTITION_FUNCTION_SUPPORTED         (1L << 1)
218
 
#define HA_FAST_CHANGE_PARTITION                (1L << 2)
219
 
#define HA_PARTITION_ONE_PHASE                  (1L << 3)
220
 
 
221
 
/* operations for disable/enable indexes */
222
 
#define HA_KEY_SWITCH_NONUNIQ      0
223
 
#define HA_KEY_SWITCH_ALL          1
224
 
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
225
 
#define HA_KEY_SWITCH_ALL_SAVE     3
226
 
 
227
 
/*
228
 
  Note: the following includes binlog and closing 0.
229
 
  so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
230
 
      example + csv + heap + blackhole + federated + 0
231
 
  (yes, the sum is deliberately inaccurate)
232
 
  TODO remove the limit, use dynarrays
233
 
*/
234
 
#define MAX_HA 15
235
 
 
236
 
/*
237
 
  Parameters for open() (in register form->filestat)
238
 
  HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
239
 
*/
240
 
 
241
 
#define HA_OPEN_KEYFILE         1
242
 
#define HA_OPEN_RNDFILE         2
243
 
#define HA_GET_INDEX            4
244
 
#define HA_GET_INFO             8       /* do a ha_info() after open */
245
 
#define HA_READ_ONLY            16      /* File opened as readonly */
246
 
/* Try readonly if can't open with read and write */
247
 
#define HA_TRY_READ_ONLY        32
248
 
#define HA_WAIT_IF_LOCKED       64      /* Wait if locked on open */
249
 
#define HA_ABORT_IF_LOCKED      128     /* skip if locked on open.*/
250
 
#define HA_BLOCK_LOCK           256     /* unlock when reading some records */
251
 
#define HA_OPEN_TEMPORARY       512
252
 
 
253
 
/* For transactional LOCK Table. handler::lock_table() */
254
 
#define HA_LOCK_IN_SHARE_MODE      F_RDLCK
255
 
#define HA_LOCK_IN_EXCLUSIVE_MODE  F_WRLCK
256
 
 
257
 
/* Some key definitions */
258
 
#define HA_KEY_NULL_LENGTH      1
259
 
#define HA_KEY_BLOB_LENGTH      2
260
 
 
261
 
#define HA_LEX_CREATE_TMP_TABLE 1
262
 
#define HA_LEX_CREATE_IF_NOT_EXISTS 2
263
 
#define HA_LEX_CREATE_TABLE_LIKE 4
264
 
#define HA_OPTION_NO_CHECKSUM   (1L << 17)
265
 
#define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18)
266
 
#define HA_MAX_REC_LENGTH       65535
267
 
 
268
 
/* Table caching type */
269
 
#define HA_CACHE_TBL_NONTRANSACT 0
270
 
#define HA_CACHE_TBL_NOCACHE     1
271
 
#define HA_CACHE_TBL_ASKTRANSACT 2
272
 
#define HA_CACHE_TBL_TRANSACT    4
273
 
 
274
 
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
275
 
#define DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
276
 
 
277
 
/* Flags for method is_fatal_error */
278
 
#define HA_CHECK_DUP_KEY 1
279
 
#define HA_CHECK_DUP_UNIQUE 2
280
 
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
281
 
 
282
 
enum legacy_db_type
283
 
{
284
 
  DB_TYPE_UNKNOWN=0,
285
 
  DB_TYPE_FIRST_DYNAMIC=42,
286
 
  DB_TYPE_DEFAULT=127 // Must be last
287
 
};
288
 
 
289
 
enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED,
290
 
                ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED,
291
 
                ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGE };
292
 
 
293
 
enum column_format_type { COLUMN_FORMAT_TYPE_NOT_USED= -1,
294
 
                          COLUMN_FORMAT_TYPE_DEFAULT=   0,
295
 
                          COLUMN_FORMAT_TYPE_FIXED=     1,
296
 
                          COLUMN_FORMAT_TYPE_DYNAMIC=   2 };
297
 
 
298
 
enum enum_binlog_func {
299
 
  BFN_RESET_LOGS=        1,
300
 
  BFN_RESET_SLAVE=       2,
301
 
  BFN_BINLOG_WAIT=       3,
302
 
  BFN_BINLOG_END=        4,
303
 
  BFN_BINLOG_PURGE_FILE= 5
304
 
};
305
 
 
306
 
enum enum_binlog_command {
307
 
  LOGCOM_CREATE_TABLE,
308
 
  LOGCOM_ALTER_TABLE,
309
 
  LOGCOM_RENAME_TABLE,
310
 
  LOGCOM_DROP_TABLE,
311
 
  LOGCOM_CREATE_DB,
312
 
  LOGCOM_ALTER_DB,
313
 
  LOGCOM_DROP_DB
314
 
};
315
 
 
316
 
/* struct to hold information about the table that should be created */
317
 
 
318
 
/* Bits in used_fields */
319
 
#define HA_CREATE_USED_AUTO             (1L << 0)
320
 
#ifdef DEAD_OPTIONS
321
 
#define HA_CREATE_USED_RAID             (1L << 1) /* Historical, no longer supported */
322
 
#define HA_CREATE_USED_UNION            (1L << 2)
323
 
#define HA_CREATE_USED_PASSWORD         (1L << 17)
324
 
#endif
325
 
#define HA_CREATE_USED_INSERT_METHOD    (1L << 3)
326
 
#define HA_CREATE_USED_MIN_ROWS         (1L << 4)
327
 
#define HA_CREATE_USED_MAX_ROWS         (1L << 5)
328
 
#define HA_CREATE_USED_AVG_ROW_LENGTH   (1L << 6)
329
 
#define HA_CREATE_USED_PACK_KEYS        (1L << 7)
330
 
#define HA_CREATE_USED_CHARSET          (1L << 8)
331
 
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
332
 
#define HA_CREATE_USED_DATADIR          (1L << 10)
333
 
#define HA_CREATE_USED_INDEXDIR         (1L << 11)
334
 
#define HA_CREATE_USED_ENGINE           (1L << 12)
335
 
#define HA_CREATE_USED_CHECKSUM         (1L << 13)
336
 
#define HA_CREATE_USED_DELAY_KEY_WRITE  (1L << 14)
337
 
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
338
 
#define HA_CREATE_USED_COMMENT          (1L << 16)
339
 
#define HA_CREATE_USED_CONNECTION       (1L << 18)
340
 
#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)
341
 
#define HA_CREATE_USED_PAGE_CHECKSUM    (1L << 21)
342
 
#define HA_CREATE_USED_BLOCK_SIZE       (1L << 22)
343
 
 
344
 
typedef uint64_t my_xid; // this line is the same as in log_event.h
345
 
#define DRIZZLE_XID_PREFIX "MySQLXid"
346
 
#define DRIZZLE_XID_PREFIX_LEN 8 // must be a multiple of 8
347
 
#define DRIZZLE_XID_OFFSET (DRIZZLE_XID_PREFIX_LEN+sizeof(server_id))
348
 
#define DRIZZLE_XID_GTRID_LEN (DRIZZLE_XID_OFFSET+sizeof(my_xid))
349
 
 
350
 
#define XIDDATASIZE DRIZZLE_XIDDATASIZE
351
 
#define MAXGTRIDSIZE 64
352
 
#define MAXBQUALSIZE 64
353
 
 
354
 
#define COMPATIBLE_DATA_YES 0
355
 
#define COMPATIBLE_DATA_NO  1
356
 
 
357
 
typedef bool (*qc_engine_callback)(THD *thd, char *table_key,
 
39
 
 
40
typedef bool (*qc_engine_callback)(Session *session, char *table_key,
358
41
                                      uint32_t key_length,
359
42
                                      uint64_t *engine_data);
360
43
 
361
 
/**
362
 
  struct xid_t is binary compatible with the XID structure as
363
 
  in the X/Open CAE Specification, Distributed Transaction Processing:
364
 
  The XA Specification, X/Open Company Ltd., 1991.
365
 
  http://www.opengroup.org/bookstore/catalog/c193.htm
366
 
 
367
 
  @see DRIZZLE_XID in mysql/plugin.h
368
 
*/
369
 
struct xid_t {
370
 
  long formatID;
371
 
  long gtrid_length;
372
 
  long bqual_length;
373
 
  char data[XIDDATASIZE];  // not \0-terminated !
374
 
 
375
 
  xid_t() {}                                /* Remove gcc warning */  
376
 
  bool eq(struct xid_t *xid)
377
 
  { return eq(xid->gtrid_length, xid->bqual_length, xid->data); }
378
 
  bool eq(long g, long b, const char *d)
379
 
  { return g == gtrid_length && b == bqual_length && !memcmp(d, data, g+b); }
380
 
  void set(struct xid_t *xid)
381
 
  { memcpy(this, xid, xid->length()); }
382
 
  void set(long f, const char *g, long gl, const char *b, long bl)
383
 
  {
384
 
    formatID= f;
385
 
    memcpy(data, g, gtrid_length= gl);
386
 
    memcpy(data+gl, b, bqual_length= bl);
387
 
  }
388
 
  void set(uint64_t xid)
389
 
  {
390
 
    my_xid tmp;
391
 
    formatID= 1;
392
 
    set(DRIZZLE_XID_PREFIX_LEN, 0, DRIZZLE_XID_PREFIX);
393
 
    memcpy(data+DRIZZLE_XID_PREFIX_LEN, &server_id, sizeof(server_id));
394
 
    tmp= xid;
395
 
    memcpy(data+DRIZZLE_XID_OFFSET, &tmp, sizeof(tmp));
396
 
    gtrid_length=DRIZZLE_XID_GTRID_LEN;
397
 
  }
398
 
  void set(long g, long b, const char *d)
399
 
  {
400
 
    formatID= 1;
401
 
    gtrid_length= g;
402
 
    bqual_length= b;
403
 
    memcpy(data, d, g+b);
404
 
  }
405
 
  bool is_null() { return formatID == -1; }
406
 
  void null() { formatID= -1; }
407
 
  my_xid quick_get_my_xid()
408
 
  {
409
 
    my_xid tmp;
410
 
    memcpy(&tmp, data+DRIZZLE_XID_OFFSET, sizeof(tmp));
411
 
    return tmp;
412
 
  }
413
 
  my_xid get_my_xid()
414
 
  {
415
 
    return gtrid_length == DRIZZLE_XID_GTRID_LEN && bqual_length == 0 &&
416
 
           !memcmp(data+DRIZZLE_XID_PREFIX_LEN, &server_id, sizeof(server_id)) &&
417
 
           !memcmp(data, DRIZZLE_XID_PREFIX, DRIZZLE_XID_PREFIX_LEN) ?
418
 
           quick_get_my_xid() : 0;
419
 
  }
420
 
  uint32_t length()
421
 
  {
422
 
    return sizeof(formatID)+sizeof(gtrid_length)+sizeof(bqual_length)+
423
 
           gtrid_length+bqual_length;
424
 
  }
425
 
  unsigned char *key()
426
 
  {
427
 
    return (unsigned char *)&gtrid_length;
428
 
  }
429
 
  uint32_t key_length()
430
 
  {
431
 
    return sizeof(gtrid_length)+sizeof(bqual_length)+gtrid_length+bqual_length;
432
 
  }
433
 
};
434
 
typedef struct xid_t XID;
435
 
 
436
 
/* for recover() handlerton call */
437
 
#define MIN_XID_LIST_SIZE  128
438
 
#define MAX_XID_LIST_SIZE  (1024*128)
439
44
 
440
45
struct handlerton;
441
46
 
442
47
/* The handler for a table type.  Will be included in the Table structure */
443
48
 
444
49
class Table;
 
50
class TableList;
445
51
typedef struct st_table_share TABLE_SHARE;
446
52
struct st_foreign_key_info;
447
53
typedef struct st_foreign_key_info FOREIGN_KEY_INFO;
448
 
typedef bool (stat_print_fn)(THD *thd, const char *type, uint32_t type_len,
 
54
typedef bool (stat_print_fn)(Session *session, const char *type, uint32_t type_len,
449
55
                             const char *file, uint32_t file_len,
450
56
                             const char *status, uint32_t status_len);
451
57
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
476
82
  enum legacy_db_type db_type;
477
83
  /*
478
84
    each storage engine has it's own memory area (actually a pointer)
479
 
    in the thd, for storing per-connection information.
 
85
    in the session, for storing per-connection information.
480
86
    It is accessed as
481
87
 
482
 
      thd->ha_data[xxx_hton.slot]
 
88
      session->ha_data[xxx_hton.slot]
483
89
 
484
90
   slot number is initialized by MySQL after xxx_init() is called.
485
91
   */
498
104
     handlerton methods:
499
105
 
500
106
     close_connection is only called if
501
 
     thd->ha_data[xxx_hton.slot] is non-zero, so even if you don't need
 
107
     session->ha_data[xxx_hton.slot] is non-zero, so even if you don't need
502
108
     this storage area - set it to something, so that MySQL would know
503
109
     this storage engine was accessed in this connection
504
110
   */
505
 
   int  (*close_connection)(handlerton *hton, THD *thd);
 
111
   int  (*close_connection)(handlerton *hton, Session *session);
506
112
   /*
507
113
     sv points to an uninitialized storage area of requested size
508
114
     (see savepoint_offset description)
509
115
   */
510
 
   int  (*savepoint_set)(handlerton *hton, THD *thd, void *sv);
 
116
   int  (*savepoint_set)(handlerton *hton, Session *session, void *sv);
511
117
   /*
512
118
     sv points to a storage area, that was earlier passed
513
119
     to the savepoint_set call
514
120
   */
515
 
   int  (*savepoint_rollback)(handlerton *hton, THD *thd, void *sv);
516
 
   int  (*savepoint_release)(handlerton *hton, THD *thd, void *sv);
 
121
   int  (*savepoint_rollback)(handlerton *hton, Session *session, void *sv);
 
122
   int  (*savepoint_release)(handlerton *hton, Session *session, void *sv);
517
123
   /*
518
124
     'all' is true if it's a real commit, that makes persistent changes
519
125
     'all' is false if it's not in fact a commit but an end of the
521
127
     NOTE 'all' is also false in auto-commit mode where 'end of statement'
522
128
     and 'real commit' mean the same event.
523
129
   */
524
 
   int  (*commit)(handlerton *hton, THD *thd, bool all);
525
 
   int  (*rollback)(handlerton *hton, THD *thd, bool all);
526
 
   int  (*prepare)(handlerton *hton, THD *thd, bool all);
 
130
   int  (*commit)(handlerton *hton, Session *session, bool all);
 
131
   int  (*rollback)(handlerton *hton, Session *session, bool all);
 
132
   int  (*prepare)(handlerton *hton, Session *session, bool all);
527
133
   int  (*recover)(handlerton *hton, XID *xid_list, uint32_t len);
528
134
   int  (*commit_by_xid)(handlerton *hton, XID *xid);
529
135
   int  (*rollback_by_xid)(handlerton *hton, XID *xid);
530
 
   void *(*create_cursor_read_view)(handlerton *hton, THD *thd);
531
 
   void (*set_cursor_read_view)(handlerton *hton, THD *thd, void *read_view);
532
 
   void (*close_cursor_read_view)(handlerton *hton, THD *thd, void *read_view);
 
136
   void *(*create_cursor_read_view)(handlerton *hton, Session *session);
 
137
   void (*set_cursor_read_view)(handlerton *hton, Session *session, void *read_view);
 
138
   void (*close_cursor_read_view)(handlerton *hton, Session *session, void *read_view);
533
139
   handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root);
534
140
   void (*drop_database)(handlerton *hton, char* path);
535
 
   int (*start_consistent_snapshot)(handlerton *hton, THD *thd);
 
141
   int (*start_consistent_snapshot)(handlerton *hton, Session *session);
536
142
   bool (*flush_logs)(handlerton *hton);
537
 
   bool (*show_status)(handlerton *hton, THD *thd, stat_print_fn *print, enum ha_stat_type stat);
538
 
   int (*fill_files_table)(handlerton *hton, THD *thd,
 
143
   bool (*show_status)(handlerton *hton, Session *session, stat_print_fn *print, enum ha_stat_type stat);
 
144
   int (*fill_files_table)(handlerton *hton, Session *session,
539
145
                           TableList *tables,
540
146
                           class Item *cond);
541
147
   uint32_t flags;                                /* global handler flags */
542
 
   int (*release_temporary_latches)(handlerton *hton, THD *thd);
 
148
   int (*release_temporary_latches)(handlerton *hton, Session *session);
543
149
 
544
 
   int (*discover)(handlerton *hton, THD* thd, const char *db, 
 
150
   int (*discover)(handlerton *hton, Session* session, const char *db, 
545
151
                   const char *name,
546
152
                   unsigned char **frmblob, 
547
153
                   size_t *frmlen);
548
 
   int (*table_exists_in_engine)(handlerton *hton, THD* thd, const char *db,
 
154
   int (*table_exists_in_engine)(handlerton *hton, Session* session, const char *db,
549
155
                                 const char *name);
550
156
   uint32_t license; /* Flag for Engine License */
551
157
   void *data; /* Location for engines to keep personal structures */
552
158
};
553
159
 
554
160
 
555
 
/* Possible flags of a handlerton (there can be 32 of them) */
556
 
#define HTON_NO_FLAGS                 0
557
 
#define HTON_CLOSE_CURSORS_AT_COMMIT (1 << 0)
558
 
#define HTON_ALTER_NOT_SUPPORTED     (1 << 1) //Engine does not support alter
559
 
#define HTON_CAN_RECREATE            (1 << 2) //Delete all is used fro truncate
560
 
#define HTON_HIDDEN                  (1 << 3) //Engine does not appear in lists
561
 
#define HTON_FLUSH_AFTER_RENAME      (1 << 4)
562
 
#define HTON_NOT_USER_SELECTABLE     (1 << 5)
563
 
#define HTON_TEMPORARY_NOT_SUPPORTED (1 << 6) //Having temporary tables not supported
564
 
#define HTON_SUPPORT_LOG_TABLES      (1 << 7) //Engine supports log tables
565
 
#define HTON_NO_PARTITION            (1 << 8) //You can not partition these tables
566
161
 
567
162
class Ha_trx_info;
568
163
 
569
 
struct THD_TRANS
 
164
struct Session_TRANS
570
165
{
571
166
  /* true is not all entries in the ht[] support 2pc */
572
167
  bool        no_2pc;
576
171
    The purpose of this flag is to keep track of non-transactional
577
172
    tables that were modified in scope of:
578
173
    - transaction, when the variable is a member of
579
 
    THD::transaction.all
 
174
    Session::transaction.all
580
175
    - top-level statement or sub-statement, when the variable is a
581
 
    member of THD::transaction.stmt
 
176
    member of Session::transaction.stmt
582
177
    This member has the following life cycle:
583
178
    * stmt.modified_non_trans_table is used to keep track of
584
179
    modified non-transactional tables of top-level statements. At
612
207
 
613
208
  If a storage engine participates in a statement/transaction,
614
209
  an instance of this class is present in
615
 
  thd->transaction.{stmt|all}.ha_list. The addition to
 
210
  session->transaction.{stmt|all}.ha_list. The addition to
616
211
  {stmt|all}.ha_list is made by trans_register_ha().
617
212
 
618
213
  When it's time to commit or rollback, each element of ha_list
627
222
{
628
223
public:
629
224
  /** Register this storage engine in the given transaction context. */
630
 
  void register_ha(THD_TRANS *trans, handlerton *ht_arg)
 
225
  void register_ha(Session_TRANS *trans, handlerton *ht_arg)
631
226
  {
632
227
    assert(m_flags == 0);
633
228
    assert(m_ht == NULL);
718
313
  uint64_t check_sum;
719
314
} PARTITION_INFO;
720
315
 
721
 
#define UNDEF_NODEGROUP 65535
722
316
class Item;
723
317
struct st_table_log_memory_entry;
724
318
 
725
 
#define NOT_A_PARTITION_ID ((uint32_t)-1)
726
 
 
727
 
enum ha_choice { HA_CHOICE_UNDEF, HA_CHOICE_NO, HA_CHOICE_YES };
728
319
 
729
320
typedef struct st_ha_create_information
730
321
{
952
543
void get_sweep_read_cost(Table *table, ha_rows nrows, bool interrupted, 
953
544
                         COST_VECT *cost);
954
545
 
955
 
/*
956
 
  The below two are not used (and not handled) in this milestone of this WL
957
 
  entry because there seems to be no use for them at this stage of
958
 
  implementation.
959
 
*/
960
 
#define HA_MRR_SINGLE_POINT 1
961
 
#define HA_MRR_FIXED_KEY  2
962
 
 
963
 
/* 
964
 
  Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
965
 
  'range' parameter.
966
 
*/
967
 
#define HA_MRR_NO_ASSOCIATION 4
968
 
 
969
 
/* 
970
 
  The MRR user will provide ranges in key order, and MRR implementation
971
 
  must return rows in key order.
972
 
*/
973
 
#define HA_MRR_SORTED 8
974
 
 
975
 
/* MRR implementation doesn't have to retrieve full records */
976
 
#define HA_MRR_INDEX_ONLY 16
977
 
 
978
 
/* 
979
 
  The passed memory buffer is of maximum possible size, the caller can't
980
 
  assume larger buffer.
981
 
*/
982
 
#define HA_MRR_LIMITS 32
983
 
 
984
 
 
985
 
/*
986
 
  Flag set <=> default MRR implementation is used
987
 
  (The choice is made by **_info[_const]() function which may set this
988
 
   flag. SQL layer remembers the flag value and then passes it to
989
 
   multi_read_range_init().
990
 
*/
991
 
#define HA_MRR_USE_DEFAULT_IMPL 64
992
 
 
993
 
/*
994
 
  Used only as parameter to multi_range_read_info():
995
 
  Flag set <=> the caller guarantees that the bounds of the scanned ranges
996
 
  will not have NULL values.
997
 
*/
998
 
#define HA_MRR_NO_NULL_ENDPOINTS 128
999
546
 
1000
547
 
1001
548
class ha_statistics
1158
705
    insert id for the current row (*autogenerated*; if not
1159
706
    autogenerated, it's 0).
1160
707
    At first successful insertion, this variable is stored into
1161
 
    THD::first_successful_insert_id_in_cur_stmt.
 
708
    Session::first_successful_insert_id_in_cur_stmt.
1162
709
  */
1163
710
  uint64_t insert_id_for_cur_row;
1164
711
  /**
1234
781
    interface, see the (private) functions write_row(), update_row(),
1235
782
    and delete_row() below.
1236
783
  */
1237
 
  int ha_external_lock(THD *thd, int lock_type);
 
784
  int ha_external_lock(Session *session, int lock_type);
1238
785
  int ha_write_row(unsigned char * buf);
1239
786
  int ha_update_row(const unsigned char * old_data, unsigned char * new_data);
1240
787
  int ha_delete_row(const unsigned char * buf);
1242
789
 
1243
790
  int ha_check_for_upgrade(HA_CHECK_OPT *check_opt);
1244
791
  /** to be actually called to get 'check()' functionality*/
1245
 
  int ha_check(THD *thd, HA_CHECK_OPT *check_opt);
1246
 
  int ha_repair(THD* thd, HA_CHECK_OPT* check_opt);
 
792
  int ha_check(Session *session, HA_CHECK_OPT *check_opt);
 
793
  int ha_repair(Session* session, HA_CHECK_OPT* check_opt);
1247
794
  void ha_start_bulk_insert(ha_rows rows)
1248
795
  {
1249
796
    estimation_rows_to_insert= rows;
1258
805
                         uint32_t *dup_key_found);
1259
806
  int ha_delete_all_rows();
1260
807
  int ha_reset_auto_increment(uint64_t value);
1261
 
  int ha_optimize(THD* thd, HA_CHECK_OPT* check_opt);
1262
 
  int ha_analyze(THD* thd, HA_CHECK_OPT* check_opt);
1263
 
  bool ha_check_and_repair(THD *thd);
 
808
  int ha_optimize(Session* session, HA_CHECK_OPT* check_opt);
 
809
  int ha_analyze(Session* session, HA_CHECK_OPT* check_opt);
 
810
  bool ha_check_and_repair(Session *session);
1264
811
  int ha_disable_indexes(uint32_t mode);
1265
812
  int ha_enable_indexes(uint32_t mode);
1266
813
  int ha_discard_or_import_tablespace(bool discard);
1514
1061
  */
1515
1062
  virtual void try_semi_consistent_read(bool) {}
1516
1063
  virtual void unlock_row(void) {}
1517
 
  virtual int start_stmt(THD *thd __attribute__((unused)),
 
1064
  virtual int start_stmt(Session *session __attribute__((unused)),
1518
1065
                         thr_lock_type lock_type __attribute__((unused)))
1519
1066
  {return 0;}
1520
1067
  virtual void get_auto_increment(uint64_t offset, uint64_t increment,
1543
1090
 
1544
1091
  virtual void update_create_info(HA_CREATE_INFO *create_info __attribute__((unused))) {}
1545
1092
  int check_old_types(void);
1546
 
  virtual int assign_to_keycache(THD* thd __attribute__((unused)),
 
1093
  virtual int assign_to_keycache(Session* session __attribute__((unused)),
1547
1094
                                 HA_CHECK_OPT* check_opt __attribute__((unused)))
1548
1095
  { return HA_ADMIN_NOT_IMPLEMENTED; }
1549
1096
  /* end of the list of admin commands */
1570
1117
  /** used in ALTER Table; 1 if changing storage engine is allowed */
1571
1118
  virtual bool can_switch_engines(void) { return 1; }
1572
1119
  /** used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */
1573
 
  virtual int get_foreign_key_list(THD *thd __attribute__((unused)),
 
1120
  virtual int get_foreign_key_list(Session *session __attribute__((unused)),
1574
1121
                                   List<FOREIGN_KEY_INFO> *f_key_list __attribute__((unused)))
1575
1122
  { return 0; }
1576
1123
  virtual uint32_t referenced_by_foreign_key() { return 0;}
1661
1208
    than lock_count() claimed. This can happen when the MERGE children
1662
1209
    are not attached when this is called from another thread.
1663
1210
  */
1664
 
  virtual THR_LOCK_DATA **store_lock(THD *thd,
 
1211
  virtual THR_LOCK_DATA **store_lock(Session *session,
1665
1212
                                     THR_LOCK_DATA **to,
1666
1213
                                     enum thr_lock_type lock_type)=0;
1667
1214
 
1672
1219
  /**
1673
1220
    @brief Register a named table with a call back function to the query cache.
1674
1221
 
1675
 
    @param thd The thread handle
 
1222
    @param session The thread handle
1676
1223
    @param table_key A pointer to the table name in the table cache
1677
1224
    @param key_length The length of the table name
1678
1225
    @param[out] engine_callback The pointer to the storage engine call back
1700
1247
  */
1701
1248
 
1702
1249
  virtual bool
1703
 
    register_query_cache_table(THD *thd __attribute__((unused)),
 
1250
    register_query_cache_table(Session *session __attribute__((unused)),
1704
1251
                               char *table_key __attribute__((unused)),
1705
1252
                               uint32_t key_length __attribute__((unused)),
1706
1253
                               qc_engine_callback *engine_callback,
1804
1351
   if (this->check_if_incompatible_data(create_info, table_changes)
1805
1352
       == COMPATIBLE_DATA_NO)
1806
1353
     return(HA_ALTER_NOT_SUPPORTED);
 
1354
   else if ((*alter_flags & HA_ALTER_STORED_VCOL).is_set())
 
1355
     return(HA_ALTER_NOT_SUPPORTED);
1807
1356
   else
1808
1357
     return(HA_ALTER_SUPPORTED_WAIT_LOCK);
1809
1358
 }
1810
1359
 /**
1811
1360
   Tell storage engine to prepare for the on-line alter table (pre-alter)
1812
1361
 
1813
 
   @param     thd               The thread handle
 
1362
   @param     session               The thread handle
1814
1363
   @param     altered_table     A temporary table show what table is to
1815
1364
                                change to
1816
1365
   @param     alter_info        Storage place for data used during phase1
1820
1369
   @retval   0      OK
1821
1370
   @retval   error  error code passed from storage engine
1822
1371
 */
1823
 
 virtual int alter_table_phase1(THD *thd __attribute__((unused)),
 
1372
 virtual int alter_table_phase1(Session *session __attribute__((unused)),
1824
1373
                                Table *altered_table __attribute__((unused)),
1825
1374
                                HA_CREATE_INFO *create_info __attribute__((unused)),
1826
1375
                                HA_ALTER_INFO *alter_info __attribute__((unused)),
1831
1380
 /**
1832
1381
    Tell storage engine to perform the on-line alter table (alter)
1833
1382
 
1834
 
    @param    thd               The thread handle
 
1383
    @param    session               The thread handle
1835
1384
    @param    altered_table     A temporary table show what table is to
1836
1385
                                change to
1837
1386
    @param    alter_info        Storage place for data used during phase1
1846
1395
      this call is to be wrapped with a DDL lock. This is currently NOT
1847
1396
      supported.
1848
1397
 */
1849
 
 virtual int alter_table_phase2(THD *thd  __attribute__((unused)),
 
1398
 virtual int alter_table_phase2(Session *session  __attribute__((unused)),
1850
1399
                                Table *altered_table  __attribute__((unused)),
1851
1400
                                HA_CREATE_INFO *create_info __attribute__((unused)),
1852
1401
                                HA_ALTER_INFO *alter_info __attribute__((unused)),
1858
1407
    Tell storage engine that changed frm file is now on disk and table
1859
1408
    has been re-opened (post-alter)
1860
1409
 
1861
 
    @param    thd               The thread handle
 
1410
    @param    session               The thread handle
1862
1411
    @param    table             The altered table, re-opened
1863
1412
 */
1864
 
 virtual int alter_table_phase3(THD *thd __attribute__((unused)),
 
1413
 virtual int alter_table_phase3(Session *session __attribute__((unused)),
1865
1414
                                Table *table __attribute__((unused)))
1866
1415
 {
1867
1416
   return HA_ERR_UNSUPPORTED;
1877
1426
  /**
1878
1427
    Lock table.
1879
1428
 
1880
 
    @param    thd                     Thread handle
 
1429
    @param    session                     Thread handle
1881
1430
    @param    lock_type               HA_LOCK_IN_SHARE_MODE     (F_RDLCK)
1882
1431
                                      HA_LOCK_IN_EXCLUSIVE_MODE (F_WRLCK)
1883
1432
    @param    lock_timeout            -1 default timeout
1898
1447
                                      lock conflict with NOWAIT option
1899
1448
    @retval HA_ERR_LOCK_DEADLOCK      Deadlock detected
1900
1449
  */
1901
 
  virtual int lock_table(THD *thd         __attribute__((unused)),
 
1450
  virtual int lock_table(Session *session         __attribute__((unused)),
1902
1451
                         int lock_type    __attribute__((unused)),
1903
1452
                         int lock_timeout __attribute__((unused)))
1904
1453
  {
1905
1454
    return HA_ERR_WRONG_COMMAND;
1906
1455
  }
 
1456
  /*
 
1457
    This procedure defines if the storage engine supports virtual columns.
 
1458
    Default false means "not supported".
 
1459
  */
 
1460
  virtual bool check_if_supported_virtual_columns(void) 
 
1461
  { return false; }
1907
1462
 
1908
1463
protected:
1909
1464
  /* Service methods for use by storage engines. */
1910
1465
  void ha_statistic_increment(ulong SSV::*offset) const;
1911
 
  void **ha_data(THD *) const;
1912
 
  THD *ha_thd(void) const;
 
1466
  void **ha_data(Session *) const;
 
1467
  Session *ha_session(void) const;
1913
1468
 
1914
1469
  /**
1915
1470
    Default rename_table() and delete_table() rename/delete files with a
1994
1549
    @return  non-0 in case of failure, 0 in case of success.
1995
1550
    When lock_type is F_UNLCK, the return value is ignored.
1996
1551
  */
1997
 
  virtual int external_lock(THD *thd __attribute__((unused)),
 
1552
  virtual int external_lock(Session *session __attribute__((unused)),
1998
1553
                            int lock_type __attribute__((unused)))
1999
1554
  {
2000
1555
    return 0;
2003
1558
  /** admin commands - called from mysql_admin_table */
2004
1559
  virtual int check_for_upgrade(HA_CHECK_OPT *check_opt __attribute__((unused)))
2005
1560
  { return 0; }
2006
 
  virtual int check(THD* thd __attribute__((unused)),
 
1561
  virtual int check(Session* session __attribute__((unused)),
2007
1562
                    HA_CHECK_OPT* check_opt __attribute__((unused)))
2008
1563
  { return HA_ADMIN_NOT_IMPLEMENTED; }
2009
1564
 
2012
1567
     to specify CHECK option to use to call check()
2013
1568
     upon the table.
2014
1569
  */
2015
 
  virtual int repair(THD* thd __attribute__((unused)),
 
1570
  virtual int repair(Session* session __attribute__((unused)),
2016
1571
                     HA_CHECK_OPT* check_opt __attribute__((unused)))
2017
1572
  { return HA_ADMIN_NOT_IMPLEMENTED; }
2018
1573
  virtual void start_bulk_insert(ha_rows rows __attribute__((unused)))
2063
1618
  */
2064
1619
  virtual int reset_auto_increment(uint64_t value __attribute__((unused)))
2065
1620
  { return HA_ERR_WRONG_COMMAND; }
2066
 
  virtual int optimize(THD* thd __attribute__((unused)),
 
1621
  virtual int optimize(Session* session __attribute__((unused)),
2067
1622
                       HA_CHECK_OPT* check_opt __attribute__((unused)))
2068
1623
  { return HA_ADMIN_NOT_IMPLEMENTED; }
2069
 
  virtual int analyze(THD* thd __attribute__((unused)),
 
1624
  virtual int analyze(Session* session __attribute__((unused)),
2070
1625
                      HA_CHECK_OPT* check_opt __attribute__((unused)))
2071
1626
  { return HA_ADMIN_NOT_IMPLEMENTED; }
2072
 
  virtual bool check_and_repair(THD *thd __attribute__((unused)))
 
1627
  virtual bool check_and_repair(Session *session __attribute__((unused)))
2073
1628
  { return true; }
2074
1629
  virtual int disable_indexes(uint32_t mode __attribute__((unused)))
2075
1630
  { return HA_ERR_WRONG_COMMAND; }
2166
1721
extern uint32_t total_ha, total_ha_2pc;
2167
1722
 
2168
1723
       /* Wrapper functions */
2169
 
#define ha_commit(thd) (ha_commit_trans((thd), true))
2170
 
#define ha_rollback(thd) (ha_rollback_trans((thd), true))
 
1724
#define ha_commit(session) (ha_commit_trans((session), true))
 
1725
#define ha_rollback(session) (ha_rollback_trans((session), true))
2171
1726
 
2172
1727
/* lookups */
2173
 
handlerton *ha_default_handlerton(THD *thd);
2174
 
plugin_ref ha_resolve_by_name(THD *thd, const LEX_STRING *name);
2175
 
plugin_ref ha_lock_engine(THD *thd, handlerton *hton);
2176
 
handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type);
 
1728
handlerton *ha_default_handlerton(Session *session);
 
1729
plugin_ref ha_resolve_by_name(Session *session, const LEX_STRING *name);
 
1730
plugin_ref ha_lock_engine(Session *session, handlerton *hton);
 
1731
handlerton *ha_resolve_by_legacy_type(Session *session, enum legacy_db_type db_type);
2177
1732
handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc,
2178
1733
                         handlerton *db_type);
2179
 
handlerton *ha_checktype(THD *thd, enum legacy_db_type database_type,
 
1734
handlerton *ha_checktype(Session *session, enum legacy_db_type database_type,
2180
1735
                          bool no_substitute, bool report_error);
2181
1736
 
2182
1737
 
2209
1764
int ha_finalize_handlerton(st_plugin_int *plugin);
2210
1765
 
2211
1766
TYPELIB *ha_known_exts(void);
2212
 
void ha_close_connection(THD* thd);
 
1767
void ha_close_connection(Session* session);
2213
1768
bool ha_flush_logs(handlerton *db_type);
2214
1769
void ha_drop_database(char* path);
2215
 
int ha_create_table(THD *thd, const char *path,
 
1770
int ha_create_table(Session *session, const char *path,
2216
1771
                    const char *db, const char *table_name,
2217
1772
                    HA_CREATE_INFO *create_info,
2218
1773
                    bool update_create_info);
2219
 
int ha_delete_table(THD *thd, handlerton *db_type, const char *path,
 
1774
int ha_delete_table(Session *session, handlerton *db_type, const char *path,
2220
1775
                    const char *db, const char *alias, bool generate_warning);
2221
1776
 
2222
1777
/* statistics and info */
2223
 
bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat);
 
1778
bool ha_show_status(Session *session, handlerton *db_type, enum ha_stat_type stat);
2224
1779
 
2225
1780
/* discovery */
2226
 
int ha_create_table_from_engine(THD* thd, const char *db, const char *name);
2227
 
int ha_discover(THD* thd, const char* dbname, const char* name,
 
1781
int ha_create_table_from_engine(Session* session, const char *db, const char *name);
 
1782
int ha_discover(Session* session, const char* dbname, const char* name,
2228
1783
                unsigned char** frmblob, size_t* frmlen);
2229
 
int ha_find_files(THD *thd,const char *db,const char *path,
 
1784
int ha_find_files(Session *session,const char *db,const char *path,
2230
1785
                  const char *wild, bool dir, List<LEX_STRING>* files);
2231
 
int ha_table_exists_in_engine(THD* thd, const char* db, const char* name);
 
1786
int ha_table_exists_in_engine(Session* session, const char* db, const char* name);
2232
1787
 
2233
1788
/* key cache */
2234
1789
extern "C" int ha_init_key_cache(const char *name, KEY_CACHE *key_cache);
2238
1793
int ha_end_key_cache(KEY_CACHE *key_cache);
2239
1794
 
2240
1795
/* report to InnoDB that control passes to the client */
2241
 
int ha_release_temporary_latches(THD *thd);
 
1796
int ha_release_temporary_latches(Session *session);
2242
1797
 
2243
1798
/* transactions: interface to handlerton functions */
2244
 
int ha_start_consistent_snapshot(THD *thd);
 
1799
int ha_start_consistent_snapshot(Session *session);
2245
1800
int ha_commit_or_rollback_by_xid(XID *xid, bool commit);
2246
 
int ha_commit_one_phase(THD *thd, bool all);
2247
 
int ha_rollback_trans(THD *thd, bool all);
2248
 
int ha_prepare(THD *thd);
 
1801
int ha_commit_one_phase(Session *session, bool all);
 
1802
int ha_rollback_trans(Session *session, bool all);
 
1803
int ha_prepare(Session *session);
2249
1804
int ha_recover(HASH *commit_list);
2250
1805
 
2251
1806
/* transactions: these functions never call handlerton functions directly */
2252
 
int ha_commit_trans(THD *thd, bool all);
2253
 
int ha_autocommit_or_rollback(THD *thd, int error);
2254
 
int ha_enable_transaction(THD *thd, bool on);
 
1807
int ha_commit_trans(Session *session, bool all);
 
1808
int ha_autocommit_or_rollback(Session *session, int error);
 
1809
int ha_enable_transaction(Session *session, bool on);
2255
1810
 
2256
1811
/* savepoints */
2257
 
int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv);
2258
 
int ha_savepoint(THD *thd, SAVEPOINT *sv);
2259
 
int ha_release_savepoint(THD *thd, SAVEPOINT *sv);
 
1812
int ha_rollback_to_savepoint(Session *session, SAVEPOINT *sv);
 
1813
int ha_savepoint(Session *session, SAVEPOINT *sv);
 
1814
int ha_release_savepoint(Session *session, SAVEPOINT *sv);
2260
1815
 
2261
1816
/* these are called by storage engines */
2262
 
void trans_register_ha(THD *thd, bool all, handlerton *ht);
 
1817
void trans_register_ha(Session *session, bool all, handlerton *ht);
 
1818
 
 
1819
void table_case_convert(char * name, uint32_t length);
 
1820
const char *table_case_name(HA_CREATE_INFO *info, const char *name);
 
1821
 
 
1822
extern char reg_ext[FN_EXTLEN];
 
1823
extern uint32_t reg_ext_length;
 
1824
extern ulong specialflag;
 
1825
extern uint32_t lower_case_table_names;
 
1826
uint32_t filename_to_tablename(const char *from, char *to, uint32_t to_length);
 
1827
uint32_t tablename_to_filename(const char *from, char *to, uint32_t to_length);
 
1828
 
2263
1829
 
2264
1830
/*
2265
1831
  Storage engine has to assume the transaction will end up with 2pc if
2266
1832
   - there is more than one 2pc-capable storage engine available
2267
1833
   - in the current transaction 2pc was not disabled yet
2268
1834
*/
2269
 
#define trans_need_2pc(thd, all)                   ((total_ha_2pc > 1) && \
2270
 
        !((all ? &thd->transaction.all : &thd->transaction.stmt)->no_2pc))
 
1835
#define trans_need_2pc(session, all)                   ((total_ha_2pc > 1) && \
 
1836
        !((all ? &session->transaction.all : &session->transaction.stmt)->no_2pc))
 
1837
 
 
1838
#endif /* DRIZZLED_HANDLER_H */