~drizzle-trunk/drizzle/development

1 by brian
clean slate
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 */
15
16
/* This file includes constants used with all databases */
17
18
#ifndef _my_base_h
19
#define _my_base_h
20
21
#ifndef stdin				/* Included first in handler */
22
#define CHSIZE_USED
212.5.39 by Monty Taylor
Phew. Moved my_base and my_global.
23
#include <drizzled/global.h>
212.5.38 by Monty Taylor
Moved my_dir (and removed references to a lot of places)
24
#include <mysys/my_dir.h>		/* This includes types */
212.5.13 by Monty Taylor
Moved my_sys/my_pthread/my_nosys and mysys_err to mysys.
25
#include <mysys/my_sys.h>
212.5.18 by Monty Taylor
Moved m_ctype, m_string and my_bitmap. Removed t_ctype.
26
#include <mystrings/m_string.h>
1 by brian
clean slate
27
#include <errno.h>
28
29
#ifndef EOVERFLOW
30
#define EOVERFLOW 84
31
#endif
32
33
#endif	/* stdin */
212.5.28 by Monty Taylor
Moved my_bit and my_list
34
#include <mysys/my_list.h>
1 by brian
clean slate
35
36
/* The following is bits in the flag parameter to ha_open() */
37
38
#define HA_OPEN_ABORT_IF_LOCKED		0	/* default */
39
#define HA_OPEN_WAIT_IF_LOCKED		1
40
#define HA_OPEN_IGNORE_IF_LOCKED	2
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) */
48
/* Internal temp table, used for temporary results */
49
#define HA_OPEN_INTERNAL_TABLE          512
50
51
/* The following is parameter to ha_rkey() how to use key */
52
53
/*
54
  We define a complete-field prefix of a key value as a prefix where
55
  the last included field in the prefix contains the full field, not
56
  just some bytes from the start of the field. A partial-field prefix
57
  is allowed to contain only a few first bytes from the last included
58
  field.
59
60
  Below HA_READ_KEY_EXACT, ..., HA_READ_BEFORE_KEY can take a
61
  complete-field prefix of a key value as the search
62
  key. HA_READ_PREFIX and HA_READ_PREFIX_LAST could also take a
63
  partial-field prefix, but currently (4.0.10) they are only used with
64
  complete-field prefixes. MySQL uses a padding trick to implement
65
  LIKE 'abc%' queries.
66
67
  NOTE that in InnoDB HA_READ_PREFIX_LAST will NOT work with a
68
  partial-field prefix because InnoDB currently strips spaces from the
69
  end of varchar fields!
70
*/
71
72
enum ha_rkey_function {
73
  HA_READ_KEY_EXACT,              /* Find first record else error */
74
  HA_READ_KEY_OR_NEXT,            /* Record or next record */
75
  HA_READ_KEY_OR_PREV,            /* Record or previous */
76
  HA_READ_AFTER_KEY,              /* Find next rec. after key-record */
77
  HA_READ_BEFORE_KEY,             /* Find next rec. before key-record */
78
  HA_READ_PREFIX,                 /* Key which as same prefix */
79
  HA_READ_PREFIX_LAST,            /* Last key with the same prefix */
80
  HA_READ_PREFIX_LAST_OR_PREV,    /* Last or prev key with the same prefix */
81
  HA_READ_MBR_CONTAIN,
82
  HA_READ_MBR_INTERSECT,
83
  HA_READ_MBR_WITHIN,
84
  HA_READ_MBR_DISJOINT,
85
  HA_READ_MBR_EQUAL
86
};
87
88
	/* Key algorithm types */
89
90
enum ha_key_alg {
91
  HA_KEY_ALG_UNDEF=	0,		/* Not specified (old file) */
92
  HA_KEY_ALG_BTREE=	1,		/* B-tree, default one          */
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) */
96
};
97
98
	/* Index and table build methods */
99
100
enum ha_build_method { 
101
  HA_BUILD_DEFAULT, 
102
  HA_BUILD_ONLINE,
103
  HA_BUILD_OFFLINE 
104
};
105
106
	/* The following is parameter to ha_extra() */
107
108
enum ha_extra_function {
109
  HA_EXTRA_NORMAL=0,			/* Optimize for space (def) */
110
  HA_EXTRA_QUICK=1,			/* Optimize for speed */
111
  HA_EXTRA_NOT_USED=2,
112
  HA_EXTRA_CACHE=3,			/* Cache record in HA_rrnd() */
113
  HA_EXTRA_NO_CACHE=4,			/* End caching of records (def) */
114
  HA_EXTRA_NO_READCHECK=5,		/* No readcheck on update */
115
  HA_EXTRA_READCHECK=6,			/* Use readcheck (def) */
116
  HA_EXTRA_KEYREAD=7,			/* Read only key to database */
117
  HA_EXTRA_NO_KEYREAD=8,		/* Normal read of records (def) */
118
  HA_EXTRA_NO_USER_CHANGE=9,		/* No user is allowed to write */
119
  HA_EXTRA_KEY_CACHE=10,
120
  HA_EXTRA_NO_KEY_CACHE=11,
121
  HA_EXTRA_WAIT_LOCK=12,		/* Wait until file is avalably (def) */
122
  HA_EXTRA_NO_WAIT_LOCK=13,		/* If file is locked, return quickly */
123
  HA_EXTRA_WRITE_CACHE=14,		/* Use write cache in ha_write() */
124
  HA_EXTRA_FLUSH_CACHE=15,		/* flush write_record_cache */
125
  HA_EXTRA_NO_KEYS=16,			/* Remove all update of keys */
126
  HA_EXTRA_KEYREAD_CHANGE_POS=17,	/* Keyread, but change pos */
127
					/* xxxxchk -r must be used */
128
  HA_EXTRA_REMEMBER_POS=18,		/* Remember pos for next/prev */
129
  HA_EXTRA_RESTORE_POS=19,
130
  HA_EXTRA_REINIT_CACHE=20,		/* init cache from current record */
131
  HA_EXTRA_FORCE_REOPEN=21,		/* Datafile have changed on disk */
132
  HA_EXTRA_FLUSH,			/* Flush tables to disk */
133
  HA_EXTRA_NO_ROWS,			/* Don't write rows */
134
  HA_EXTRA_RESET_STATE,			/* Reset positions */
135
  HA_EXTRA_IGNORE_DUP_KEY,		/* Dup keys don't rollback everything*/
136
  HA_EXTRA_NO_IGNORE_DUP_KEY,
137
  HA_EXTRA_PREPARE_FOR_DROP,
138
  HA_EXTRA_PREPARE_FOR_UPDATE,		/* Remove read cache if problems */
139
  HA_EXTRA_PRELOAD_BUFFER_SIZE,         /* Set buffer size for preloading */
140
  /*
141
    On-the-fly switching between unique and non-unique key inserting.
142
  */
143
  HA_EXTRA_CHANGE_KEY_TO_UNIQUE,
144
  HA_EXTRA_CHANGE_KEY_TO_DUP,
145
  /*
146
    When using HA_EXTRA_KEYREAD, overwrite only key member fields and keep 
147
    other fields intact. When this is off (by default) InnoDB will use memcpy
148
    to overwrite entire row.
149
  */
150
  HA_EXTRA_KEYREAD_PRESERVE_FIELDS,
151
  HA_EXTRA_MMAP,
152
  /*
153
    Ignore if the a tuple is not found, continue processing the
154
    transaction and ignore that 'row'.  Needed for idempotency
155
    handling on the slave
156
157
    Currently only used by NDB storage engine. Partition handler ignores flag.
158
  */
159
  HA_EXTRA_IGNORE_NO_KEY,
160
  HA_EXTRA_NO_IGNORE_NO_KEY,
161
  /*
162
    Informs handler that write_row() which tries to insert new row into the
163
    table and encounters some already existing row with same primary/unique
164
    key can replace old row with new row instead of reporting error (basically
165
    it informs handler that we do REPLACE instead of simple INSERT).
166
    Off by default.
167
  */
168
  HA_EXTRA_WRITE_CAN_REPLACE,
169
  HA_EXTRA_WRITE_CANNOT_REPLACE,
170
  /*
171
    Inform handler that delete_row()/update_row() cannot batch deletes/updates
172
    and should perform them immediately. This may be needed when table has 
173
    AFTER DELETE/UPDATE triggers which access to subject table.
174
    These flags are reset by the handler::extra(HA_EXTRA_RESET) call.
175
  */
176
  HA_EXTRA_DELETE_CANNOT_BATCH,
177
  HA_EXTRA_UPDATE_CANNOT_BATCH,
178
  /*
179
    Inform handler that an "INSERT...ON DUPLICATE KEY UPDATE" will be
180
    executed. This condition is unset by HA_EXTRA_NO_IGNORE_DUP_KEY.
181
  */
182
  HA_EXTRA_INSERT_WITH_UPDATE,
183
  /* Inform handler that we will do a rename */
102 by Brian Aker
Final cleanup on enum for MEMORY/DISK
184
  HA_EXTRA_PREPARE_FOR_RENAME
1 by brian
clean slate
185
};
186
187
/* Compatible option, to be deleted in 6.0 */
188
#define HA_EXTRA_PREPARE_FOR_DELETE HA_EXTRA_PREPARE_FOR_DROP
189
190
	/* The following is parameter to ha_panic() */
191
192
enum ha_panic_function {
193
  HA_PANIC_CLOSE,			/* Close all databases */
194
  HA_PANIC_WRITE,			/* Unlock and write status */
195
  HA_PANIC_READ				/* Lock and read keyinfo */
196
};
197
198
	/* The following is parameter to ha_create(); keytypes */
199
200
enum ha_base_keytype {
201
  HA_KEYTYPE_END=0,
202
  HA_KEYTYPE_TEXT=1,			/* Key is sorted as letters */
203
  HA_KEYTYPE_BINARY=2,			/* Key is sorted as unsigned chars */
204
  HA_KEYTYPE_SHORT_INT=3,
205
  HA_KEYTYPE_LONG_INT=4,
206
  HA_KEYTYPE_FLOAT=5,
207
  HA_KEYTYPE_DOUBLE=6,
208
  HA_KEYTYPE_NUM=7,			/* Not packed num with pre-space */
209
  HA_KEYTYPE_USHORT_INT=8,
210
  HA_KEYTYPE_ULONG_INT=9,
211
  HA_KEYTYPE_LONGLONG=10,
212
  HA_KEYTYPE_ULONGLONG=11,
213
  HA_KEYTYPE_INT24=12,
214
  HA_KEYTYPE_UINT24=13,
215
  HA_KEYTYPE_INT8=14,
216
  /* Varchar (0-255 bytes) with length packed with 1 byte */
217
  HA_KEYTYPE_VARTEXT1=15,               /* Key is sorted as letters */
218
  HA_KEYTYPE_VARBINARY1=16,             /* Key is sorted as unsigned chars */
219
  /* Varchar (0-65535 bytes) with length packed with 2 bytes */
220
  HA_KEYTYPE_VARTEXT2=17,		/* Key is sorted as letters */
221
  HA_KEYTYPE_VARBINARY2=18,		/* Key is sorted as unsigned chars */
222
  HA_KEYTYPE_BIT=19
223
};
224
225
#define HA_MAX_KEYTYPE	31		/* Must be log2-1 */
226
227
	/* These flags kan be OR:ed to key-flag */
228
229
#define HA_NOSAME		 1	/* Set if not dupplicated records */
230
#define HA_PACK_KEY		 2	/* Pack string key to previous key */
231
#define HA_AUTO_KEY		 16
232
#define HA_BINARY_PACK_KEY	 32	/* Packing of all keys to prev key */
233
#define HA_UNIQUE_CHECK		256	/* Check the key for uniqueness */
234
#define HA_NULL_ARE_EQUAL	2048	/* NULL in key are cmp as equal */
235
#define HA_GENERATED_KEY	8192	/* Automaticly generated key */
236
237
        /* The combination of the above can be used for key type comparison. */
238
#define HA_KEYFLAG_MASK (HA_NOSAME | HA_PACK_KEY | HA_AUTO_KEY | \
248 by Brian Aker
Random cleanup in base.h
239
                         HA_BINARY_PACK_KEY | HA_UNIQUE_CHECK | \
240
                         HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
1 by brian
clean slate
241
242
#define HA_KEY_HAS_PART_KEY_SEG 65536   /* Key contains partial segments */
243
244
	/* Automatic bits in key-flag */
245
246
#define HA_SPACE_PACK_USED	 4	/* Test for if SPACE_PACK used */
247
#define HA_VAR_LENGTH_KEY	 8
248
#define HA_NULL_PART_KEY	 64
249
#define HA_USES_COMMENT          4096
250
#define HA_USES_BLOCK_SIZE	 ((uint) 32768)
251
#define HA_SORT_ALLOWS_SAME      512    /* Intern bit when sorting records */
252
253
	/* These flags can be added to key-seg-flag */
254
255
#define HA_SPACE_PACK		 1	/* Pack space in key-seg */
256
#define HA_PART_KEY_SEG		 4	/* Used by MySQL for part-key-cols */
257
#define HA_VAR_LENGTH_PART	 8
258
#define HA_NULL_PART		 16
259
#define HA_BLOB_PART		 32
260
#define HA_SWAP_KEY		 64
261
#define HA_REVERSE_SORT		 128	/* Sort key in reverse order */
262
#define HA_NO_SORT               256 /* do not bother sorting on this keyseg */
263
/*
264
  End space in unique/varchar are considered equal. (Like 'a' and 'a ')
265
  Only needed for internal temporary tables.
266
*/
267
#define HA_END_SPACE_ARE_EQUAL	 512
268
#define HA_BIT_PART		1024
269
270
	/* optionbits for database */
271
#define HA_OPTION_PACK_RECORD		1
272
#define HA_OPTION_PACK_KEYS		2
273
#define HA_OPTION_COMPRESS_RECORD	4
274
#define HA_OPTION_LONG_BLOB_PTR		8 /* new ISAM format */
275
#define HA_OPTION_TMP_TABLE		16
276
#define HA_OPTION_CHECKSUM		32
277
#define HA_OPTION_DELAY_KEY_WRITE	64
278
#define HA_OPTION_NO_PACK_KEYS		128  /* Reserved for MySQL */
279
#define HA_OPTION_CREATE_FROM_ENGINE    256
280
#define HA_OPTION_RELIES_ON_SQL_LAYER   512
281
#define HA_OPTION_NULL_FIELDS		1024
282
#define HA_OPTION_PAGE_CHECKSUM		2048
283
#define HA_OPTION_TEMP_COMPRESS_RECORD	((uint) 16384)	/* set by isamchk */
284
#define HA_OPTION_READ_ONLY_DATA	((uint) 32768)	/* Set by isamchk */
285
286
	/* Bits in flag to create() */
287
288
#define HA_DONT_TOUCH_DATA	1	/* Don't empty datafile (isamchk) */
289
#define HA_PACK_RECORD		2	/* Request packed record format */
290
#define HA_CREATE_TMP_TABLE	4
291
#define HA_CREATE_CHECKSUM	8
292
#define HA_CREATE_KEEP_FILES	16      /* don't overwrite .MYD and MYI */
293
#define HA_CREATE_PAGE_CHECKSUM	32
294
#define HA_CREATE_DELAY_KEY_WRITE 64
295
#define HA_CREATE_RELIES_ON_SQL_LAYER 128
296
297
/*
298
  The following flags (OR-ed) are passed to handler::info() method.
299
  The method copies misc handler information out of the storage engine
300
  to data structures accessible from MySQL
301
302
  Same flags are also passed down to mi_status, myrg_status, etc.
303
*/
304
305
/* this one is not used */
306
#define HA_STATUS_POS            1
307
/*
308
  assuming the table keeps shared actual copy of the 'info' and
309
  local, possibly outdated copy, the following flag means that
310
  it should not try to get the actual data (locking the shared structure)
311
  slightly outdated version will suffice
312
*/
313
#define HA_STATUS_NO_LOCK        2
314
/* update the time of the last modification (in handler::update_time) */
315
#define HA_STATUS_TIME           4
316
/*
317
  update the 'constant' part of the info:
318
  handler::max_data_file_length, max_index_file_length, create_time
319
  sortkey, ref_length, block_size, data_file_name, index_file_name.
320
  handler::table->s->keys_in_use, keys_for_keyread, rec_per_key
321
*/
322
#define HA_STATUS_CONST          8
323
/*
324
  update the 'variable' part of the info:
325
  handler::records, deleted, data_file_length, index_file_length,
326
  delete_length, check_time, mean_rec_length
327
*/
328
#define HA_STATUS_VARIABLE      16
329
/*
330
  get the information about the key that caused last duplicate value error
331
  update handler::errkey and handler::dupp_ref
332
  see handler::get_dup_key()
333
*/
334
#define HA_STATUS_ERRKEY        32
335
/*
336
  update handler::auto_increment_value
337
*/
338
#define HA_STATUS_AUTO          64
339
340
/*
341
  Errorcodes given by handler functions
342
343
  opt_sum_query() assumes these codes are > 1
344
  Do not add error numbers before HA_ERR_FIRST.
345
  If necessary to add lower numbers, change HA_ERR_FIRST accordingly.
346
*/
347
#define HA_ERR_FIRST            120     /* Copy of first error nr.*/
348
349
#define HA_ERR_KEY_NOT_FOUND	120	/* Didn't find key on read or update */
350
#define HA_ERR_FOUND_DUPP_KEY	121	/* Dupplicate key on write */
351
#define HA_ERR_INTERNAL_ERROR   122     /* Internal error */
352
#define HA_ERR_RECORD_CHANGED	123	/* Uppdate with is recoverable */
353
#define HA_ERR_WRONG_INDEX	124	/* Wrong index given to function */
354
#define HA_ERR_CRASHED		126	/* Indexfile is crashed */
355
#define HA_ERR_WRONG_IN_RECORD	127	/* Record-file is crashed */
356
#define HA_ERR_OUT_OF_MEM	128	/* Record-file is crashed */
357
#define HA_ERR_NOT_A_TABLE      130     /* not a MYI file - no signature */
358
#define HA_ERR_WRONG_COMMAND	131	/* Command not supported */
359
#define HA_ERR_OLD_FILE		132	/* old databasfile */
360
#define HA_ERR_NO_ACTIVE_RECORD 133	/* No record read in update() */
361
#define HA_ERR_RECORD_DELETED	134	/* A record is not there */
362
#define HA_ERR_RECORD_FILE_FULL 135	/* No more room in file */
363
#define HA_ERR_INDEX_FILE_FULL	136	/* No more room in file */
364
#define HA_ERR_END_OF_FILE	137	/* end in next/prev/first/last */
365
#define HA_ERR_UNSUPPORTED	138	/* unsupported extension used */
366
#define HA_ERR_TO_BIG_ROW	139	/* Too big row */
367
#define HA_WRONG_CREATE_OPTION	140	/* Wrong create option */
368
#define HA_ERR_FOUND_DUPP_UNIQUE 141	/* Dupplicate unique on write */
369
#define HA_ERR_UNKNOWN_CHARSET	 142	/* Can't open charset */
370
#define HA_ERR_WRONG_MRG_TABLE_DEF 143  /* conflicting tables in MERGE */
371
#define HA_ERR_CRASHED_ON_REPAIR 144	/* Last (automatic?) repair failed */
372
#define HA_ERR_CRASHED_ON_USAGE  145	/* Table must be repaired */
373
#define HA_ERR_LOCK_WAIT_TIMEOUT 146
374
#define HA_ERR_LOCK_TABLE_FULL   147
375
#define HA_ERR_READ_ONLY_TRANSACTION 148 /* Updates not allowed */
376
#define HA_ERR_LOCK_DEADLOCK	 149
377
#define HA_ERR_CANNOT_ADD_FOREIGN 150    /* Cannot add a foreign key constr. */
378
#define HA_ERR_NO_REFERENCED_ROW 151     /* Cannot add a child row */
379
#define HA_ERR_ROW_IS_REFERENCED 152     /* Cannot delete a parent row */
380
#define HA_ERR_NO_SAVEPOINT	 153     /* No savepoint with that name */
381
#define HA_ERR_NON_UNIQUE_BLOCK_SIZE 154 /* Non unique key block size */
382
#define HA_ERR_NO_SUCH_TABLE     155  /* The table does not exist in engine */
383
#define HA_ERR_TABLE_EXIST       156  /* The table existed in storage engine */
384
#define HA_ERR_NO_CONNECTION     157  /* Could not connect to storage engine */
385
/* NULLs are not supported in spatial index */
386
#define HA_ERR_NULL_IN_SPATIAL   158
387
#define HA_ERR_TABLE_DEF_CHANGED 159  /* The table changed in storage engine */
388
/* There's no partition in table for given value */
389
#define HA_ERR_NO_PARTITION_FOUND 160
390
#define HA_ERR_RBR_LOGGING_FAILED 161  /* Row-based binlogging of row failed */
391
#define HA_ERR_DROP_INDEX_FK      162  /* Index needed in foreign key constr */
392
/*
393
  Upholding foreign key constraints would lead to a duplicate key error
394
  in some other table.
395
*/
396
#define HA_ERR_FOREIGN_DUPLICATE_KEY 163
397
/* The table changed in storage engine */
398
#define HA_ERR_TABLE_NEEDS_UPGRADE 164
399
#define HA_ERR_TABLE_READONLY      165   /* The table is not writable */
400
401
#define HA_ERR_AUTOINC_READ_FAILED 166   /* Failed to get next autoinc value */
402
#define HA_ERR_AUTOINC_ERANGE    167     /* Failed to set row autoinc value */
403
#define HA_ERR_GENERIC           168     /* Generic error */
404
/* row not actually updated: new values same as the old values */
405
#define HA_ERR_RECORD_IS_THE_SAME 169
406
/* It is not possible to log this statement */
407
#define HA_ERR_LOGGING_IMPOSSIBLE 170    /* It is not possible to log this
408
                                            statement */
409
#define HA_ERR_TABLESPACE_EXIST   171
410
#define HA_ERR_CORRUPT_EVENT      172    /* The event was corrupt, leading to
411
                                            illegal data being read */
202.3.6 by Monty Taylor
First pass at gettexizing the error messages.
412
#define HA_ERR_NEW_FILE	          173	 /* New file format */
413
#define HA_ERR_ROWS_EVENT_APPLY   174    /* The event could not be processed
1 by brian
clean slate
414
                                            no other hanlder error happened */
202.3.6 by Monty Taylor
First pass at gettexizing the error messages.
415
#define HA_ERR_INITIALIZATION     175    /* Error during initialization */
416
#define HA_ERR_FILE_TOO_SHORT	  176	 /* File too short */
417
#define HA_ERR_WRONG_CRC	  177	 /* Wrong CRC on page */
418
#define HA_ERR_LOCK_OR_ACTIVE_TRANSACTION 178
419
#define HA_ERR_NO_SUCH_TABLESPACE 179
420
#define HA_ERR_TABLESPACE_NOT_EMPTY 180
421
#define HA_ERR_LAST               180    /* Copy of last error nr */
1 by brian
clean slate
422
423
/* Number of different errors */
424
#define HA_ERR_ERRORS            (HA_ERR_LAST - HA_ERR_FIRST + 1)
425
426
	/* Other constants */
427
428
#define HA_NAMELEN 64			/* Max length of saved filename */
429
#define NO_SUCH_KEY (~(uint)0)          /* used as a key no. */
430
431
typedef ulong key_part_map;
432
#define HA_WHOLE_KEY  (~(key_part_map)0)
433
434
	/* Intern constants in databases */
435
436
	/* bits in _search */
437
#define SEARCH_FIND	1
438
#define SEARCH_NO_FIND	2
439
#define SEARCH_SAME	4
440
#define SEARCH_BIGGER	8
441
#define SEARCH_SMALLER	16
442
#define SEARCH_SAVE_BUFF	32
443
#define SEARCH_UPDATE	64
444
#define SEARCH_PREFIX	128
445
#define SEARCH_LAST	256
446
#define MBR_CONTAIN     512
447
#define MBR_INTERSECT   1024
448
#define MBR_WITHIN      2048
449
#define MBR_DISJOINT    4096
450
#define MBR_EQUAL       8192
451
#define MBR_DATA        16384
452
#define SEARCH_NULL_ARE_EQUAL 32768	/* NULL in keys are equal */
453
#define SEARCH_NULL_ARE_NOT_EQUAL 65536	/* NULL in keys are not equal */
454
455
	/* bits in opt_flag */
456
#define QUICK_USED	1
457
#define READ_CACHE_USED	2
458
#define READ_CHECK_USED 4
459
#define KEY_READ_USED	8
460
#define WRITE_CACHE_USED 16
461
#define OPT_NO_ROWS	32
462
463
	/* bits in update */
464
#define HA_STATE_CHANGED	1	/* Database has changed */
465
#define HA_STATE_AKTIV		2	/* Has a current record */
466
#define HA_STATE_WRITTEN	4	/* Record is written */
467
#define HA_STATE_DELETED	8
468
#define HA_STATE_NEXT_FOUND	16	/* Next found record (record before) */
469
#define HA_STATE_PREV_FOUND	32	/* Prev found record (record after) */
470
#define HA_STATE_NO_KEY		64	/* Last read didn't find record */
471
#define HA_STATE_KEY_CHANGED	128
472
#define HA_STATE_WRITE_AT_END	256	/* set in _ps_find_writepos */
473
#define HA_STATE_BUFF_SAVED	512	/* If current keybuff is info->buff */
474
#define HA_STATE_ROW_CHANGED	1024	/* To invalide ROW cache */
475
#define HA_STATE_EXTEND_BLOCK	2048
476
#define HA_STATE_RNEXT_SAME	4096	/* rnext_same occupied lastkey2 */
477
478
/* myisampack expects no more than 32 field types. */
479
enum en_fieldtype {
480
  FIELD_LAST=-1,FIELD_NORMAL,FIELD_SKIP_ENDSPACE,FIELD_SKIP_PRESPACE,
481
  FIELD_SKIP_ZERO,FIELD_BLOB,FIELD_CONSTANT,FIELD_INTERVALL,FIELD_ZERO,
482
  FIELD_VARCHAR,FIELD_CHECK,
483
  FIELD_enum_val_count
484
};
485
486
enum data_file_type {
487
  STATIC_RECORD, DYNAMIC_RECORD, COMPRESSED_RECORD, BLOCK_RECORD
488
};
489
490
/* For key ranges */
491
492
/* from -inf */
493
#define NO_MIN_RANGE	1
494
495
/* to +inf */
496
#define NO_MAX_RANGE	2
497
498
/*  X < key, i.e. not including the left endpoint */
499
#define NEAR_MIN	4
500
501
/* X > key, i.e. not including the right endpoint */
502
#define NEAR_MAX	8
503
504
/* 
505
  This flag means that index is a unique index, and the interval is 
506
  equivalent to "AND(keypart_i = const_i)", where all of const_i are not NULLs.
507
*/
508
#define UNIQUE_RANGE	16
509
510
/* 
511
  This flag means that the interval is equivalent to 
512
  "AND(keypart_i = const_i)", where not all key parts may be used but all of 
513
  const_i are not NULLs.
514
*/
515
#define EQ_RANGE	32
516
517
/*
518
  This flag has the same meaning as UNIQUE_RANGE, except that for at least
519
  one keypart the condition is "keypart IS NULL". 
520
*/
521
#define NULL_RANGE	64
522
523
typedef struct st_key_range
524
{
525
  const uchar *key;
526
  uint length;
527
  key_part_map keypart_map;
528
  enum ha_rkey_function flag;
529
} key_range;
530
531
typedef struct st_key_multi_range
532
{
533
  key_range start_key;
534
  key_range end_key;
535
  char  *ptr;                 /* Free to use by caller (ptr to row etc) */
536
  uint  range_flag;           /* key range flags see above */
537
} KEY_MULTI_RANGE;
538
539
540
/* For number of records */
248 by Brian Aker
Random cleanup in base.h
541
typedef uint64_t	ha_rows;
151 by Brian Aker
Ulonglong to uint64_t
542
#define rows2double(A)	uint64_t2double(A)
1 by brian
clean slate
543
544
#define HA_POS_ERROR	(~ (ha_rows) 0)
545
#define HA_OFFSET_ERROR	(~ (my_off_t) 0)
546
77.1.3 by Monty Taylor
MyISAM cleanups.
547
#if SIZEOF_OFF_T == 4
163 by Brian Aker
Merge Monty's code.
548
#define MAX_FILE_SIZE	INT32_MAX
1 by brian
clean slate
549
#else
163 by Brian Aker
Merge Monty's code.
550
#define MAX_FILE_SIZE	INT64_MAX
1 by brian
clean slate
551
#endif
552
553
#define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2)
554
555
/* invalidator function reference for Query Cache */
556
typedef void (* invalidator_by_filename)(const char * filename);
557
558
#endif /* _my_base_h */