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
#include "definitions.h"
30
#ifndef DRIZZLED_BASE_H
31
#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>
36
47
/* The following is bits in the flag parameter to ha_open() */
39
50
#define HA_OPEN_WAIT_IF_LOCKED 1
40
51
#define HA_OPEN_IGNORE_IF_LOCKED 2
41
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) */
42
59
/* Internal temp table, used for temporary results */
43
60
#define HA_OPEN_INTERNAL_TABLE 512
85
102
HA_KEY_ALG_UNDEF= 0, /* Not specified (old file) */
86
103
HA_KEY_ALG_BTREE= 1, /* B-tree, default one */
87
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) */
90
109
/* Index and table build methods */
92
enum ha_build_method {
111
enum ha_build_method {
98
117
/* The following is parameter to ha_extra() */
135
154
HA_EXTRA_CHANGE_KEY_TO_UNIQUE,
136
155
HA_EXTRA_CHANGE_KEY_TO_DUP,
138
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
139
158
other fields intact. When this is off (by default) InnoDB will use memcpy
140
159
to overwrite entire row.
142
161
HA_EXTRA_KEYREAD_PRESERVE_FIELDS,
144
164
Ignore if the a tuple is not found, continue processing the
145
165
transaction and ignore that 'row'. Needed for idempotency
160
180
HA_EXTRA_WRITE_CANNOT_REPLACE,
162
182
Inform handler that delete_row()/update_row() cannot batch deletes/updates
163
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
164
184
AFTER DELETE/UPDATE triggers which access to subject table.
165
185
These flags are reset by the handler::extra(HA_EXTRA_RESET) call.
175
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
178
201
/* The following is parameter to ha_panic() */
180
203
enum ha_panic_function {
189
212
HA_KEYTYPE_END=0,
190
213
HA_KEYTYPE_TEXT=1, /* Key is sorted as letters */
191
214
HA_KEYTYPE_BINARY=2, /* Key is sorted as unsigned chars */
215
HA_KEYTYPE_SHORT_INT=3,
192
216
HA_KEYTYPE_LONG_INT=4,
193
218
HA_KEYTYPE_DOUBLE=6,
219
HA_KEYTYPE_NUM=7, /* Not packed num with pre-space */
220
HA_KEYTYPE_USHORT_INT=8,
194
221
HA_KEYTYPE_ULONG_INT=9,
195
222
HA_KEYTYPE_LONGLONG=10,
196
223
HA_KEYTYPE_ULONGLONG=11,
225
HA_KEYTYPE_UINT24=13,
197
227
/* Varchar (0-255 bytes) with length packed with 1 byte */
198
228
HA_KEYTYPE_VARTEXT1=15, /* Key is sorted as letters */
199
229
HA_KEYTYPE_VARBINARY1=16, /* Key is sorted as unsigned chars */
200
230
/* Varchar (0-65535 bytes) with length packed with 2 bytes */
201
231
HA_KEYTYPE_VARTEXT2=17, /* Key is sorted as letters */
202
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 */
205
238
/* These flags kan be OR:ed to key-flag */
207
240
#define HA_NOSAME 1 /* Set if not dupplicated records */
212
245
#define HA_NULL_ARE_EQUAL 2048 /* NULL in key are cmp as equal */
213
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)
215
253
#define HA_KEY_HAS_PART_KEY_SEG 65536 /* Key contains partial segments */
217
255
/* Automatic bits in key-flag */
220
258
#define HA_VAR_LENGTH_KEY 8
221
259
#define HA_NULL_PART_KEY 64
222
260
#define HA_USES_COMMENT 4096
223
#define HA_USES_BLOCK_SIZE ((uint32_t) 32768)
261
#define HA_USES_BLOCK_SIZE ((uint) 32768)
224
262
#define HA_SORT_ALLOWS_SAME 512 /* Intern bit when sorting records */
226
264
/* These flags can be added to key-seg-flag */
244
282
#define HA_OPTION_PACK_RECORD 1
245
283
#define HA_OPTION_PACK_KEYS 2
246
284
#define HA_OPTION_COMPRESS_RECORD 4
285
#define HA_OPTION_LONG_BLOB_PTR 8 /* new ISAM format */
247
286
#define HA_OPTION_TMP_TABLE 16
287
#define HA_OPTION_CHECKSUM 32
288
#define HA_OPTION_DELAY_KEY_WRITE 64
248
289
#define HA_OPTION_NO_PACK_KEYS 128 /* Reserved for MySQL */
249
#define HA_OPTION_TEMP_COMPRESS_RECORD ((uint32_t) 16384) /* set by isamchk */
250
#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 */
252
297
/* Bits in flag to create() */
254
299
#define HA_DONT_TOUCH_DATA 1 /* Don't empty datafile (isamchk) */
255
300
#define HA_PACK_RECORD 2 /* Request packed record format */
256
301
#define HA_CREATE_TMP_TABLE 4
302
#define HA_CREATE_CHECKSUM 8
257
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
260
309
The following flags (OR-ed) are passed to handler::info() method.
303
352
Errorcodes given by handler functions
305
optimizer::sum_query() assumes these codes are > 1
354
opt_sum_query() assumes these codes are > 1
306
355
Do not add error numbers before HA_ERR_FIRST.
307
356
If necessary to add lower numbers, change HA_ERR_FIRST accordingly.
388
437
/* Other constants */
390
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;
391
443
#define HA_WHOLE_KEY (~(key_part_map)0)
393
445
/* Intern constants in databases */
407
459
#define MBR_WITHIN 2048
408
460
#define MBR_DISJOINT 4096
409
461
#define MBR_EQUAL 8192
462
#define MBR_DATA 16384
410
463
#define SEARCH_NULL_ARE_EQUAL 32768 /* NULL in keys are equal */
411
464
#define SEARCH_NULL_ARE_NOT_EQUAL 65536 /* NULL in keys are not equal */
413
466
/* bits in opt_flag */
414
468
#define READ_CACHE_USED 2
415
469
#define READ_CHECK_USED 4
416
470
#define KEY_READ_USED 8
424
478
#define HA_STATE_DELETED 8
425
479
#define HA_STATE_NEXT_FOUND 16 /* Next found record (record before) */
426
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 */
427
482
#define HA_STATE_KEY_CHANGED 128
428
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 */
429
485
#define HA_STATE_ROW_CHANGED 1024 /* To invalide ROW cache */
430
486
#define HA_STATE_EXTEND_BLOCK 2048
431
487
#define HA_STATE_RNEXT_SAME 4096 /* rnext_same occupied lastkey2 */
456
512
/* X > key, i.e. not including the right endpoint */
457
513
#define NEAR_MAX 8
460
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
461
517
equivalent to "AND(keypart_i = const_i)", where all of const_i are not NULLs.
463
519
#define UNIQUE_RANGE 16
466
This flag means that the interval is equivalent to
467
"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
468
524
const_i are not NULLs.
470
526
#define EQ_RANGE 32
473
529
This flag has the same meaning as UNIQUE_RANGE, except that for at least
474
one keypart the condition is "keypart IS NULL".
530
one keypart the condition is "keypart IS NULL".
476
532
#define NULL_RANGE 64
534
typedef struct st_key_range
481
536
const unsigned char *key;
538
key_part_map keypart_map;
483
539
enum ha_rkey_function flag;
484
key_part_map keypart_map;
487
class KEY_MULTI_RANGE
542
typedef struct st_key_multi_range
490
544
key_range start_key;
491
545
key_range end_key;
492
546
char *ptr; /* Free to use by caller (ptr to row etc) */
493
547
uint32_t range_flag; /* key range flags see above */
497
551
/* For number of records */
498
552
typedef uint64_t ha_rows;
499
inline static double rows2double(ha_rows rows)
501
return uint64_t2double(rows);
553
#define rows2double(A) uint64_t2double(A)
504
#define HA_POS_ERROR (~ (::drizzled::ha_rows) 0)
505
#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)
507
558
#if SIZEOF_OFF_T == 4
508
559
#define MAX_FILE_SIZE INT32_MAX
510
561
#define MAX_FILE_SIZE INT64_MAX
513
inline static uint32_t ha_varchar_packlength(uint32_t field_length)
515
return (field_length < 256 ? 1 :2);
519
} /* namespace drizzled */
521
#endif /* DRIZZLED_BASE_H */
564
#define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2)
566
/* invalidator function reference for Query Cache */
567
typedef void (* invalidator_by_filename)(const char * filename);
569
#endif /* DRIZZLE_SERVER_BASE_H */