~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/base.h

  • Committer: Brian Aker
  • Date: 2009-05-23 17:13:03 UTC
  • mfrom: (1034.1.8 merge)
  • Revision ID: brian@gaz-20090523171303-d28xhutqic0xe2b4
Merge Brian

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
/**
23
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
#define CHSIZE_USED
35
33
 
36
34
/* The following is bits in the flag parameter to ha_open() */
37
35
 
39
37
#define HA_OPEN_WAIT_IF_LOCKED          1
40
38
#define HA_OPEN_IGNORE_IF_LOCKED        2
41
39
#define HA_OPEN_TMP_TABLE               4       /* Table is a temp table */
 
40
#define HA_OPEN_DELAY_KEY_WRITE         8       /* Don't update index  */
 
41
#define HA_OPEN_ABORT_IF_CRASHED        16
 
42
#define HA_OPEN_FOR_REPAIR              32      /* open even if crashed */
 
43
#define HA_OPEN_FROM_SQL_LAYER          64
 
44
#define HA_OPEN_MMAP                    128     /* open memory mapped */
 
45
#define HA_OPEN_COPY                    256     /* Open copy (for repair) */
42
46
/* Internal temp table, used for temporary results */
43
47
#define HA_OPEN_INTERNAL_TABLE          512
44
48
 
84
88
enum ha_key_alg {
85
89
  HA_KEY_ALG_UNDEF=     0,              /* Not specified (old file) */
86
90
  HA_KEY_ALG_BTREE=     1,              /* B-tree, default one          */
87
 
  HA_KEY_ALG_HASH=      3               /* HASH keys (HEAP tables) */
 
91
  HA_KEY_ALG_RTREE=     2,              /* R-tree, for spatial searches */
 
92
  HA_KEY_ALG_HASH=      3,              /* HASH keys (HEAP tables) */
 
93
  HA_KEY_ALG_FULLTEXT=  4               /* FULLTEXT (MyISAM tables) */
88
94
};
89
95
 
90
96
        /* Index and table build methods */
140
146
    to overwrite entire row.
141
147
  */
142
148
  HA_EXTRA_KEYREAD_PRESERVE_FIELDS,
 
149
  HA_EXTRA_MMAP,
143
150
  /*
144
151
    Ignore if the a tuple is not found, continue processing the
145
152
    transaction and ignore that 'row'.  Needed for idempotency
175
182
  HA_EXTRA_PREPARE_FOR_RENAME
176
183
};
177
184
 
 
185
/* Compatible option, to be deleted in 6.0 */
 
186
#define HA_EXTRA_PREPARE_FOR_DELETE HA_EXTRA_PREPARE_FOR_DROP
 
187
 
178
188
        /* The following is parameter to ha_panic() */
179
189
 
180
190
enum ha_panic_function {
189
199
  HA_KEYTYPE_END=0,
190
200
  HA_KEYTYPE_TEXT=1,                    /* Key is sorted as letters */
191
201
  HA_KEYTYPE_BINARY=2,                  /* Key is sorted as unsigned chars */
 
202
  HA_KEYTYPE_SHORT_INT=3,
192
203
  HA_KEYTYPE_LONG_INT=4,
 
204
  HA_KEYTYPE_FLOAT=5,
193
205
  HA_KEYTYPE_DOUBLE=6,
 
206
  HA_KEYTYPE_NUM=7,                     /* Not packed num with pre-space */
 
207
  HA_KEYTYPE_USHORT_INT=8,
194
208
  HA_KEYTYPE_ULONG_INT=9,
195
209
  HA_KEYTYPE_LONGLONG=10,
196
210
  HA_KEYTYPE_ULONGLONG=11,
 
211
  HA_KEYTYPE_INT24=12,
 
212
  HA_KEYTYPE_UINT24=13,
 
213
  HA_KEYTYPE_INT8=14,
197
214
  /* Varchar (0-255 bytes) with length packed with 1 byte */
198
215
  HA_KEYTYPE_VARTEXT1=15,               /* Key is sorted as letters */
199
216
  HA_KEYTYPE_VARBINARY1=16,             /* Key is sorted as unsigned chars */
200
217
  /* Varchar (0-65535 bytes) with length packed with 2 bytes */
201
218
  HA_KEYTYPE_VARTEXT2=17,               /* Key is sorted as letters */
202
 
  HA_KEYTYPE_VARBINARY2=18              /* Key is sorted as unsigned chars */
 
219
  HA_KEYTYPE_VARBINARY2=18,             /* Key is sorted as unsigned chars */
 
220
  HA_KEYTYPE_BIT=19
203
221
};
204
222
 
 
223
#define HA_MAX_KEYTYPE  31              /* Must be log2-1 */
 
224
 
205
225
        /* These flags kan be OR:ed to key-flag */
206
226
 
207
227
#define HA_NOSAME                1      /* Set if not dupplicated records */
212
232
#define HA_NULL_ARE_EQUAL       2048    /* NULL in key are cmp as equal */
213
233
#define HA_GENERATED_KEY        8192    /* Automaticly generated key */
214
234
 
 
235
        /* The combination of the above can be used for key type comparison. */
 
236
#define HA_KEYFLAG_MASK (HA_NOSAME | HA_PACK_KEY | HA_AUTO_KEY | \
 
237
                         HA_BINARY_PACK_KEY | HA_UNIQUE_CHECK | \
 
238
                         HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
 
239
 
215
240
#define HA_KEY_HAS_PART_KEY_SEG 65536   /* Key contains partial segments */
216
241
 
217
242
        /* Automatic bits in key-flag */
244
269
#define HA_OPTION_PACK_RECORD           1
245
270
#define HA_OPTION_PACK_KEYS             2
246
271
#define HA_OPTION_COMPRESS_RECORD       4
 
272
#define HA_OPTION_LONG_BLOB_PTR         8 /* new ISAM format */
247
273
#define HA_OPTION_TMP_TABLE             16
 
274
#define HA_OPTION_CHECKSUM              32
 
275
#define HA_OPTION_DELAY_KEY_WRITE       64
248
276
#define HA_OPTION_NO_PACK_KEYS          128  /* Reserved for MySQL */
 
277
#define HA_OPTION_CREATE_FROM_ENGINE    256
 
278
#define HA_OPTION_RELIES_ON_SQL_LAYER   512
 
279
#define HA_OPTION_NULL_FIELDS           1024
 
280
#define HA_OPTION_PAGE_CHECKSUM         2048
249
281
#define HA_OPTION_TEMP_COMPRESS_RECORD  ((uint32_t) 16384)      /* set by isamchk */
250
282
#define HA_OPTION_READ_ONLY_DATA        ((uint32_t) 32768)      /* Set by isamchk */
251
283
 
254
286
#define HA_DONT_TOUCH_DATA      1       /* Don't empty datafile (isamchk) */
255
287
#define HA_PACK_RECORD          2       /* Request packed record format */
256
288
#define HA_CREATE_TMP_TABLE     4
 
289
#define HA_CREATE_CHECKSUM      8
257
290
#define HA_CREATE_KEEP_FILES    16      /* don't overwrite .MYD and MYI */
 
291
#define HA_CREATE_PAGE_CHECKSUM 32
 
292
#define HA_CREATE_DELAY_KEY_WRITE 64
 
293
#define HA_CREATE_RELIES_ON_SQL_LAYER 128
258
294
 
259
295
/*
260
296
  The following flags (OR-ed) are passed to handler::info() method.
302
338
/*
303
339
  Errorcodes given by handler functions
304
340
 
305
 
  optimizer::sum_query() assumes these codes are > 1
 
341
  opt_sum_query() assumes these codes are > 1
306
342
  Do not add error numbers before HA_ERR_FIRST.
307
343
  If necessary to add lower numbers, change HA_ERR_FIRST accordingly.
308
344
*/
387
423
 
388
424
        /* Other constants */
389
425
 
390
 
typedef unsigned long key_part_map;
 
426
#define HA_NAMELEN 64                   /* Max length of saved filename */
 
427
#define NO_SUCH_KEY (~(uint32_t)0)          /* used as a key no. */
 
428
 
 
429
typedef ulong key_part_map;
391
430
#define HA_WHOLE_KEY  (~(key_part_map)0)
392
431
 
393
432
        /* Intern constants in databases */
407
446
#define MBR_WITHIN      2048
408
447
#define MBR_DISJOINT    4096
409
448
#define MBR_EQUAL       8192
 
449
#define MBR_DATA        16384
410
450
#define SEARCH_NULL_ARE_EQUAL 32768     /* NULL in keys are equal */
411
451
#define SEARCH_NULL_ARE_NOT_EQUAL 65536 /* NULL in keys are not equal */
412
452
 
413
453
        /* bits in opt_flag */
 
454
#define QUICK_USED      1
414
455
#define READ_CACHE_USED 2
415
456
#define READ_CHECK_USED 4
416
457
#define KEY_READ_USED   8
424
465
#define HA_STATE_DELETED        8
425
466
#define HA_STATE_NEXT_FOUND     16      /* Next found record (record before) */
426
467
#define HA_STATE_PREV_FOUND     32      /* Prev found record (record after) */
 
468
#define HA_STATE_NO_KEY         64      /* Last read didn't find record */
427
469
#define HA_STATE_KEY_CHANGED    128
428
470
#define HA_STATE_WRITE_AT_END   256     /* set in _ps_find_writepos */
 
471
#define HA_STATE_BUFF_SAVED     512     /* If current keybuff is info->buff */
429
472
#define HA_STATE_ROW_CHANGED    1024    /* To invalide ROW cache */
430
473
#define HA_STATE_EXTEND_BLOCK   2048
431
474
#define HA_STATE_RNEXT_SAME     4096    /* rnext_same occupied lastkey2 */
475
518
*/
476
519
#define NULL_RANGE      64
477
520
 
478
 
class key_range
 
521
typedef struct st_key_range
479
522
{
480
 
public:
481
523
  const unsigned char *key;
482
524
  uint32_t length;
483
525
  enum ha_rkey_function flag;
484
526
  key_part_map keypart_map;
485
 
};
 
527
} key_range;
486
528
 
487
 
class KEY_MULTI_RANGE
 
529
typedef struct st_key_multi_range
488
530
{
489
 
public:
490
531
  key_range start_key;
491
532
  key_range end_key;
492
533
  char  *ptr;                 /* Free to use by caller (ptr to row etc) */
493
534
  uint32_t  range_flag;           /* key range flags see above */
494
 
};
 
535
} KEY_MULTI_RANGE;
495
536
 
496
537
 
497
538
/* For number of records */
498
539
typedef uint64_t        ha_rows;
499
 
inline static double rows2double(ha_rows rows)
500
 
{  
501
 
  return uint64_t2double(rows);
502
 
}
 
540
#define rows2double(A)  uint64_t2double(A)
503
541
 
504
 
#define HA_POS_ERROR    (~ (::drizzled::ha_rows) 0)
505
 
#define HA_OFFSET_ERROR (~ (::drizzled::internal::my_off_t) 0)
 
542
#define HA_POS_ERROR    (~ (ha_rows) 0)
 
543
#define HA_OFFSET_ERROR (~ (my_off_t) 0)
506
544
 
507
545
#if SIZEOF_OFF_T == 4
508
546
#define MAX_FILE_SIZE   INT32_MAX
510
548
#define MAX_FILE_SIZE   INT64_MAX
511
549
#endif
512
550
 
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 */
 
551
#define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2)
 
552
 
 
553
#endif /* DRIZZLE_SERVER_BASE_H */