74
91
#define RAND_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-1))
75
92
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
77
#define MAX_FIELDS 4096 /* Historical limit from MySQL FRM. */
94
#define MAX_FIELDS 4096 /* Limit in the .frm file */
79
96
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
81
98
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
82
99
#define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
101
/* Memory allocated when parsing a statement / saving a statement */
102
#define MEM_ROOT_BLOCK_SIZE 8192
103
#define MEM_ROOT_PREALLOC 8192
104
#define TRANS_MEM_ROOT_BLOCK_SIZE 4096
105
#define TRANS_MEM_ROOT_PREALLOC 4096
84
107
#define DEFAULT_ERROR_COUNT 64
85
108
#define EXTRA_RECORDS 10 /* Extra records in sort */
109
#define SCROLL_EXTRA 5 /* Extra scroll-rows. */
110
#define FIELD_NAME_USED ((uint) 32768) /* Bit set if fieldname used */
111
#define FORM_NAME_USED ((uint) 16384) /* Bit set if formname used */
112
#define FIELD_NR_MASK 16383 /* To get fieldnumber */
113
#define FERR -1 /* Error from my_functions */
114
#define CREATE_MODE 0 /* Default mode on new files */
86
115
#define NAMES_SEP_CHAR '\377' /* Char to sep. names */
88
#define READ_RECORD_BUFFER (uint32_t) (IO_SIZE*8) /* Pointer_buffer_size */
89
#define DISK_BUFFER_SIZE (uint32_t) (IO_SIZE*16) /* Size of diskbuffer */
117
#define READ_RECORD_BUFFER (uint) (IO_SIZE*8) /* Pointer_buffer_size */
118
#define DISK_BUFFER_SIZE (uint) (IO_SIZE*16) /* Size of diskbuffer */
120
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
91
121
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
92
122
#define MYF_RW MYF(MY_WME+MY_NABP) /* Vid my_read & my_write */
125
#define store_record(A,B) memcpy((A)->B,(A)->record[0],(size_t) (A)->s->reclength)
126
#define restore_record(A,B) memcpy((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
127
#define cmp_record(A,B) memcmp((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
128
#define empty_record(A) \
130
restore_record((A),s->default_values); \
131
memset((A)->null_flags, 255, (A)->s->null_bytes); \
134
/* Defines for use with openfrm, openprt and openfrd */
136
#define READ_ALL 1 /* openfrm: Read all parameters */
137
#define CHANGE_FRM 2 /* openfrm: open .frm as O_RDWR */
138
#define EXTRA_RECORD 8 /* Reservera plats f|r extra record */
139
#define DONT_GIVE_ERROR 256 /* Don't do frm_error on openfrm */
140
#define DELAYED_OPEN 4096 /* Open table later */
142
This flag is used in function get_all_tables() which fills
143
I_S tables with data which are retrieved from frm files and storage engine
144
The flag means that we need to open FRM file only to get necessary data.
146
#define OPEN_FRM_FILE_ONLY 32768
148
This flag is used in function get_all_tables() which fills
149
I_S tables with data which are retrieved from frm files and storage engine
150
The flag means that we need to process tables only to get necessary data.
151
Views are not processed.
153
#define OPEN_TABLE_ONLY OPEN_FRM_FILE_ONLY*2
155
This flag is used in function get_all_tables() which fills
156
I_S tables with data which are retrieved from frm files and storage engine.
157
The flag means that I_S table uses optimization algorithm.
159
#define OPTIMIZE_I_S_TABLE OPEN_TABLE_ONLY*2
161
#define SC_INFO_LENGTH 4 /* Form format constant */
162
#define TE_INFO_LENGTH 3
163
#define MTYP_NOEMPTY_BIT 128
165
#define FRM_VER_TRUE_VARCHAR (FRM_VER+4) /* 10 */
166
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_CGE 50120
167
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM 50205
168
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_STR "50205"
95
171
Minimum length pattern before Turbo Boyer-Moore is used
96
172
for SELECT "text" LIKE "%pattern%", excluding the two
244
364
#define portable_sizeof_char_ptr 8
246
#define TMP_FILE_PREFIX "#sql" /**< Prefix for tmp tables */
247
#define TMP_FILE_PREFIX_LENGTH 4
366
#define tmp_file_prefix "#sql" /**< Prefix for tmp tables */
367
#define tmp_file_prefix_length 4
249
369
/* Flags for calc_week() function. */
250
370
#define WEEK_MONDAY_FIRST 1
251
371
#define WEEK_YEAR 2
252
372
#define WEEK_FIRST_WEEKDAY 4
254
/* used in date and time conversions */
255
/* Daynumber from year 0 to 9999-12-31 */
256
#define MAX_DAY_NUMBER 3652424L
258
374
#define STRING_BUFFER_USUAL_SIZE 80
260
typedef void *range_seq_t;
262
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
263
// the following is for checking tables
265
#define HA_ADMIN_ALREADY_DONE 1
266
#define HA_ADMIN_OK 0
267
#define HA_ADMIN_NOT_IMPLEMENTED -1
268
#define HA_ADMIN_FAILED -2
269
#define HA_ADMIN_CORRUPT -3
270
#define HA_ADMIN_INTERNAL_ERROR -4
271
#define HA_ADMIN_INVALID -5
272
#define HA_ADMIN_REJECT -6
274
/* bits in index_flags(index_number) for what you can do with index */
275
#define HA_READ_NEXT 1 /* TODO really use this flag */
276
#define HA_READ_PREV 2 /* supports ::index_prev */
277
#define HA_READ_ORDER 4 /* index_next/prev follow sort order */
278
#define HA_READ_RANGE 8 /* can find all records in a range */
279
#define HA_ONLY_WHOLE_INDEX 16 /* Can't use part key searches */
280
#define HA_KEYREAD_ONLY 64 /* Support HA_EXTRA_KEYREAD */
282
Index scan will not return records in rowid order. Not guaranteed to be
283
set for unordered (e.g. HASH) indexes.
285
#define HA_KEY_SCAN_NOT_ROR 128
287
/* operations for disable/enable indexes */
288
#define HA_KEY_SWITCH_NONUNIQ 0
289
#define HA_KEY_SWITCH_ALL 1
290
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
291
#define HA_KEY_SWITCH_ALL_SAVE 3
294
Note: the following includes binlog and closing 0.
295
so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
296
example + csv + heap + blackhole + federated + 0
297
(yes, the sum is deliberately inaccurate)
298
TODO remove the limit, use dynarrays
303
Parameters for open() (in register form->filestat)
304
HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
307
#define HA_OPEN_KEYFILE 1
308
#define HA_OPEN_RNDFILE 2
309
#define HA_GET_INDEX 4
310
#define HA_GET_INFO 8 /* do a ha_info() after open */
311
#define HA_READ_ONLY 16 /* File opened as readonly */
312
/* Try readonly if can't open with read and write */
313
#define HA_TRY_READ_ONLY 32
314
#define HA_WAIT_IF_LOCKED 64 /* Wait if locked on open */
315
#define HA_ABORT_IF_LOCKED 128 /* skip if locked on open.*/
316
#define HA_BLOCK_LOCK 256 /* unlock when reading some records */
317
#define HA_OPEN_TEMPORARY 512
319
/* For transactional LOCK Table. handler::lock_table() */
320
#define HA_LOCK_IN_SHARE_MODE F_RDLCK
321
#define HA_LOCK_IN_EXCLUSIVE_MODE F_WRLCK
323
/* Some key definitions */
324
#define HA_KEY_NULL_LENGTH 1
325
#define HA_KEY_BLOB_LENGTH 2
327
#define HA_MAX_REC_LENGTH 65535
329
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
330
enum start_transaction_option_t
332
START_TRANS_NO_OPTIONS,
333
START_TRANS_OPT_WITH_CONS_SNAPSHOT
336
/* Flags for method is_fatal_error */
337
#define HA_CHECK_DUP_KEY 1
338
#define HA_CHECK_DUP_UNIQUE 2
339
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
342
/* Bits in used_fields */
343
#define HA_CREATE_USED_AUTO (1L << 0)
344
#define HA_CREATE_USED_CHARSET (1L << 8)
345
#define HA_CREATE_USED_DEFAULT_CHARSET (1L << 9)
346
#define HA_CREATE_USED_ROW_FORMAT (1L << 15)
347
#define HA_CREATE_USED_KEY_BLOCK_SIZE (1L << 19)
348
#define HA_CREATE_USED_BLOCK_SIZE (1L << 22)
351
The below two are not used (and not handled) in this milestone of this WL
352
entry because there seems to be no use for them at this stage of
355
#define HA_MRR_SINGLE_POINT 1
356
#define HA_MRR_FIXED_KEY 2
359
Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
362
#define HA_MRR_NO_ASSOCIATION 4
365
The MRR user will provide ranges in key order, and MRR implementation
366
must return rows in key order.
368
#define HA_MRR_SORTED 8
370
/* MRR implementation doesn't have to retrieve full records */
371
#define HA_MRR_INDEX_ONLY 16
374
The passed memory buffer is of maximum possible size, the caller can't
375
assume larger buffer.
377
#define HA_MRR_LIMITS 32
381
Flag set <=> default MRR implementation is used
382
(The choice is made by **_info[_const]() function which may set this
383
flag. SQL layer remembers the flag value and then passes it to
384
multi_read_range_init().
386
#define HA_MRR_USE_DEFAULT_IMPL 64
389
#define MYF(v) (static_cast<drizzled::myf>(v))
392
"Declared Type Collation"
393
A combination of collation and its derivation.
395
Flags for collation aggregation modes:
396
MY_COLL_ALLOW_SUPERSET_CONV - allow conversion to a superset
397
MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
399
MY_COLL_ALLOW_CONV - allow any kind of conversion
400
(combination of the above two)
401
MY_COLL_DISALLOW_NONE - don't allow return DERIVATION_NONE
402
(e.g. when aggregating for comparison)
403
MY_COLL_CMP_CONV - combination of MY_COLL_ALLOW_CONV
404
and MY_COLL_DISALLOW_NONE
407
#define MY_COLL_ALLOW_SUPERSET_CONV 1
408
#define MY_COLL_ALLOW_COERCIBLE_CONV 2
409
#define MY_COLL_ALLOW_CONV 3
410
#define MY_COLL_DISALLOW_NONE 4
411
#define MY_COLL_CMP_CONV 7
412
#define clear_timestamp_auto_bits(_target_, _bits_) \
413
(_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
416
* The following are for the interface with the .frm file
419
#define FIELDFLAG_PACK_SHIFT 3
420
#define FIELDFLAG_MAX_DEC 31
422
#define MTYP_TYPENR(type) (type & 127) /* Remove bits from type */
424
#define f_settype(x) (((int) x) << FIELDFLAG_PACK_SHIFT)
428
template <class T> void set_if_bigger(T &a, const T &b)
434
template <class T> void set_if_smaller(T &a, const T &b)
441
#define set_if_bigger(a,b) do { \
442
const typeof(a) _a = (a); \
443
const typeof(b) _b = (b); \
444
(void) (&_a == &_b); \
445
if ((a) < (b)) (a)=(b); \
447
#define set_if_smaller(a,b) do { \
448
const typeof(a) _a = (a); \
449
const typeof(b) _b = (b); \
450
(void) (&_a == &_b); \
451
if ((a) > (b)) (a)=(b); \
455
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
456
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
461
#define array_elements(a) \
462
((sizeof(a) / sizeof(*(a))) / \
463
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
466
/* Some types that is different between systems */
469
#define FN_LIBCHAR '/'
470
#define FN_ROOTDIR "/"
472
#define MY_NFILE 64 /* This is only used to save filenames */
473
#ifndef OS_FILE_LIMIT
474
#define OS_FILE_LIMIT 65535
478
How much overhead does malloc have. The code often allocates
479
something like 1024-MALLOC_OVERHEAD bytes
481
#define MALLOC_OVERHEAD 8
483
/* get memory in huncs */
484
static const uint32_t ONCE_ALLOC_INIT= 4096;
485
/* Typical record cash */
486
static const uint32_t RECORD_CACHE_SIZE= 64*1024;
487
/* Typical key cash */
488
static const uint32_t KEY_CACHE_SIZE= 8*1024*1024;
490
/* Default size of a key cache block */
491
static const uint32_t KEY_CACHE_BLOCK_SIZE= 1024;
494
/* Some things that this system doesn't have */
496
/* Some defines of functions for portability */
498
#ifndef uint64_t2double
499
#define uint64_t2double(A) ((double) (uint64_t) (A))
503
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
505
#define ulong_to_double(X) ((double) (ulong) (X))
507
/* From limits.h instead */
509
#define DBL_MIN 4.94065645841246544e-324
512
#define DBL_MAX 1.79769313486231470e+308
516
/* Define missing math constants. */
518
#define M_PI 3.14159265358979323846
521
#define M_E 2.7182818284590452354
524
#define M_LN2 0.69314718055994530942
528
Max size that must be added to a so that we know Size to make
531
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
532
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
533
/* Size to make adressable obj. */
534
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
535
/* Offset of field f in structure t */
536
#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
538
#define ADD_TO_PTR(ptr,size,type) (type) (reinterpret_cast<const unsigned char*>(ptr)+size)
539
#define PTR_BYTE_DIFF(A,B) (ptrdiff_t) (reinterpret_cast<const unsigned char*>(A) - reinterpret_cast<const unsigned char*>(B))
541
#define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
542
#define PTR_BYTE_DIFF(A,B) (ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
545
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
546
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
548
/* Typdefs for easyier portability */
551
#if defined(SIZEOF_OFF_T)
552
# if (SIZEOF_OFF_T == 8)
553
# define OFF_T_MAX (INT64_MAX)
555
# define OFF_T_MAX (INT32_MAX)
559
#define MY_FILEPOS_ERROR -1
561
#define DRIZZLE_SERVER
563
/* Length of decimal number represented by INT32. */
564
#define MY_INT32_NUM_DECIMAL_DIGITS 11
566
/* Length of decimal number represented by INT64. */
567
#define MY_INT64_NUM_DECIMAL_DIGITS 21
570
Io buffer size; Must be a power of 2 and
571
a multiple of 512. May be
572
smaller what the disk page size. This influences the speed of the
573
isam btree library. eg to big to slow.
576
/* Max file name len */
578
/* Max length of extension (part of FN_LEN) */
580
/* Max length of full path-name */
581
#define FN_REFLEN 512
582
/* File extension character */
583
#define FN_EXTCHAR '.'
584
/* ~ is used as abbrev for home dir */
585
#define FN_HOMELIB '~'
586
/* ./ is used as abbrev for current dir */
587
#define FN_CURLIB '.'
588
/* Parent directory; Must be a string */
589
#define FN_PARENTDIR ".."
591
/* Quote argument (before cpp) */
593
# define QUOTE_ARG(x) #x
595
/* Quote argument, (after cpp) */
596
#ifndef STRINGIFY_ARG
597
# define STRINGIFY_ARG(x) QUOTE_ARG(x)
601
* The macros below are borrowed from include/linux/compiler.h in the
602
* Linux kernel. Use them to indicate the likelyhood of the truthfulness
603
* of a condition. This serves two purposes - newer versions of gcc will be
604
* able to optimize for branch predication, which could yield siginficant
605
* performance gains in frequently executed sections of the code, and the
606
* other reason to use them is for documentation
608
#if !defined(__GNUC__)
609
#define __builtin_expect(x, expected_value) (x)
612
#define likely(x) __builtin_expect((x),1)
613
#define unlikely(x) __builtin_expect((x),0)
617
Only Linux is known to need an explicit sync of the directory to make sure a
618
file creation/deletion/renaming in(from,to) this directory durable.
620
#ifdef TARGET_OS_LINUX
621
#define NEED_EXPLICIT_SYNC_DIR 1
624
/* We need to turn off _DTRACE_VERSION if we're not going to use dtrace */
625
#if !defined(HAVE_DTRACE)
626
# undef _DTRACE_VERSION
627
# define _DTRACE_VERSION 0
630
} /* namespace drizzled */
632
#endif /* DRIZZLED_DEFINITIONS_H */
377
Some defines for exit codes for ::is_equal class functions.
379
#define IS_EQUAL_NO 0
380
#define IS_EQUAL_YES 1
381
#define IS_EQUAL_PACK_LENGTH 2
384
#endif /* DRIZZLE_SERVER_DEFINITIONS_H */