~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/base.h

  • Committer: Monty Taylor
  • Date: 2008-11-16 06:29:53 UTC
  • mto: (584.1.9 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081116062953-ivdltjmfe009b5fr
Moved stuff into item/

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
/* This file includes constants used with all databases */
21
21
 
22
 
/**
23
 
 * @TODO Name this file something better and split it out if necessary.
 
22
/** 
 
23
 * @TODO Name this file something better and split it out if necessary.  
 
24
 * base.h isn't descriptive, especially compared to global.h 
24
25
 *
25
26
 * @TODO Convert HA_XXX defines into enums and/or bitmaps
26
27
 */
27
28
 
28
 
#ifndef DRIZZLED_BASE_H
29
 
#define DRIZZLED_BASE_H
30
 
 
31
 
namespace drizzled
32
 
{
 
29
#ifndef DRIZZLE_SERVER_BASE_H
 
30
#define DRIZZLE_SERVER_BASE_H
 
31
 
 
32
#ifndef stdin                           /* Included first in handler */
 
33
#define CHSIZE_USED
 
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>
 
38
#include <errno.h>
 
39
 
 
40
#ifndef EOVERFLOW
 
41
#define EOVERFLOW 84
 
42
#endif
 
43
 
 
44
#endif  /* stdin */
 
45
#include <mysys/my_list.h>
33
46
 
34
47
/* The following is bits in the flag parameter to ha_open() */
35
48
 
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
42
61
 
82
101
enum ha_key_alg {
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) */
86
107
};
87
108
 
88
109
        /* Index and table build methods */
89
110
 
90
 
enum ha_build_method {
91
 
  HA_BUILD_DEFAULT,
 
111
enum ha_build_method { 
 
112
  HA_BUILD_DEFAULT, 
92
113
  HA_BUILD_ONLINE,
93
 
  HA_BUILD_OFFLINE
 
114
  HA_BUILD_OFFLINE 
94
115
};
95
116
 
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,
135
156
  /*
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.
139
160
  */
140
161
  HA_EXTRA_KEYREAD_PRESERVE_FIELDS,
 
162
  HA_EXTRA_MMAP,
141
163
  /*
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,
159
181
  /*
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.
164
186
  */
173
195
  HA_EXTRA_PREPARE_FOR_RENAME
174
196
};
175
197
 
 
198
/* Compatible option, to be deleted in 6.0 */
 
199
#define HA_EXTRA_PREPARE_FOR_DELETE HA_EXTRA_PREPARE_FOR_DROP
 
200
 
176
201
        /* The following is parameter to ha_panic() */
177
202
 
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,
 
217
  HA_KEYTYPE_FLOAT=5,
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,
 
224
  HA_KEYTYPE_INT24=12,
 
225
  HA_KEYTYPE_UINT24=13,
 
226
  HA_KEYTYPE_INT8=14,
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 */
 
233
  HA_KEYTYPE_BIT=19
201
234
};
202
235
 
 
236
#define HA_MAX_KEYTYPE  31              /* Must be log2-1 */
 
237
 
203
238
        /* These flags kan be OR:ed to key-flag */
204
239
 
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 */
212
247
 
 
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)
 
252
 
213
253
#define HA_KEY_HAS_PART_KEY_SEG 65536   /* Key contains partial segments */
214
254
 
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 */
223
263
 
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 */
249
296
 
250
297
        /* Bits in flag to create() */
251
298
 
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
256
307
 
257
308
/*
258
309
  The following flags (OR-ed) are passed to handler::info() method.
300
351
/*
301
352
  Errorcodes given by handler functions
302
353
 
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.
306
357
*/
385
436
 
386
437
        /* Other constants */
387
438
 
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. */
 
441
 
 
442
typedef ulong key_part_map;
389
443
#define HA_WHOLE_KEY  (~(key_part_map)0)
390
444
 
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 */
410
465
 
411
466
        /* bits in opt_flag */
 
467
#define QUICK_USED      1
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
456
514
 
457
 
/*
458
 
  This flag means that index is a unique index, and the interval is
 
515
/* 
 
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.
460
518
*/
461
519
#define UNIQUE_RANGE    16
462
520
 
463
 
/*
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
 
521
/* 
 
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.
467
525
*/
468
526
#define EQ_RANGE        32
469
527
 
470
528
/*
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". 
473
531
*/
474
532
#define NULL_RANGE      64
475
533
 
477
535
{
478
536
  const unsigned char *key;
479
537
  uint32_t length;
 
538
  key_part_map keypart_map;
480
539
  enum ha_rkey_function flag;
481
 
  key_part_map keypart_map;
482
540
} key_range;
483
541
 
484
542
typedef struct st_key_multi_range
494
552
typedef uint64_t        ha_rows;
495
553
#define rows2double(A)  uint64_t2double(A)
496
554
 
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)
499
557
 
500
558
#if SIZEOF_OFF_T == 4
501
559
#define MAX_FILE_SIZE   INT32_MAX
505
563
 
506
564
#define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2)
507
565
 
508
 
 
509
 
} /* namespace drizzled */
510
 
 
511
 
#endif /* DRIZZLED_BASE_H */
 
566
/* invalidator function reference for Query Cache */
 
567
typedef void (* invalidator_by_filename)(const char * filename);
 
568
 
 
569
#endif /* DRIZZLE_SERVER_BASE_H */