1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
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.
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.
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
1
/* Copyright (C) 2000 MySQL AB
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.
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.
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 */
20
16
/* This file includes constants used with all databases */
23
* @TODO Name this file something better and split it out if necessary.
25
* @TODO Convert HA_XXX defines into enums and/or bitmaps
28
#include "definitions.h"
30
#ifndef DRIZZLED_BASE_H
31
#define DRIZZLED_BASE_H
21
#ifndef stdin /* Included first in handler */
23
#include <my_global.h>
24
#include <my_dir.h> /* This includes types */
36
36
/* The following is bits in the flag parameter to ha_open() */
39
39
#define HA_OPEN_WAIT_IF_LOCKED 1
40
40
#define HA_OPEN_IGNORE_IF_LOCKED 2
41
41
#define HA_OPEN_TMP_TABLE 4 /* Table is a temp table */
42
#define HA_OPEN_DELAY_KEY_WRITE 8 /* Don't update index */
43
#define HA_OPEN_ABORT_IF_CRASHED 16
44
#define HA_OPEN_FOR_REPAIR 32 /* open even if crashed */
45
#define HA_OPEN_FROM_SQL_LAYER 64
46
#define HA_OPEN_MMAP 128 /* open memory mapped */
47
#define HA_OPEN_COPY 256 /* Open copy (for repair) */
42
48
/* Internal temp table, used for temporary results */
43
49
#define HA_OPEN_INTERNAL_TABLE 512
85
91
HA_KEY_ALG_UNDEF= 0, /* Not specified (old file) */
86
92
HA_KEY_ALG_BTREE= 1, /* B-tree, default one */
87
HA_KEY_ALG_HASH= 3 /* HASH keys (HEAP tables) */
93
HA_KEY_ALG_RTREE= 2, /* R-tree, for spatial searches */
94
HA_KEY_ALG_HASH= 3, /* HASH keys (HEAP tables) */
95
HA_KEY_ALG_FULLTEXT= 4 /* FULLTEXT (MyISAM tables) */
90
98
/* Index and table build methods */
92
enum ha_build_method {
100
enum ha_build_method {
98
106
/* The following is parameter to ha_extra() */
135
143
HA_EXTRA_CHANGE_KEY_TO_UNIQUE,
136
144
HA_EXTRA_CHANGE_KEY_TO_DUP,
138
When using HA_EXTRA_KEYREAD, overwrite only key member fields and keep
146
When using HA_EXTRA_KEYREAD, overwrite only key member fields and keep
139
147
other fields intact. When this is off (by default) InnoDB will use memcpy
140
148
to overwrite entire row.
142
150
HA_EXTRA_KEYREAD_PRESERVE_FIELDS,
144
153
Ignore if the a tuple is not found, continue processing the
145
154
transaction and ignore that 'row'. Needed for idempotency
150
159
HA_EXTRA_IGNORE_NO_KEY,
151
160
HA_EXTRA_NO_IGNORE_NO_KEY,
162
Mark the table as a log table. For some handlers (e.g. CSV) this results
163
in a special locking for the table.
165
HA_EXTRA_MARK_AS_LOG_TABLE,
153
167
Informs handler that write_row() which tries to insert new row into the
154
168
table and encounters some already existing row with same primary/unique
155
169
key can replace old row with new row instead of reporting error (basically
160
174
HA_EXTRA_WRITE_CANNOT_REPLACE,
162
176
Inform handler that delete_row()/update_row() cannot batch deletes/updates
163
and should perform them immediately. This may be needed when table has
177
and should perform them immediately. This may be needed when table has
164
178
AFTER DELETE/UPDATE triggers which access to subject table.
165
179
These flags are reset by the handler::extra(HA_EXTRA_RESET) call.
189
206
HA_KEYTYPE_END=0,
190
207
HA_KEYTYPE_TEXT=1, /* Key is sorted as letters */
191
208
HA_KEYTYPE_BINARY=2, /* Key is sorted as unsigned chars */
209
HA_KEYTYPE_SHORT_INT=3,
192
210
HA_KEYTYPE_LONG_INT=4,
193
212
HA_KEYTYPE_DOUBLE=6,
213
HA_KEYTYPE_NUM=7, /* Not packed num with pre-space */
214
HA_KEYTYPE_USHORT_INT=8,
194
215
HA_KEYTYPE_ULONG_INT=9,
195
216
HA_KEYTYPE_LONGLONG=10,
196
217
HA_KEYTYPE_ULONGLONG=11,
219
HA_KEYTYPE_UINT24=13,
197
221
/* Varchar (0-255 bytes) with length packed with 1 byte */
198
222
HA_KEYTYPE_VARTEXT1=15, /* Key is sorted as letters */
199
223
HA_KEYTYPE_VARBINARY1=16, /* Key is sorted as unsigned chars */
200
224
/* Varchar (0-65535 bytes) with length packed with 2 bytes */
201
225
HA_KEYTYPE_VARTEXT2=17, /* Key is sorted as letters */
202
HA_KEYTYPE_VARBINARY2=18 /* Key is sorted as unsigned chars */
226
HA_KEYTYPE_VARBINARY2=18, /* Key is sorted as unsigned chars */
230
#define HA_MAX_KEYTYPE 31 /* Must be log2-1 */
205
232
/* These flags kan be OR:ed to key-flag */
207
234
#define HA_NOSAME 1 /* Set if not dupplicated records */
208
235
#define HA_PACK_KEY 2 /* Pack string key to previous key */
209
236
#define HA_AUTO_KEY 16
210
237
#define HA_BINARY_PACK_KEY 32 /* Packing of all keys to prev key */
238
#define HA_FULLTEXT 128 /* For full-text search */
211
239
#define HA_UNIQUE_CHECK 256 /* Check the key for uniqueness */
240
#define HA_SPATIAL 1024 /* For spatial search */
212
241
#define HA_NULL_ARE_EQUAL 2048 /* NULL in key are cmp as equal */
213
242
#define HA_GENERATED_KEY 8192 /* Automaticly generated key */
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_FULLTEXT | HA_UNIQUE_CHECK | \
247
HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
215
249
#define HA_KEY_HAS_PART_KEY_SEG 65536 /* Key contains partial segments */
217
251
/* Automatic bits in key-flag */
220
254
#define HA_VAR_LENGTH_KEY 8
221
255
#define HA_NULL_PART_KEY 64
222
256
#define HA_USES_COMMENT 4096
223
#define HA_USES_BLOCK_SIZE ((uint32_t) 32768)
257
#define HA_USES_PARSER 16384 /* Fulltext index uses [pre]parser */
258
#define HA_USES_BLOCK_SIZE ((uint) 32768)
224
259
#define HA_SORT_ALLOWS_SAME 512 /* Intern bit when sorting records */
226
261
/* These flags can be added to key-seg-flag */
244
279
#define HA_OPTION_PACK_RECORD 1
245
280
#define HA_OPTION_PACK_KEYS 2
246
281
#define HA_OPTION_COMPRESS_RECORD 4
282
#define HA_OPTION_LONG_BLOB_PTR 8 /* new ISAM format */
247
283
#define HA_OPTION_TMP_TABLE 16
284
#define HA_OPTION_CHECKSUM 32
285
#define HA_OPTION_DELAY_KEY_WRITE 64
248
286
#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 */
287
#define HA_OPTION_CREATE_FROM_ENGINE 256
288
#define HA_OPTION_RELIES_ON_SQL_LAYER 512
289
#define HA_OPTION_NULL_FIELDS 1024
290
#define HA_OPTION_PAGE_CHECKSUM 2048
291
#define HA_OPTION_TEMP_COMPRESS_RECORD ((uint) 16384) /* set by isamchk */
292
#define HA_OPTION_READ_ONLY_DATA ((uint) 32768) /* Set by isamchk */
252
294
/* Bits in flag to create() */
254
296
#define HA_DONT_TOUCH_DATA 1 /* Don't empty datafile (isamchk) */
255
297
#define HA_PACK_RECORD 2 /* Request packed record format */
256
298
#define HA_CREATE_TMP_TABLE 4
299
#define HA_CREATE_CHECKSUM 8
257
300
#define HA_CREATE_KEEP_FILES 16 /* don't overwrite .MYD and MYI */
301
#define HA_CREATE_PAGE_CHECKSUM 32
302
#define HA_CREATE_DELAY_KEY_WRITE 64
303
#define HA_CREATE_RELIES_ON_SQL_LAYER 128
260
306
The following flags (OR-ed) are passed to handler::info() method.
371
417
#define HA_ERR_TABLESPACE_EXIST 171
372
418
#define HA_ERR_CORRUPT_EVENT 172 /* The event was corrupt, leading to
373
419
illegal data being read */
374
#define HA_ERR_NEW_FILE 173 /* New file format */
375
#define HA_ERR_ROWS_EVENT_APPLY 174 /* The event could not be processed
420
#define HA_ERR_NEW_FILE 172 /* New file format */
421
#define HA_ERR_ROWS_EVENT_APPLY 173 /* The event could not be processed
376
422
no other hanlder error happened */
377
#define HA_ERR_INITIALIZATION 175 /* Error during initialization */
378
#define HA_ERR_FILE_TOO_SHORT 176 /* File too short */
379
#define HA_ERR_WRONG_CRC 177 /* Wrong CRC on page */
380
#define HA_ERR_LOCK_OR_ACTIVE_TRANSACTION 178
381
#define HA_ERR_NO_SUCH_TABLESPACE 179
382
#define HA_ERR_TABLESPACE_NOT_EMPTY 180
383
#define HA_ERR_LAST 180 /* Copy of last error nr */
423
#define HA_ERR_INITIALIZATION 174 /* Error during initialization */
424
#define HA_ERR_FILE_TOO_SHORT 175 /* File too short */
425
#define HA_ERR_WRONG_CRC 176 /* Wrong CRC on page */
426
#define HA_ERR_LOCK_OR_ACTIVE_TRANSACTION 177
427
#define HA_ERR_NO_SUCH_TABLESPACE 178
428
#define HA_ERR_TABLESPACE_NOT_EMPTY 179
429
#define HA_ERR_LAST 179 /* Copy of last error nr */
385
431
/* Number of different errors */
386
432
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
388
434
/* Other constants */
390
typedef unsigned long key_part_map;
436
#define HA_NAMELEN 64 /* Max length of saved filename */
437
#define NO_SUCH_KEY (~(uint)0) /* used as a key no. */
439
typedef ulong key_part_map;
391
440
#define HA_WHOLE_KEY (~(key_part_map)0)
393
442
/* Intern constants in databases */
424
475
#define HA_STATE_DELETED 8
425
476
#define HA_STATE_NEXT_FOUND 16 /* Next found record (record before) */
426
477
#define HA_STATE_PREV_FOUND 32 /* Prev found record (record after) */
478
#define HA_STATE_NO_KEY 64 /* Last read didn't find record */
427
479
#define HA_STATE_KEY_CHANGED 128
428
480
#define HA_STATE_WRITE_AT_END 256 /* set in _ps_find_writepos */
481
#define HA_STATE_BUFF_SAVED 512 /* If current keybuff is info->buff */
429
482
#define HA_STATE_ROW_CHANGED 1024 /* To invalide ROW cache */
430
483
#define HA_STATE_EXTEND_BLOCK 2048
431
484
#define HA_STATE_RNEXT_SAME 4096 /* rnext_same occupied lastkey2 */
456
509
/* X > key, i.e. not including the right endpoint */
457
510
#define NEAR_MAX 8
460
This flag means that index is a unique index, and the interval is
513
This flag means that index is a unique index, and the interval is
461
514
equivalent to "AND(keypart_i = const_i)", where all of const_i are not NULLs.
463
516
#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
519
This flag means that the interval is equivalent to
520
"AND(keypart_i = const_i)", where not all key parts may be used but all of
468
521
const_i are not NULLs.
470
523
#define EQ_RANGE 32
473
526
This flag has the same meaning as UNIQUE_RANGE, except that for at least
474
one keypart the condition is "keypart IS NULL".
527
one keypart the condition is "keypart IS NULL".
476
529
#define NULL_RANGE 64
531
#define GEOM_FLAG 128
533
/* Deprecated, currently used only by NDB at row retrieval */
534
#define SKIP_RANGE 256
536
typedef struct st_key_range
481
const unsigned char *key;
540
key_part_map keypart_map;
483
541
enum ha_rkey_function flag;
484
key_part_map keypart_map;
487
class KEY_MULTI_RANGE
544
typedef struct st_key_multi_range
490
546
key_range start_key;
491
547
key_range end_key;
492
548
char *ptr; /* Free to use by caller (ptr to row etc) */
493
uint32_t range_flag; /* key range flags see above */
549
uint range_flag; /* key range flags see above */
497
553
/* For number of records */
498
typedef uint64_t ha_rows;
499
inline static double rows2double(ha_rows rows)
501
return uint64_t2double(rows);
555
#define rows2double(A) ulonglong2double(A)
556
typedef my_off_t ha_rows;
558
#define rows2double(A) (double) (A)
559
typedef ulong ha_rows;
504
#define HA_POS_ERROR (~ (::drizzled::ha_rows) 0)
505
#define HA_OFFSET_ERROR (~ (::drizzled::internal::my_off_t) 0)
562
#define HA_POS_ERROR (~ (ha_rows) 0)
563
#define HA_OFFSET_ERROR (~ (my_off_t) 0)
507
565
#if SIZEOF_OFF_T == 4
508
#define MAX_FILE_SIZE INT32_MAX
566
#define MAX_FILE_SIZE INT_MAX32
510
#define MAX_FILE_SIZE INT64_MAX
568
#define MAX_FILE_SIZE LONGLONG_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 */
571
#define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2)
573
/* invalidator function reference for Query Cache */
574
typedef void (* invalidator_by_filename)(const char * filename);
576
#endif /* _my_base_h */