~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/base.h

  • Committer: Brian Aker
  • Date: 2010-05-27 01:25:56 UTC
  • mfrom: (1567.1.4 new-staging)
  • Revision ID: brian@gaz-20100527012556-5zgkirkl7swbigd6
Merge of Brian, Paul. PBXT compile issue, and test framework cleanup. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000 MySQL AB
2
 
 
3
 
   This program is free software; you can redistribute it and/or modify
4
 
   it under the terms of the GNU General Public License as published by
5
 
   the Free Software Foundation; version 2 of the License.
6
 
 
7
 
   This program is distributed in the hope that it will be useful,
8
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 
   GNU General Public License for more details.
11
 
 
12
 
   You should have received a copy of the GNU General Public License
13
 
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; version 2 of the License.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
15
19
 
16
20
/* This file includes constants used with all databases */
17
21
 
18
 
/** 
19
 
 * @TODO Name this file something better and split it out if necessary.  
20
 
 * base.h isn't descriptive, especially compared to global.h 
 
22
/**
 
23
 * @TODO Name this file something better and split it out if necessary.
21
24
 *
22
25
 * @TODO Convert HA_XXX defines into enums and/or bitmaps
23
26
 */
24
27
 
25
 
#ifndef DRIZZLE_SERVER_BASE_H
26
 
#define DRIZZLE_SERVER_BASE_H
27
 
 
28
 
#ifndef stdin                           /* Included first in handler */
29
 
#define CHSIZE_USED
30
 
#include <drizzled/global.h>
31
 
#include <mysys/my_dir.h>               /* This includes types */
32
 
#include <mysys/my_sys.h>
33
 
#include <mystrings/m_string.h>
34
 
#include <errno.h>
35
 
 
36
 
#ifndef EOVERFLOW
37
 
#define EOVERFLOW 84
38
 
#endif
39
 
 
40
 
#endif  /* stdin */
41
 
#include <mysys/my_list.h>
 
28
#ifndef DRIZZLED_BASE_H
 
29
#define DRIZZLED_BASE_H
 
30
 
 
31
namespace drizzled
 
32
{
42
33
 
43
34
/* The following is bits in the flag parameter to ha_open() */
44
35
 
46
37
#define HA_OPEN_WAIT_IF_LOCKED          1
47
38
#define HA_OPEN_IGNORE_IF_LOCKED        2
48
39
#define HA_OPEN_TMP_TABLE               4       /* Table is a temp table */
49
 
#define HA_OPEN_DELAY_KEY_WRITE         8       /* Don't update index  */
50
 
#define HA_OPEN_ABORT_IF_CRASHED        16
51
 
#define HA_OPEN_FOR_REPAIR              32      /* open even if crashed */
52
 
#define HA_OPEN_FROM_SQL_LAYER          64
53
 
#define HA_OPEN_MMAP                    128     /* open memory mapped */
54
 
#define HA_OPEN_COPY                    256     /* Open copy (for repair) */
55
40
/* Internal temp table, used for temporary results */
56
41
#define HA_OPEN_INTERNAL_TABLE          512
57
42
 
97
82
enum ha_key_alg {
98
83
  HA_KEY_ALG_UNDEF=     0,              /* Not specified (old file) */
99
84
  HA_KEY_ALG_BTREE=     1,              /* B-tree, default one          */
100
 
  HA_KEY_ALG_RTREE=     2,              /* R-tree, for spatial searches */
101
 
  HA_KEY_ALG_HASH=      3,              /* HASH keys (HEAP tables) */
102
 
  HA_KEY_ALG_FULLTEXT=  4               /* FULLTEXT (MyISAM tables) */
 
85
  HA_KEY_ALG_HASH=      3               /* HASH keys (HEAP tables) */
103
86
};
104
87
 
105
88
        /* Index and table build methods */
106
89
 
107
 
enum ha_build_method { 
108
 
  HA_BUILD_DEFAULT, 
 
90
enum ha_build_method {
 
91
  HA_BUILD_DEFAULT,
109
92
  HA_BUILD_ONLINE,
110
 
  HA_BUILD_OFFLINE 
 
93
  HA_BUILD_OFFLINE
111
94
};
112
95
 
113
96
        /* The following is parameter to ha_extra() */
150
133
  HA_EXTRA_CHANGE_KEY_TO_UNIQUE,
151
134
  HA_EXTRA_CHANGE_KEY_TO_DUP,
152
135
  /*
153
 
    When using HA_EXTRA_KEYREAD, overwrite only key member fields and keep 
 
136
    When using HA_EXTRA_KEYREAD, overwrite only key member fields and keep
154
137
    other fields intact. When this is off (by default) InnoDB will use memcpy
155
138
    to overwrite entire row.
156
139
  */
157
140
  HA_EXTRA_KEYREAD_PRESERVE_FIELDS,
158
 
  HA_EXTRA_MMAP,
159
141
  /*
160
142
    Ignore if the a tuple is not found, continue processing the
161
143
    transaction and ignore that 'row'.  Needed for idempotency
176
158
  HA_EXTRA_WRITE_CANNOT_REPLACE,
177
159
  /*
178
160
    Inform handler that delete_row()/update_row() cannot batch deletes/updates
179
 
    and should perform them immediately. This may be needed when table has 
 
161
    and should perform them immediately. This may be needed when table has
180
162
    AFTER DELETE/UPDATE triggers which access to subject table.
181
163
    These flags are reset by the handler::extra(HA_EXTRA_RESET) call.
182
164
  */
191
173
  HA_EXTRA_PREPARE_FOR_RENAME
192
174
};
193
175
 
194
 
/* Compatible option, to be deleted in 6.0 */
195
 
#define HA_EXTRA_PREPARE_FOR_DELETE HA_EXTRA_PREPARE_FOR_DROP
196
 
 
197
176
        /* The following is parameter to ha_panic() */
198
177
 
199
178
enum ha_panic_function {
208
187
  HA_KEYTYPE_END=0,
209
188
  HA_KEYTYPE_TEXT=1,                    /* Key is sorted as letters */
210
189
  HA_KEYTYPE_BINARY=2,                  /* Key is sorted as unsigned chars */
211
 
  HA_KEYTYPE_SHORT_INT=3,
212
190
  HA_KEYTYPE_LONG_INT=4,
213
 
  HA_KEYTYPE_FLOAT=5,
214
191
  HA_KEYTYPE_DOUBLE=6,
215
 
  HA_KEYTYPE_NUM=7,                     /* Not packed num with pre-space */
216
 
  HA_KEYTYPE_USHORT_INT=8,
217
192
  HA_KEYTYPE_ULONG_INT=9,
218
193
  HA_KEYTYPE_LONGLONG=10,
219
194
  HA_KEYTYPE_ULONGLONG=11,
220
 
  HA_KEYTYPE_INT24=12,
221
195
  HA_KEYTYPE_UINT24=13,
222
 
  HA_KEYTYPE_INT8=14,
223
196
  /* Varchar (0-255 bytes) with length packed with 1 byte */
224
197
  HA_KEYTYPE_VARTEXT1=15,               /* Key is sorted as letters */
225
198
  HA_KEYTYPE_VARBINARY1=16,             /* Key is sorted as unsigned chars */
226
199
  /* Varchar (0-65535 bytes) with length packed with 2 bytes */
227
200
  HA_KEYTYPE_VARTEXT2=17,               /* Key is sorted as letters */
228
 
  HA_KEYTYPE_VARBINARY2=18,             /* Key is sorted as unsigned chars */
229
 
  HA_KEYTYPE_BIT=19
 
201
  HA_KEYTYPE_VARBINARY2=18              /* Key is sorted as unsigned chars */
230
202
};
231
203
 
232
 
#define HA_MAX_KEYTYPE  31              /* Must be log2-1 */
233
 
 
234
204
        /* These flags kan be OR:ed to key-flag */
235
205
 
236
206
#define HA_NOSAME                1      /* Set if not dupplicated records */
241
211
#define HA_NULL_ARE_EQUAL       2048    /* NULL in key are cmp as equal */
242
212
#define HA_GENERATED_KEY        8192    /* Automaticly generated key */
243
213
 
244
 
        /* The combination of the above can be used for key type comparison. */
245
 
#define HA_KEYFLAG_MASK (HA_NOSAME | HA_PACK_KEY | HA_AUTO_KEY | \
246
 
                         HA_BINARY_PACK_KEY | HA_UNIQUE_CHECK | \
247
 
                         HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
248
 
 
249
214
#define HA_KEY_HAS_PART_KEY_SEG 65536   /* Key contains partial segments */
250
215
 
251
216
        /* Automatic bits in key-flag */
254
219
#define HA_VAR_LENGTH_KEY        8
255
220
#define HA_NULL_PART_KEY         64
256
221
#define HA_USES_COMMENT          4096
257
 
#define HA_USES_BLOCK_SIZE       ((uint) 32768)
 
222
#define HA_USES_BLOCK_SIZE       ((uint32_t) 32768)
258
223
#define HA_SORT_ALLOWS_SAME      512    /* Intern bit when sorting records */
259
224
 
260
225
        /* These flags can be added to key-seg-flag */
278
243
#define HA_OPTION_PACK_RECORD           1
279
244
#define HA_OPTION_PACK_KEYS             2
280
245
#define HA_OPTION_COMPRESS_RECORD       4
281
 
#define HA_OPTION_LONG_BLOB_PTR         8 /* new ISAM format */
282
246
#define HA_OPTION_TMP_TABLE             16
283
 
#define HA_OPTION_CHECKSUM              32
284
 
#define HA_OPTION_DELAY_KEY_WRITE       64
285
247
#define HA_OPTION_NO_PACK_KEYS          128  /* Reserved for MySQL */
286
 
#define HA_OPTION_CREATE_FROM_ENGINE    256
287
 
#define HA_OPTION_RELIES_ON_SQL_LAYER   512
288
 
#define HA_OPTION_NULL_FIELDS           1024
289
 
#define HA_OPTION_PAGE_CHECKSUM         2048
290
 
#define HA_OPTION_TEMP_COMPRESS_RECORD  ((uint) 16384)  /* set by isamchk */
291
 
#define HA_OPTION_READ_ONLY_DATA        ((uint) 32768)  /* Set by isamchk */
 
248
#define HA_OPTION_TEMP_COMPRESS_RECORD  ((uint32_t) 16384)      /* set by isamchk */
 
249
#define HA_OPTION_READ_ONLY_DATA        ((uint32_t) 32768)      /* Set by isamchk */
292
250
 
293
251
        /* Bits in flag to create() */
294
252
 
295
253
#define HA_DONT_TOUCH_DATA      1       /* Don't empty datafile (isamchk) */
296
254
#define HA_PACK_RECORD          2       /* Request packed record format */
297
255
#define HA_CREATE_TMP_TABLE     4
298
 
#define HA_CREATE_CHECKSUM      8
299
256
#define HA_CREATE_KEEP_FILES    16      /* don't overwrite .MYD and MYI */
300
 
#define HA_CREATE_PAGE_CHECKSUM 32
301
 
#define HA_CREATE_DELAY_KEY_WRITE 64
302
 
#define HA_CREATE_RELIES_ON_SQL_LAYER 128
303
257
 
304
258
/*
305
259
  The following flags (OR-ed) are passed to handler::info() method.
347
301
/*
348
302
  Errorcodes given by handler functions
349
303
 
350
 
  opt_sum_query() assumes these codes are > 1
 
304
  optimizer::sum_query() assumes these codes are > 1
351
305
  Do not add error numbers before HA_ERR_FIRST.
352
306
  If necessary to add lower numbers, change HA_ERR_FIRST accordingly.
353
307
*/
432
386
 
433
387
        /* Other constants */
434
388
 
435
 
#define HA_NAMELEN 64                   /* Max length of saved filename */
436
 
#define NO_SUCH_KEY (~(uint)0)          /* used as a key no. */
437
 
 
438
 
typedef ulong key_part_map;
 
389
typedef unsigned long key_part_map;
439
390
#define HA_WHOLE_KEY  (~(key_part_map)0)
440
391
 
441
392
        /* Intern constants in databases */
455
406
#define MBR_WITHIN      2048
456
407
#define MBR_DISJOINT    4096
457
408
#define MBR_EQUAL       8192
458
 
#define MBR_DATA        16384
459
409
#define SEARCH_NULL_ARE_EQUAL 32768     /* NULL in keys are equal */
460
410
#define SEARCH_NULL_ARE_NOT_EQUAL 65536 /* NULL in keys are not equal */
461
411
 
462
412
        /* bits in opt_flag */
463
 
#define QUICK_USED      1
464
413
#define READ_CACHE_USED 2
465
414
#define READ_CHECK_USED 4
466
415
#define KEY_READ_USED   8
474
423
#define HA_STATE_DELETED        8
475
424
#define HA_STATE_NEXT_FOUND     16      /* Next found record (record before) */
476
425
#define HA_STATE_PREV_FOUND     32      /* Prev found record (record after) */
477
 
#define HA_STATE_NO_KEY         64      /* Last read didn't find record */
478
426
#define HA_STATE_KEY_CHANGED    128
479
427
#define HA_STATE_WRITE_AT_END   256     /* set in _ps_find_writepos */
480
 
#define HA_STATE_BUFF_SAVED     512     /* If current keybuff is info->buff */
481
428
#define HA_STATE_ROW_CHANGED    1024    /* To invalide ROW cache */
482
429
#define HA_STATE_EXTEND_BLOCK   2048
483
430
#define HA_STATE_RNEXT_SAME     4096    /* rnext_same occupied lastkey2 */
508
455
/* X > key, i.e. not including the right endpoint */
509
456
#define NEAR_MAX        8
510
457
 
511
 
/* 
512
 
  This flag means that index is a unique index, and the interval is 
 
458
/*
 
459
  This flag means that index is a unique index, and the interval is
513
460
  equivalent to "AND(keypart_i = const_i)", where all of const_i are not NULLs.
514
461
*/
515
462
#define UNIQUE_RANGE    16
516
463
 
517
 
/* 
518
 
  This flag means that the interval is equivalent to 
519
 
  "AND(keypart_i = const_i)", where not all key parts may be used but all of 
 
464
/*
 
465
  This flag means that the interval is equivalent to
 
466
  "AND(keypart_i = const_i)", where not all key parts may be used but all of
520
467
  const_i are not NULLs.
521
468
*/
522
469
#define EQ_RANGE        32
523
470
 
524
471
/*
525
472
  This flag has the same meaning as UNIQUE_RANGE, except that for at least
526
 
  one keypart the condition is "keypart IS NULL". 
 
473
  one keypart the condition is "keypart IS NULL".
527
474
*/
528
475
#define NULL_RANGE      64
529
476
 
530
477
typedef struct st_key_range
531
478
{
532
 
  const uchar *key;
533
 
  uint length;
 
479
  const unsigned char *key;
 
480
  uint32_t length;
 
481
  enum ha_rkey_function flag;
534
482
  key_part_map keypart_map;
535
 
  enum ha_rkey_function flag;
536
483
} key_range;
537
484
 
538
485
typedef struct st_key_multi_range
540
487
  key_range start_key;
541
488
  key_range end_key;
542
489
  char  *ptr;                 /* Free to use by caller (ptr to row etc) */
543
 
  uint  range_flag;           /* key range flags see above */
 
490
  uint32_t  range_flag;           /* key range flags see above */
544
491
} KEY_MULTI_RANGE;
545
492
 
546
493
 
548
495
typedef uint64_t        ha_rows;
549
496
#define rows2double(A)  uint64_t2double(A)
550
497
 
551
 
#define HA_POS_ERROR    (~ (ha_rows) 0)
552
 
#define HA_OFFSET_ERROR (~ (my_off_t) 0)
 
498
#define HA_POS_ERROR    (~ (::drizzled::ha_rows) 0)
 
499
#define HA_OFFSET_ERROR (~ (::drizzled::internal::my_off_t) 0)
553
500
 
554
501
#if SIZEOF_OFF_T == 4
555
502
#define MAX_FILE_SIZE   INT32_MAX
559
506
 
560
507
#define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2)
561
508
 
562
 
/* invalidator function reference for Query Cache */
563
 
typedef void (* invalidator_by_filename)(const char * filename);
564
 
 
565
 
#endif /* DRIZZLE_SERVER_BASE_H */
 
509
 
 
510
} /* namespace drizzled */
 
511
 
 
512
#endif /* DRIZZLED_BASE_H */