20
20
/* This file includes constants used with all databases */
23
* @TODO Name this file something better and split it out if necessary.
23
* @TODO Name this file something better and split it out if necessary.
24
* base.h isn't descriptive, especially compared to global.h
25
26
* @TODO Convert HA_XXX defines into enums and/or bitmaps
28
#ifndef DRIZZLED_BASE_H
29
#define DRIZZLED_BASE_H
29
#ifndef DRIZZLE_SERVER_BASE_H
30
#define DRIZZLE_SERVER_BASE_H
32
#ifndef stdin /* Included first in handler */
34
#include <drizzled/global.h>
35
#include <mysys/my_dir.h> /* This includes types */
36
#include <mysys/my_sys.h>
37
#include <mystrings/m_string.h>
45
#include <mysys/my_list.h>
34
47
/* The following is bits in the flag parameter to ha_open() */
37
50
#define HA_OPEN_WAIT_IF_LOCKED 1
38
51
#define HA_OPEN_IGNORE_IF_LOCKED 2
39
52
#define HA_OPEN_TMP_TABLE 4 /* Table is a temp table */
53
#define HA_OPEN_DELAY_KEY_WRITE 8 /* Don't update index */
54
#define HA_OPEN_ABORT_IF_CRASHED 16
55
#define HA_OPEN_FOR_REPAIR 32 /* open even if crashed */
56
#define HA_OPEN_FROM_SQL_LAYER 64
57
#define HA_OPEN_MMAP 128 /* open memory mapped */
58
#define HA_OPEN_COPY 256 /* Open copy (for repair) */
40
59
/* Internal temp table, used for temporary results */
41
60
#define HA_OPEN_INTERNAL_TABLE 512
83
102
HA_KEY_ALG_UNDEF= 0, /* Not specified (old file) */
84
103
HA_KEY_ALG_BTREE= 1, /* B-tree, default one */
85
HA_KEY_ALG_HASH= 3 /* HASH keys (HEAP tables) */
104
HA_KEY_ALG_RTREE= 2, /* R-tree, for spatial searches */
105
HA_KEY_ALG_HASH= 3, /* HASH keys (HEAP tables) */
106
HA_KEY_ALG_FULLTEXT= 4 /* FULLTEXT (MyISAM tables) */
88
109
/* Index and table build methods */
90
enum ha_build_method {
111
enum ha_build_method {
96
117
/* The following is parameter to ha_extra() */
133
154
HA_EXTRA_CHANGE_KEY_TO_UNIQUE,
134
155
HA_EXTRA_CHANGE_KEY_TO_DUP,
136
When using HA_EXTRA_KEYREAD, overwrite only key member fields and keep
157
When using HA_EXTRA_KEYREAD, overwrite only key member fields and keep
137
158
other fields intact. When this is off (by default) InnoDB will use memcpy
138
159
to overwrite entire row.
140
161
HA_EXTRA_KEYREAD_PRESERVE_FIELDS,
142
164
Ignore if the a tuple is not found, continue processing the
143
165
transaction and ignore that 'row'. Needed for idempotency
158
180
HA_EXTRA_WRITE_CANNOT_REPLACE,
160
182
Inform handler that delete_row()/update_row() cannot batch deletes/updates
161
and should perform them immediately. This may be needed when table has
183
and should perform them immediately. This may be needed when table has
162
184
AFTER DELETE/UPDATE triggers which access to subject table.
163
185
These flags are reset by the handler::extra(HA_EXTRA_RESET) call.
173
195
HA_EXTRA_PREPARE_FOR_RENAME
198
/* Compatible option, to be deleted in 6.0 */
199
#define HA_EXTRA_PREPARE_FOR_DELETE HA_EXTRA_PREPARE_FOR_DROP
176
201
/* The following is parameter to ha_panic() */
178
203
enum ha_panic_function {
187
212
HA_KEYTYPE_END=0,
188
213
HA_KEYTYPE_TEXT=1, /* Key is sorted as letters */
189
214
HA_KEYTYPE_BINARY=2, /* Key is sorted as unsigned chars */
215
HA_KEYTYPE_SHORT_INT=3,
190
216
HA_KEYTYPE_LONG_INT=4,
191
218
HA_KEYTYPE_DOUBLE=6,
219
HA_KEYTYPE_NUM=7, /* Not packed num with pre-space */
220
HA_KEYTYPE_USHORT_INT=8,
192
221
HA_KEYTYPE_ULONG_INT=9,
193
222
HA_KEYTYPE_LONGLONG=10,
194
223
HA_KEYTYPE_ULONGLONG=11,
225
HA_KEYTYPE_UINT24=13,
195
227
/* Varchar (0-255 bytes) with length packed with 1 byte */
196
228
HA_KEYTYPE_VARTEXT1=15, /* Key is sorted as letters */
197
229
HA_KEYTYPE_VARBINARY1=16, /* Key is sorted as unsigned chars */
198
230
/* Varchar (0-65535 bytes) with length packed with 2 bytes */
199
231
HA_KEYTYPE_VARTEXT2=17, /* Key is sorted as letters */
200
HA_KEYTYPE_VARBINARY2=18 /* Key is sorted as unsigned chars */
232
HA_KEYTYPE_VARBINARY2=18, /* Key is sorted as unsigned chars */
236
#define HA_MAX_KEYTYPE 31 /* Must be log2-1 */
203
238
/* These flags kan be OR:ed to key-flag */
205
240
#define HA_NOSAME 1 /* Set if not dupplicated records */
210
245
#define HA_NULL_ARE_EQUAL 2048 /* NULL in key are cmp as equal */
211
246
#define HA_GENERATED_KEY 8192 /* Automaticly generated key */
248
/* The combination of the above can be used for key type comparison. */
249
#define HA_KEYFLAG_MASK (HA_NOSAME | HA_PACK_KEY | HA_AUTO_KEY | \
250
HA_BINARY_PACK_KEY | HA_UNIQUE_CHECK | \
251
HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
213
253
#define HA_KEY_HAS_PART_KEY_SEG 65536 /* Key contains partial segments */
215
255
/* Automatic bits in key-flag */
218
258
#define HA_VAR_LENGTH_KEY 8
219
259
#define HA_NULL_PART_KEY 64
220
260
#define HA_USES_COMMENT 4096
221
#define HA_USES_BLOCK_SIZE ((uint32_t) 32768)
261
#define HA_USES_BLOCK_SIZE ((uint) 32768)
222
262
#define HA_SORT_ALLOWS_SAME 512 /* Intern bit when sorting records */
224
264
/* These flags can be added to key-seg-flag */
242
282
#define HA_OPTION_PACK_RECORD 1
243
283
#define HA_OPTION_PACK_KEYS 2
244
284
#define HA_OPTION_COMPRESS_RECORD 4
285
#define HA_OPTION_LONG_BLOB_PTR 8 /* new ISAM format */
245
286
#define HA_OPTION_TMP_TABLE 16
287
#define HA_OPTION_CHECKSUM 32
288
#define HA_OPTION_DELAY_KEY_WRITE 64
246
289
#define HA_OPTION_NO_PACK_KEYS 128 /* Reserved for MySQL */
247
#define HA_OPTION_TEMP_COMPRESS_RECORD ((uint32_t) 16384) /* set by isamchk */
248
#define HA_OPTION_READ_ONLY_DATA ((uint32_t) 32768) /* Set by isamchk */
290
#define HA_OPTION_CREATE_FROM_ENGINE 256
291
#define HA_OPTION_RELIES_ON_SQL_LAYER 512
292
#define HA_OPTION_NULL_FIELDS 1024
293
#define HA_OPTION_PAGE_CHECKSUM 2048
294
#define HA_OPTION_TEMP_COMPRESS_RECORD ((uint) 16384) /* set by isamchk */
295
#define HA_OPTION_READ_ONLY_DATA ((uint) 32768) /* Set by isamchk */
250
297
/* Bits in flag to create() */
252
299
#define HA_DONT_TOUCH_DATA 1 /* Don't empty datafile (isamchk) */
253
300
#define HA_PACK_RECORD 2 /* Request packed record format */
254
301
#define HA_CREATE_TMP_TABLE 4
302
#define HA_CREATE_CHECKSUM 8
255
303
#define HA_CREATE_KEEP_FILES 16 /* don't overwrite .MYD and MYI */
304
#define HA_CREATE_PAGE_CHECKSUM 32
305
#define HA_CREATE_DELAY_KEY_WRITE 64
306
#define HA_CREATE_RELIES_ON_SQL_LAYER 128
258
309
The following flags (OR-ed) are passed to handler::info() method.
301
352
Errorcodes given by handler functions
303
optimizer::sum_query() assumes these codes are > 1
354
opt_sum_query() assumes these codes are > 1
304
355
Do not add error numbers before HA_ERR_FIRST.
305
356
If necessary to add lower numbers, change HA_ERR_FIRST accordingly.
386
437
/* Other constants */
388
typedef unsigned long key_part_map;
439
#define HA_NAMELEN 64 /* Max length of saved filename */
440
#define NO_SUCH_KEY (~(uint)0) /* used as a key no. */
442
typedef ulong key_part_map;
389
443
#define HA_WHOLE_KEY (~(key_part_map)0)
391
445
/* Intern constants in databases */
405
459
#define MBR_WITHIN 2048
406
460
#define MBR_DISJOINT 4096
407
461
#define MBR_EQUAL 8192
462
#define MBR_DATA 16384
408
463
#define SEARCH_NULL_ARE_EQUAL 32768 /* NULL in keys are equal */
409
464
#define SEARCH_NULL_ARE_NOT_EQUAL 65536 /* NULL in keys are not equal */
411
466
/* bits in opt_flag */
412
468
#define READ_CACHE_USED 2
413
469
#define READ_CHECK_USED 4
414
470
#define KEY_READ_USED 8
422
478
#define HA_STATE_DELETED 8
423
479
#define HA_STATE_NEXT_FOUND 16 /* Next found record (record before) */
424
480
#define HA_STATE_PREV_FOUND 32 /* Prev found record (record after) */
481
#define HA_STATE_NO_KEY 64 /* Last read didn't find record */
425
482
#define HA_STATE_KEY_CHANGED 128
426
483
#define HA_STATE_WRITE_AT_END 256 /* set in _ps_find_writepos */
484
#define HA_STATE_BUFF_SAVED 512 /* If current keybuff is info->buff */
427
485
#define HA_STATE_ROW_CHANGED 1024 /* To invalide ROW cache */
428
486
#define HA_STATE_EXTEND_BLOCK 2048
429
487
#define HA_STATE_RNEXT_SAME 4096 /* rnext_same occupied lastkey2 */
454
512
/* X > key, i.e. not including the right endpoint */
455
513
#define NEAR_MAX 8
458
This flag means that index is a unique index, and the interval is
516
This flag means that index is a unique index, and the interval is
459
517
equivalent to "AND(keypart_i = const_i)", where all of const_i are not NULLs.
461
519
#define UNIQUE_RANGE 16
464
This flag means that the interval is equivalent to
465
"AND(keypart_i = const_i)", where not all key parts may be used but all of
522
This flag means that the interval is equivalent to
523
"AND(keypart_i = const_i)", where not all key parts may be used but all of
466
524
const_i are not NULLs.
468
526
#define EQ_RANGE 32
471
529
This flag has the same meaning as UNIQUE_RANGE, except that for at least
472
one keypart the condition is "keypart IS NULL".
530
one keypart the condition is "keypart IS NULL".
474
532
#define NULL_RANGE 64
478
536
const unsigned char *key;
538
key_part_map keypart_map;
480
539
enum ha_rkey_function flag;
481
key_part_map keypart_map;
484
542
typedef struct st_key_multi_range
494
552
typedef uint64_t ha_rows;
495
553
#define rows2double(A) uint64_t2double(A)
497
#define HA_POS_ERROR (~ (::drizzled::ha_rows) 0)
498
#define HA_OFFSET_ERROR (~ (::drizzled::internal::my_off_t) 0)
555
#define HA_POS_ERROR (~ (ha_rows) 0)
556
#define HA_OFFSET_ERROR (~ (my_off_t) 0)
500
558
#if SIZEOF_OFF_T == 4
501
559
#define MAX_FILE_SIZE INT32_MAX
506
564
#define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2)
509
} /* namespace drizzled */
511
#endif /* DRIZZLED_BASE_H */
566
/* invalidator function reference for Query Cache */
567
typedef void (* invalidator_by_filename)(const char * filename);
569
#endif /* DRIZZLE_SERVER_BASE_H */