~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/base.h

  • Committer: Monty Taylor
  • Date: 2008-10-22 23:45:01 UTC
  • Revision ID: monty@inaugust.com-20081022234501-hwybvprata8ba98l
Moved handler_error_messages array out of header file. Moved associated
functions to live with it.

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
 
#include "definitions.h"
29
 
 
30
 
#ifndef DRIZZLED_BASE_H
31
 
#define DRIZZLED_BASE_H
32
 
 
33
 
namespace drizzled
34
 
{
 
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>
35
46
 
36
47
/* The following is bits in the flag parameter to ha_open() */
37
48
 
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
44
61
 
84
101
enum ha_key_alg {
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) */
88
107
};
89
108
 
90
109
        /* Index and table build methods */
91
110
 
92
 
enum ha_build_method {
93
 
  HA_BUILD_DEFAULT,
 
111
enum ha_build_method { 
 
112
  HA_BUILD_DEFAULT, 
94
113
  HA_BUILD_ONLINE,
95
 
  HA_BUILD_OFFLINE
 
114
  HA_BUILD_OFFLINE 
96
115
};
97
116
 
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,
137
156
  /*
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.
141
160
  */
142
161
  HA_EXTRA_KEYREAD_PRESERVE_FIELDS,
 
162
  HA_EXTRA_MMAP,
143
163
  /*
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,
161
181
  /*
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.
166
186
  */
175
195
  HA_EXTRA_PREPARE_FOR_RENAME
176
196
};
177
197
 
 
198
/* Compatible option, to be deleted in 6.0 */
 
199
#define HA_EXTRA_PREPARE_FOR_DELETE HA_EXTRA_PREPARE_FOR_DROP
 
200
 
178
201
        /* The following is parameter to ha_panic() */
179
202
 
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,
 
217
  HA_KEYTYPE_FLOAT=5,
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,
 
224
  HA_KEYTYPE_INT24=12,
 
225
  HA_KEYTYPE_UINT24=13,
 
226
  HA_KEYTYPE_INT8=14,
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 */
 
233
  HA_KEYTYPE_BIT=19
203
234
};
204
235
 
 
236
#define HA_MAX_KEYTYPE  31              /* Must be log2-1 */
 
237
 
205
238
        /* These flags kan be OR:ed to key-flag */
206
239
 
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 */
214
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
 
215
253
#define HA_KEY_HAS_PART_KEY_SEG 65536   /* Key contains partial segments */
216
254
 
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 */
225
263
 
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 */
251
296
 
252
297
        /* Bits in flag to create() */
253
298
 
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
258
307
 
259
308
/*
260
309
  The following flags (OR-ed) are passed to handler::info() method.
302
351
/*
303
352
  Errorcodes given by handler functions
304
353
 
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.
308
357
*/
387
436
 
388
437
        /* Other constants */
389
438
 
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. */
 
441
 
 
442
typedef ulong key_part_map;
391
443
#define HA_WHOLE_KEY  (~(key_part_map)0)
392
444
 
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 */
412
465
 
413
466
        /* bits in opt_flag */
 
467
#define QUICK_USED      1
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
458
514
 
459
 
/*
460
 
  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 
461
517
  equivalent to "AND(keypart_i = const_i)", where all of const_i are not NULLs.
462
518
*/
463
519
#define UNIQUE_RANGE    16
464
520
 
465
 
/*
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
 
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 
468
524
  const_i are not NULLs.
469
525
*/
470
526
#define EQ_RANGE        32
471
527
 
472
528
/*
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". 
475
531
*/
476
532
#define NULL_RANGE      64
477
533
 
478
 
class key_range
 
534
typedef struct st_key_range
479
535
{
480
 
public:
481
536
  const unsigned char *key;
482
537
  uint32_t length;
 
538
  key_part_map keypart_map;
483
539
  enum ha_rkey_function flag;
484
 
  key_part_map keypart_map;
485
 
};
 
540
} key_range;
486
541
 
487
 
class KEY_MULTI_RANGE
 
542
typedef struct st_key_multi_range
488
543
{
489
 
public:
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 */
494
 
};
 
548
} KEY_MULTI_RANGE;
495
549
 
496
550
 
497
551
/* For number of records */
498
552
typedef uint64_t        ha_rows;
499
 
inline static double rows2double(ha_rows rows)
500
 
{  
501
 
  return uint64_t2double(rows);
502
 
}
 
553
#define rows2double(A)  uint64_t2double(A)
503
554
 
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)
506
557
 
507
558
#if SIZEOF_OFF_T == 4
508
559
#define MAX_FILE_SIZE   INT32_MAX
510
561
#define MAX_FILE_SIZE   INT64_MAX
511
562
#endif
512
563
 
513
 
inline static uint32_t ha_varchar_packlength(uint32_t field_length)
514
 
{
515
 
  return (field_length < 256 ? 1 :2);
516
 
}
517
 
 
518
 
 
519
 
} /* namespace drizzled */
520
 
 
521
 
#endif /* DRIZZLED_BASE_H */
 
564
#define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2)
 
565
 
 
566
/* invalidator function reference for Query Cache */
 
567
typedef void (* invalidator_by_filename)(const char * filename);
 
568
 
 
569
#endif /* DRIZZLE_SERVER_BASE_H */