~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/handler.h

  • Committer: Monty Taylor
  • Date: 2008-10-30 19:42:06 UTC
  • mto: (520.4.38 devel)
  • mto: This revision was merged to the branch mainline in revision 572.
  • Revision ID: monty@inaugust.com-20081030194206-fzus6yqlw1ekru65
Removed handler from common_includes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#define HA_MAX_ALTER_FLAGS 40
37
37
typedef Bitmap<HA_MAX_ALTER_FLAGS> HA_ALTER_FLAGS;
38
38
 
39
 
#ifndef NO_HASH
40
 
#define NO_HASH                         /* Not yet implemented */
41
 
#endif
42
 
 
43
 
// the following is for checking tables
44
 
 
45
 
#define HA_ADMIN_ALREADY_DONE     1
46
 
#define HA_ADMIN_OK               0
47
 
#define HA_ADMIN_NOT_IMPLEMENTED -1
48
 
#define HA_ADMIN_FAILED          -2
49
 
#define HA_ADMIN_CORRUPT         -3
50
 
#define HA_ADMIN_INTERNAL_ERROR  -4
51
 
#define HA_ADMIN_INVALID         -5
52
 
#define HA_ADMIN_REJECT          -6
53
 
#define HA_ADMIN_TRY_ALTER       -7
54
 
#define HA_ADMIN_WRONG_CHECKSUM  -8
55
 
#define HA_ADMIN_NOT_BASE_TABLE  -9
56
 
#define HA_ADMIN_NEEDS_UPGRADE  -10
57
 
#define HA_ADMIN_NEEDS_ALTER    -11
58
 
#define HA_ADMIN_NEEDS_CHECK    -12
59
 
 
60
 
 
61
 
#define HA_ADD_INDEX                  (0)
62
 
#define HA_DROP_INDEX                 (1)
63
 
#define HA_ALTER_INDEX                (2)
64
 
#define HA_RENAME_INDEX               (3)
65
 
#define HA_ADD_UNIQUE_INDEX           (4)
66
 
#define HA_DROP_UNIQUE_INDEX          (5)
67
 
#define HA_ALTER_UNIQUE_INDEX         (6)
68
 
#define HA_RENAME_UNIQUE_INDEX        (7)
69
 
#define HA_ADD_PK_INDEX               (8)
70
 
#define HA_DROP_PK_INDEX              (9)
71
 
#define HA_ALTER_PK_INDEX             (10)
72
 
#define HA_ADD_COLUMN                 (11)
73
 
#define HA_DROP_COLUMN                (12)
74
 
#define HA_CHANGE_COLUMN              (13)
75
 
#define HA_ALTER_COLUMN_NAME          (14)
76
 
#define HA_ALTER_COLUMN_TYPE          (15)
77
 
#define HA_ALTER_COLUMN_ORDER         (16)
78
 
#define HA_ALTER_COLUMN_NULLABLE      (17)
79
 
#define HA_COLUMN_DEFAULT_VALUE       (18)
80
 
#define HA_COLUMN_STORAGE             (19)
81
 
#define HA_COLUMN_FORMAT              (20)
82
 
#define HA_ADD_FOREIGN_KEY            (21)
83
 
#define HA_DROP_FOREIGN_KEY           (22)
84
 
#define HA_ALTER_FOREIGN_KEY          (23)
85
 
#define HA_ADD_CONSTRAINT             (24)
86
 
#define HA_CHANGE_CHARACTER_SET       (30)
87
 
#define HA_SET_DEFAULT_CHARACTER_SET  (31)
88
 
#define HA_CHANGE_AUTOINCREMENT_VALUE (32)
89
 
#define HA_ALTER_STORAGE              (33)
90
 
#define HA_ALTER_TABLESPACE           (34)
91
 
#define HA_ALTER_ROW_FORMAT           (35)
92
 
#define HA_RENAME_TABLE               (36)
93
 
#define HA_ALTER_STORAGE_ENGINE       (37)
94
 
#define HA_RECREATE                   (38)
95
 
#define HA_ALTER_STORED_VCOL          (39)
96
 
/* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
97
 
 
98
 
/* Return values for check_if_supported_alter */
99
 
 
100
 
#define HA_ALTER_ERROR               -1
101
 
#define HA_ALTER_SUPPORTED_WAIT_LOCK  0
102
 
#define HA_ALTER_SUPPORTED_NO_LOCK    1
103
 
#define HA_ALTER_NOT_SUPPORTED        2
104
 
 
105
 
/* Bits in table_flags() to show what database can do */
106
 
 
107
 
#define HA_NO_TRANSACTIONS     (1 << 0) /* Doesn't support transactions */
108
 
#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */
109
 
#define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */
110
 
/*
111
 
  The following should be set if the following is not true when scanning
112
 
  a table with rnd_next()
113
 
  - We will see all rows (including deleted ones)
114
 
  - Row positions are 'table->s->db_record_offset' apart
115
 
  If this flag is not set, filesort will do a postion() call for each matched
116
 
  row to be able to find the row later.
117
 
*/
118
 
#define HA_REC_NOT_IN_SEQ      (1 << 3)
119
 
 
120
 
/*
121
 
  Reading keys in random order is as fast as reading keys in sort order
122
 
  (Used in records.cc to decide if we should use a record cache and by
123
 
  filesort to decide if we should sort key + data or key + pointer-to-row
124
 
*/
125
 
#define HA_FAST_KEY_READ       (1 << 5)
126
 
/*
127
 
  Set the following flag if we on delete should force all key to be read
128
 
  and on update read all keys that changes
129
 
*/
130
 
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6)
131
 
#define HA_NULL_IN_KEY         (1 << 7) /* One can have keys with NULL */
132
 
#define HA_DUPLICATE_POS       (1 << 8)    /* ha_position() gives dup row */
133
 
#define HA_NO_BLOBS            (1 << 9) /* Doesn't support blobs */
134
 
#define HA_CAN_INDEX_BLOBS     (1 << 10)
135
 
#define HA_AUTO_PART_KEY       (1 << 11) /* auto-increment in multi-part key */
136
 
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */
137
 
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */
138
 
/*
139
 
  If we get the primary key columns for free when we do an index read
140
 
  It also implies that we have to retrive the primary key when using
141
 
  position() and rnd_pos().
142
 
*/
143
 
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
144
 
/*
145
 
  If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
146
 
  uses a primary key. Without primary key, we can't call position().
147
 
*/ 
148
 
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16) 
149
 
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
150
 
/*
151
 
  The following is we need to a primary key to delete (and update) a row.
152
 
  If there is no primary key, all columns needs to be read on update and delete
153
 
*/
154
 
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
155
 
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
156
 
#define HA_NO_AUTO_INCREMENT   (1 << 23)
157
 
#define HA_HAS_CHECKSUM        (1 << 24)
158
 
/* Table data are stored in separate files (for lower_case_table_names) */
159
 
#define HA_FILE_BASED          (1 << 26)
160
 
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
161
 
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
162
 
#define HA_NO_COPY_ON_ALTER    (INT64_C(1) << 31)
163
 
#define HA_HAS_RECORDS         (INT64_C(1) << 32) /* records() gives exact count*/
164
 
#define HA_MRR_CANT_SORT       (INT64_C(1) << 34)
165
 
 
166
 
/*
167
 
  Engine is capable of row-format and statement-format logging,
168
 
  respectively
169
 
*/
170
 
#define HA_BINLOG_ROW_CAPABLE  (INT64_C(1) << 35)
171
 
#define HA_BINLOG_STMT_CAPABLE (INT64_C(1) << 36)
172
 
 
173
 
#define HA_ONLINE_ALTER        (INT64_C(1) << 37)
174
 
 
175
 
/*
176
 
  Set of all binlog flags. Currently only contain the capabilities
177
 
  flags.
178
 
 */
179
 
#define HA_BINLOG_FLAGS (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE)
180
 
 
181
 
/* bits in index_flags(index_number) for what you can do with index */
182
 
#define HA_READ_NEXT            1       /* TODO really use this flag */
183
 
#define HA_READ_PREV            2       /* supports ::index_prev */
184
 
#define HA_READ_ORDER           4       /* index_next/prev follow sort order */
185
 
#define HA_READ_RANGE           8       /* can find all records in a range */
186
 
#define HA_ONLY_WHOLE_INDEX     16      /* Can't use part key searches */
187
 
#define HA_KEYREAD_ONLY         64      /* Support HA_EXTRA_KEYREAD */
188
 
/*
189
 
  Index scan will not return records in rowid order. Not guaranteed to be
190
 
  set for unordered (e.g. HASH) indexes.
191
 
*/
192
 
#define HA_KEY_SCAN_NOT_ROR     128 
193
 
#define HA_DO_INDEX_COND_PUSHDOWN  256 /* Supports Index Condition Pushdown */
194
 
 
195
 
 
196
 
 
197
 
/*
198
 
  HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is
199
 
  supported at all.
200
 
  HA_FAST_CHANGE_PARTITION means that optimised variants of the changes
201
 
  exists but they are not necessarily done online.
202
 
 
203
 
  HA_ONLINE_DOUBLE_WRITE means that the handler supports writing to both
204
 
  the new partition and to the old partitions when updating through the
205
 
  old partitioning schema while performing a change of the partitioning.
206
 
  This means that we can support updating of the table while performing
207
 
  the copy phase of the change. For no lock at all also a double write
208
 
  from new to old must exist and this is not required when this flag is
209
 
  set.
210
 
  This is actually removed even before it was introduced the first time.
211
 
  The new idea is that handlers will handle the lock level already in
212
 
  store_lock for ALTER Table partitions.
213
 
 
214
 
  HA_PARTITION_ONE_PHASE is a flag that can be set by handlers that take
215
 
  care of changing the partitions online and in one phase. Thus all phases
216
 
  needed to handle the change are implemented inside the storage engine.
217
 
  The storage engine must also support auto-discovery since the frm file
218
 
  is changed as part of the change and this change must be controlled by
219
 
  the storage engine. A typical engine to support this is NDB (through
220
 
  WL #2498).
221
 
*/
222
 
#define HA_PARTITION_FUNCTION_SUPPORTED         (1L << 1)
223
 
#define HA_FAST_CHANGE_PARTITION                (1L << 2)
224
 
#define HA_PARTITION_ONE_PHASE                  (1L << 3)
225
 
 
226
 
/* operations for disable/enable indexes */
227
 
#define HA_KEY_SWITCH_NONUNIQ      0
228
 
#define HA_KEY_SWITCH_ALL          1
229
 
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
230
 
#define HA_KEY_SWITCH_ALL_SAVE     3
231
 
 
232
 
/*
233
 
  Note: the following includes binlog and closing 0.
234
 
  so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
235
 
      example + csv + heap + blackhole + federated + 0
236
 
  (yes, the sum is deliberately inaccurate)
237
 
  TODO remove the limit, use dynarrays
238
 
*/
239
 
#define MAX_HA 15
240
 
 
241
 
/*
242
 
  Parameters for open() (in register form->filestat)
243
 
  HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
244
 
*/
245
 
 
246
 
#define HA_OPEN_KEYFILE         1
247
 
#define HA_OPEN_RNDFILE         2
248
 
#define HA_GET_INDEX            4
249
 
#define HA_GET_INFO             8       /* do a ha_info() after open */
250
 
#define HA_READ_ONLY            16      /* File opened as readonly */
251
 
/* Try readonly if can't open with read and write */
252
 
#define HA_TRY_READ_ONLY        32
253
 
#define HA_WAIT_IF_LOCKED       64      /* Wait if locked on open */
254
 
#define HA_ABORT_IF_LOCKED      128     /* skip if locked on open.*/
255
 
#define HA_BLOCK_LOCK           256     /* unlock when reading some records */
256
 
#define HA_OPEN_TEMPORARY       512
257
 
 
258
 
/* For transactional LOCK Table. handler::lock_table() */
259
 
#define HA_LOCK_IN_SHARE_MODE      F_RDLCK
260
 
#define HA_LOCK_IN_EXCLUSIVE_MODE  F_WRLCK
261
 
 
262
 
/* Some key definitions */
263
 
#define HA_KEY_NULL_LENGTH      1
264
 
#define HA_KEY_BLOB_LENGTH      2
265
 
 
266
 
#define HA_LEX_CREATE_TMP_TABLE 1
267
 
#define HA_LEX_CREATE_IF_NOT_EXISTS 2
268
 
#define HA_LEX_CREATE_TABLE_LIKE 4
269
 
#define HA_OPTION_NO_CHECKSUM   (1L << 17)
270
 
#define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18)
271
 
#define HA_MAX_REC_LENGTH       65535
272
 
 
273
 
/* Table caching type */
274
 
#define HA_CACHE_TBL_NONTRANSACT 0
275
 
#define HA_CACHE_TBL_NOCACHE     1
276
 
#define HA_CACHE_TBL_ASKTRANSACT 2
277
 
#define HA_CACHE_TBL_TRANSACT    4
278
 
 
279
 
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
280
 
#define DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
281
 
 
282
 
/* Flags for method is_fatal_error */
283
 
#define HA_CHECK_DUP_KEY 1
284
 
#define HA_CHECK_DUP_UNIQUE 2
285
 
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
286
 
 
287
 
enum legacy_db_type
288
 
{
289
 
  DB_TYPE_UNKNOWN=0,
290
 
  DB_TYPE_FIRST_DYNAMIC=42,
291
 
  DB_TYPE_DEFAULT=127 // Must be last
292
 
};
293
 
 
294
 
enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED,
295
 
                ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED,
296
 
                ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGE };
297
 
 
298
 
enum column_format_type { COLUMN_FORMAT_TYPE_NOT_USED= -1,
299
 
                          COLUMN_FORMAT_TYPE_DEFAULT=   0,
300
 
                          COLUMN_FORMAT_TYPE_FIXED=     1,
301
 
                          COLUMN_FORMAT_TYPE_DYNAMIC=   2 };
302
 
 
303
 
enum enum_binlog_func {
304
 
  BFN_RESET_LOGS=        1,
305
 
  BFN_RESET_SLAVE=       2,
306
 
  BFN_BINLOG_WAIT=       3,
307
 
  BFN_BINLOG_END=        4,
308
 
  BFN_BINLOG_PURGE_FILE= 5
309
 
};
310
 
 
311
 
enum enum_binlog_command {
312
 
  LOGCOM_CREATE_TABLE,
313
 
  LOGCOM_ALTER_TABLE,
314
 
  LOGCOM_RENAME_TABLE,
315
 
  LOGCOM_DROP_TABLE,
316
 
  LOGCOM_CREATE_DB,
317
 
  LOGCOM_ALTER_DB,
318
 
  LOGCOM_DROP_DB
319
 
};
320
 
 
321
 
/* struct to hold information about the table that should be created */
322
 
 
323
 
/* Bits in used_fields */
324
 
#define HA_CREATE_USED_AUTO             (1L << 0)
325
 
#ifdef DEAD_OPTIONS
326
 
#define HA_CREATE_USED_UNION            (1L << 2)
327
 
#define HA_CREATE_USED_PASSWORD         (1L << 17)
328
 
#endif
329
 
#define HA_CREATE_USED_INSERT_METHOD    (1L << 3)
330
 
#define HA_CREATE_USED_MIN_ROWS         (1L << 4)
331
 
#define HA_CREATE_USED_MAX_ROWS         (1L << 5)
332
 
#define HA_CREATE_USED_AVG_ROW_LENGTH   (1L << 6)
333
 
#define HA_CREATE_USED_PACK_KEYS        (1L << 7)
334
 
#define HA_CREATE_USED_CHARSET          (1L << 8)
335
 
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
336
 
#define HA_CREATE_USED_DATADIR          (1L << 10)
337
 
#define HA_CREATE_USED_INDEXDIR         (1L << 11)
338
 
#define HA_CREATE_USED_ENGINE           (1L << 12)
339
 
#define HA_CREATE_USED_CHECKSUM         (1L << 13)
340
 
#define HA_CREATE_USED_DELAY_KEY_WRITE  (1L << 14)
341
 
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
342
 
#define HA_CREATE_USED_COMMENT          (1L << 16)
343
 
#define HA_CREATE_USED_CONNECTION       (1L << 18)
344
 
#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)
345
 
#define HA_CREATE_USED_PAGE_CHECKSUM    (1L << 21)
346
 
#define HA_CREATE_USED_BLOCK_SIZE       (1L << 22)
347
 
 
348
 
#define MAXGTRIDSIZE 64
349
 
#define MAXBQUALSIZE 64
350
 
 
351
 
#define COMPATIBLE_DATA_YES 0
352
 
#define COMPATIBLE_DATA_NO  1
353
39
 
354
40
typedef bool (*qc_engine_callback)(Session *session, char *table_key,
355
41
                                      uint32_t key_length,
472
158
};
473
159
 
474
160
 
475
 
/* Possible flags of a handlerton (there can be 32 of them) */
476
 
#define HTON_NO_FLAGS                 0
477
 
#define HTON_CLOSE_CURSORS_AT_COMMIT (1 << 0)
478
 
#define HTON_ALTER_NOT_SUPPORTED     (1 << 1) //Engine does not support alter
479
 
#define HTON_CAN_RECREATE            (1 << 2) //Delete all is used fro truncate
480
 
#define HTON_HIDDEN                  (1 << 3) //Engine does not appear in lists
481
 
#define HTON_FLUSH_AFTER_RENAME      (1 << 4)
482
 
#define HTON_NOT_USER_SELECTABLE     (1 << 5)
483
 
#define HTON_TEMPORARY_NOT_SUPPORTED (1 << 6) //Having temporary tables not supported
484
 
#define HTON_SUPPORT_LOG_TABLES      (1 << 7) //Engine supports log tables
485
 
#define HTON_NO_PARTITION            (1 << 8) //You can not partition these tables
486
161
 
487
162
class Ha_trx_info;
488
163
 
638
313
  uint64_t check_sum;
639
314
} PARTITION_INFO;
640
315
 
641
 
#define UNDEF_NODEGROUP 65535
642
316
class Item;
643
317
struct st_table_log_memory_entry;
644
318
 
645
 
#define NOT_A_PARTITION_ID ((uint32_t)-1)
646
 
 
647
 
enum ha_choice { HA_CHOICE_UNDEF, HA_CHOICE_NO, HA_CHOICE_YES };
648
319
 
649
320
typedef struct st_ha_create_information
650
321
{
872
543
void get_sweep_read_cost(Table *table, ha_rows nrows, bool interrupted, 
873
544
                         COST_VECT *cost);
874
545
 
875
 
/*
876
 
  The below two are not used (and not handled) in this milestone of this WL
877
 
  entry because there seems to be no use for them at this stage of
878
 
  implementation.
879
 
*/
880
 
#define HA_MRR_SINGLE_POINT 1
881
 
#define HA_MRR_FIXED_KEY  2
882
 
 
883
 
/* 
884
 
  Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
885
 
  'range' parameter.
886
 
*/
887
 
#define HA_MRR_NO_ASSOCIATION 4
888
 
 
889
 
/* 
890
 
  The MRR user will provide ranges in key order, and MRR implementation
891
 
  must return rows in key order.
892
 
*/
893
 
#define HA_MRR_SORTED 8
894
 
 
895
 
/* MRR implementation doesn't have to retrieve full records */
896
 
#define HA_MRR_INDEX_ONLY 16
897
 
 
898
 
/* 
899
 
  The passed memory buffer is of maximum possible size, the caller can't
900
 
  assume larger buffer.
901
 
*/
902
 
#define HA_MRR_LIMITS 32
903
 
 
904
 
 
905
 
/*
906
 
  Flag set <=> default MRR implementation is used
907
 
  (The choice is made by **_info[_const]() function which may set this
908
 
   flag. SQL layer remembers the flag value and then passes it to
909
 
   multi_read_range_init().
910
 
*/
911
 
#define HA_MRR_USE_DEFAULT_IMPL 64
912
 
 
913
 
/*
914
 
  Used only as parameter to multi_range_read_info():
915
 
  Flag set <=> the caller guarantees that the bounds of the scanned ranges
916
 
  will not have NULL values.
917
 
*/
918
 
#define HA_MRR_NO_NULL_ENDPOINTS 128
919
546
 
920
547
 
921
548
class ha_statistics