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, Inc.
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 <drizzled/definitions.h>
30
#ifndef DRIZZLED_BASE_H
31
#define DRIZZLED_BASE_H
21
#ifndef stdin /* Included first in handler */
23
#include <drizzled/global.h>
24
#include <mysys/my_dir.h> /* This includes types */
25
#include <mysys/my_sys.h>
26
#include <mystrings/m_string.h>
34
#include <mysys/my_list.h>
36
36
/* The following is bits in the flag parameter to ha_open() */
189
201
HA_KEYTYPE_END=0,
190
202
HA_KEYTYPE_TEXT=1, /* Key is sorted as letters */
191
203
HA_KEYTYPE_BINARY=2, /* Key is sorted as unsigned chars */
204
HA_KEYTYPE_SHORT_INT=3,
192
205
HA_KEYTYPE_LONG_INT=4,
193
207
HA_KEYTYPE_DOUBLE=6,
208
HA_KEYTYPE_NUM=7, /* Not packed num with pre-space */
209
HA_KEYTYPE_USHORT_INT=8,
194
210
HA_KEYTYPE_ULONG_INT=9,
195
211
HA_KEYTYPE_LONGLONG=10,
196
212
HA_KEYTYPE_ULONGLONG=11,
214
HA_KEYTYPE_UINT24=13,
197
216
/* Varchar (0-255 bytes) with length packed with 1 byte */
198
217
HA_KEYTYPE_VARTEXT1=15, /* Key is sorted as letters */
199
218
HA_KEYTYPE_VARBINARY1=16, /* Key is sorted as unsigned chars */
200
219
/* Varchar (0-65535 bytes) with length packed with 2 bytes */
201
220
HA_KEYTYPE_VARTEXT2=17, /* Key is sorted as letters */
202
HA_KEYTYPE_VARBINARY2=18 /* Key is sorted as unsigned chars */
221
HA_KEYTYPE_VARBINARY2=18, /* Key is sorted as unsigned chars */
225
#define HA_MAX_KEYTYPE 31 /* Must be log2-1 */
205
227
/* These flags kan be OR:ed to key-flag */
207
229
#define HA_NOSAME 1 /* Set if not dupplicated records */
208
230
#define HA_PACK_KEY 2 /* Pack string key to previous key */
209
231
#define HA_AUTO_KEY 16
210
232
#define HA_BINARY_PACK_KEY 32 /* Packing of all keys to prev key */
233
#define HA_FULLTEXT 128 /* For full-text search */
211
234
#define HA_UNIQUE_CHECK 256 /* Check the key for uniqueness */
235
#define HA_SPATIAL 1024 /* For spatial search */
212
236
#define HA_NULL_ARE_EQUAL 2048 /* NULL in key are cmp as equal */
213
237
#define HA_GENERATED_KEY 8192 /* Automaticly generated key */
239
/* The combination of the above can be used for key type comparison. */
240
#define HA_KEYFLAG_MASK (HA_NOSAME | HA_PACK_KEY | HA_AUTO_KEY | \
241
HA_BINARY_PACK_KEY | HA_FULLTEXT | HA_UNIQUE_CHECK | \
242
HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
215
244
#define HA_KEY_HAS_PART_KEY_SEG 65536 /* Key contains partial segments */
217
246
/* Automatic bits in key-flag */
244
274
#define HA_OPTION_PACK_RECORD 1
245
275
#define HA_OPTION_PACK_KEYS 2
246
276
#define HA_OPTION_COMPRESS_RECORD 4
277
#define HA_OPTION_LONG_BLOB_PTR 8 /* new ISAM format */
247
278
#define HA_OPTION_TMP_TABLE 16
279
#define HA_OPTION_CHECKSUM 32
280
#define HA_OPTION_DELAY_KEY_WRITE 64
248
281
#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 */
282
#define HA_OPTION_CREATE_FROM_ENGINE 256
283
#define HA_OPTION_RELIES_ON_SQL_LAYER 512
284
#define HA_OPTION_NULL_FIELDS 1024
285
#define HA_OPTION_PAGE_CHECKSUM 2048
286
#define HA_OPTION_TEMP_COMPRESS_RECORD ((uint) 16384) /* set by isamchk */
287
#define HA_OPTION_READ_ONLY_DATA ((uint) 32768) /* Set by isamchk */
252
289
/* Bits in flag to create() */
254
291
#define HA_DONT_TOUCH_DATA 1 /* Don't empty datafile (isamchk) */
255
292
#define HA_PACK_RECORD 2 /* Request packed record format */
256
293
#define HA_CREATE_TMP_TABLE 4
294
#define HA_CREATE_CHECKSUM 8
257
295
#define HA_CREATE_KEEP_FILES 16 /* don't overwrite .MYD and MYI */
296
#define HA_CREATE_PAGE_CHECKSUM 32
297
#define HA_CREATE_DELAY_KEY_WRITE 64
298
#define HA_CREATE_RELIES_ON_SQL_LAYER 128
260
301
The following flags (OR-ed) are passed to handler::info() method.
303
344
Errorcodes given by handler functions
305
optimizer::sum_query() assumes these codes are > 1
346
opt_sum_query() assumes these codes are > 1
306
347
Do not add error numbers before HA_ERR_FIRST.
307
348
If necessary to add lower numbers, change HA_ERR_FIRST accordingly.
309
350
#define HA_ERR_FIRST 120 /* Copy of first error nr.*/
311
/* Other constants */
313
typedef unsigned long key_part_map;
352
#define HA_ERR_KEY_NOT_FOUND 120 /* Didn't find key on read or update */
353
#define HA_ERR_FOUND_DUPP_KEY 121 /* Dupplicate key on write */
354
#define HA_ERR_INTERNAL_ERROR 122 /* Internal error */
355
#define HA_ERR_RECORD_CHANGED 123 /* Uppdate with is recoverable */
356
#define HA_ERR_WRONG_INDEX 124 /* Wrong index given to function */
357
#define HA_ERR_CRASHED 126 /* Indexfile is crashed */
358
#define HA_ERR_WRONG_IN_RECORD 127 /* Record-file is crashed */
359
#define HA_ERR_OUT_OF_MEM 128 /* Record-file is crashed */
360
#define HA_ERR_NOT_A_TABLE 130 /* not a MYI file - no signature */
361
#define HA_ERR_WRONG_COMMAND 131 /* Command not supported */
362
#define HA_ERR_OLD_FILE 132 /* old databasfile */
363
#define HA_ERR_NO_ACTIVE_RECORD 133 /* No record read in update() */
364
#define HA_ERR_RECORD_DELETED 134 /* A record is not there */
365
#define HA_ERR_RECORD_FILE_FULL 135 /* No more room in file */
366
#define HA_ERR_INDEX_FILE_FULL 136 /* No more room in file */
367
#define HA_ERR_END_OF_FILE 137 /* end in next/prev/first/last */
368
#define HA_ERR_UNSUPPORTED 138 /* unsupported extension used */
369
#define HA_ERR_TO_BIG_ROW 139 /* Too big row */
370
#define HA_WRONG_CREATE_OPTION 140 /* Wrong create option */
371
#define HA_ERR_FOUND_DUPP_UNIQUE 141 /* Dupplicate unique on write */
372
#define HA_ERR_UNKNOWN_CHARSET 142 /* Can't open charset */
373
#define HA_ERR_WRONG_MRG_TABLE_DEF 143 /* conflicting tables in MERGE */
374
#define HA_ERR_CRASHED_ON_REPAIR 144 /* Last (automatic?) repair failed */
375
#define HA_ERR_CRASHED_ON_USAGE 145 /* Table must be repaired */
376
#define HA_ERR_LOCK_WAIT_TIMEOUT 146
377
#define HA_ERR_LOCK_TABLE_FULL 147
378
#define HA_ERR_READ_ONLY_TRANSACTION 148 /* Updates not allowed */
379
#define HA_ERR_LOCK_DEADLOCK 149
380
#define HA_ERR_CANNOT_ADD_FOREIGN 150 /* Cannot add a foreign key constr. */
381
#define HA_ERR_NO_REFERENCED_ROW 151 /* Cannot add a child row */
382
#define HA_ERR_ROW_IS_REFERENCED 152 /* Cannot delete a parent row */
383
#define HA_ERR_NO_SAVEPOINT 153 /* No savepoint with that name */
384
#define HA_ERR_NON_UNIQUE_BLOCK_SIZE 154 /* Non unique key block size */
385
#define HA_ERR_NO_SUCH_TABLE 155 /* The table does not exist in engine */
386
#define HA_ERR_TABLE_EXIST 156 /* The table existed in storage engine */
387
#define HA_ERR_NO_CONNECTION 157 /* Could not connect to storage engine */
388
/* NULLs are not supported in spatial index */
389
#define HA_ERR_NULL_IN_SPATIAL 158
390
#define HA_ERR_TABLE_DEF_CHANGED 159 /* The table changed in storage engine */
391
/* There's no partition in table for given value */
392
#define HA_ERR_NO_PARTITION_FOUND 160
393
#define HA_ERR_RBR_LOGGING_FAILED 161 /* Row-based binlogging of row failed */
394
#define HA_ERR_DROP_INDEX_FK 162 /* Index needed in foreign key constr */
396
Upholding foreign key constraints would lead to a duplicate key error
399
#define HA_ERR_FOREIGN_DUPLICATE_KEY 163
400
/* The table changed in storage engine */
401
#define HA_ERR_TABLE_NEEDS_UPGRADE 164
402
#define HA_ERR_TABLE_READONLY 165 /* The table is not writable */
404
#define HA_ERR_AUTOINC_READ_FAILED 166 /* Failed to get next autoinc value */
405
#define HA_ERR_AUTOINC_ERANGE 167 /* Failed to set row autoinc value */
406
#define HA_ERR_GENERIC 168 /* Generic error */
407
/* row not actually updated: new values same as the old values */
408
#define HA_ERR_RECORD_IS_THE_SAME 169
409
/* It is not possible to log this statement */
410
#define HA_ERR_LOGGING_IMPOSSIBLE 170 /* It is not possible to log this
412
#define HA_ERR_TABLESPACE_EXIST 171
413
#define HA_ERR_CORRUPT_EVENT 172 /* The event was corrupt, leading to
414
illegal data being read */
415
#define HA_ERR_NEW_FILE 173 /* New file format */
416
#define HA_ERR_ROWS_EVENT_APPLY 174 /* The event could not be processed
417
no other hanlder error happened */
418
#define HA_ERR_INITIALIZATION 175 /* Error during initialization */
419
#define HA_ERR_FILE_TOO_SHORT 176 /* File too short */
420
#define HA_ERR_WRONG_CRC 177 /* Wrong CRC on page */
421
#define HA_ERR_LOCK_OR_ACTIVE_TRANSACTION 178
422
#define HA_ERR_NO_SUCH_TABLESPACE 179
423
#define HA_ERR_TABLESPACE_NOT_EMPTY 180
424
#define HA_ERR_LAST 180 /* Copy of last error nr */
426
/* Number of different errors */
427
#define HA_ERR_ERRORS (HA_ERR_LAST - HA_ERR_FIRST + 1)
429
/* Other constants */
431
#define HA_NAMELEN 64 /* Max length of saved filename */
432
#define NO_SUCH_KEY (~(uint)0) /* used as a key no. */
434
typedef ulong key_part_map;
314
435
#define HA_WHOLE_KEY (~(key_part_map)0)
316
437
/* Intern constants in databases */
379
504
/* X > key, i.e. not including the right endpoint */
380
505
#define NEAR_MAX 8
383
This flag means that index is a unique index, and the interval is
508
This flag means that index is a unique index, and the interval is
384
509
equivalent to "AND(keypart_i = const_i)", where all of const_i are not NULLs.
386
511
#define UNIQUE_RANGE 16
389
This flag means that the interval is equivalent to
390
"AND(keypart_i = const_i)", where not all key parts may be used but all of
514
This flag means that the interval is equivalent to
515
"AND(keypart_i = const_i)", where not all key parts may be used but all of
391
516
const_i are not NULLs.
393
518
#define EQ_RANGE 32
396
521
This flag has the same meaning as UNIQUE_RANGE, except that for at least
397
one keypart the condition is "keypart IS NULL".
522
one keypart the condition is "keypart IS NULL".
399
524
#define NULL_RANGE 64
526
#define GEOM_FLAG 128
528
/* Deprecated, currently used only by NDB at row retrieval */
529
#define SKIP_RANGE 256
531
typedef struct st_key_range
404
const unsigned char *key;
535
key_part_map keypart_map;
406
536
enum ha_rkey_function flag;
407
key_part_map keypart_map;
410
class KEY_MULTI_RANGE
539
typedef struct st_key_multi_range
413
541
key_range start_key;
414
542
key_range end_key;
415
543
char *ptr; /* Free to use by caller (ptr to row etc) */
416
uint32_t range_flag; /* key range flags see above */
544
uint range_flag; /* key range flags see above */
420
548
/* For number of records */
421
typedef uint64_t ha_rows;
550
#define rows2double(A) uint64_t2double(A)
551
typedef my_off_t ha_rows;
553
#define rows2double(A) (double) (A)
554
typedef ulong ha_rows;
423
#define HA_POS_ERROR (~ (::drizzled::ha_rows) 0)
424
#define HA_OFFSET_ERROR (~ (::drizzled::internal::my_off_t) 0)
557
#define HA_POS_ERROR (~ (ha_rows) 0)
558
#define HA_OFFSET_ERROR (~ (my_off_t) 0)
426
560
#if SIZEOF_OFF_T == 4
427
561
#define MAX_FILE_SIZE INT32_MAX