74
72
#define RAND_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-1))
75
73
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
77
#define MAX_FIELDS 4096 /* Historical limit from MySQL FRM. */
75
#define MAX_FIELDS 4096 /* Limit in the .frm file */
79
77
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
81
79
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
82
80
#define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
82
/* Memory allocated when parsing a statement / saving a statement */
83
#define MEM_ROOT_BLOCK_SIZE 8192
84
#define MEM_ROOT_PREALLOC 8192
85
#define TRANS_MEM_ROOT_BLOCK_SIZE 4096
86
#define TRANS_MEM_ROOT_PREALLOC 4096
84
88
#define DEFAULT_ERROR_COUNT 64
85
89
#define EXTRA_RECORDS 10 /* Extra records in sort */
90
#define SCROLL_EXTRA 5 /* Extra scroll-rows. */
91
#define FIELD_NAME_USED ((uint32_t) 32768) /* Bit set if fieldname used */
92
#define FIELD_NR_MASK 16383 /* To get fieldnumber */
93
#define FERR -1 /* Error from my_functions */
94
#define CREATE_MODE 0 /* Default mode on new files */
86
95
#define NAMES_SEP_CHAR '\377' /* Char to sep. names */
88
97
#define READ_RECORD_BUFFER (uint32_t) (IO_SIZE*8) /* Pointer_buffer_size */
89
98
#define DISK_BUFFER_SIZE (uint32_t) (IO_SIZE*16) /* Size of diskbuffer */
100
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
91
101
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
92
102
#define MYF_RW MYF(MY_WME+MY_NABP) /* Vid my_read & my_write */
104
/* Defines for use with openfrm, openprt and openfrd */
106
#define READ_ALL 1 /* openfrm: Read all parameters */
107
#define CHANGE_FRM 2 /* openfrm: open .frm as O_RDWR */
108
#define EXTRA_RECORD 8 /* Reservera plats f|r extra record */
109
#define DONT_GIVE_ERROR 256 /* Don't do frm_error on openfrm */
110
#define DELAYED_OPEN 4096 /* Open table later */
112
This flag is used in function get_all_tables() which fills
113
I_S tables with data which are retrieved from frm files and storage engine
114
The flag means that we need to open FRM file only to get necessary data.
116
#define OPEN_FRM_FILE_ONLY 32768
118
This flag is used in function get_all_tables() which fills
119
I_S tables with data which are retrieved from frm files and storage engine
120
The flag means that we need to process tables only to get necessary data.
121
Views are not processed.
123
#define OPEN_TABLE_ONLY OPEN_FRM_FILE_ONLY*2
125
This flag is used in function get_all_tables() which fills
126
I_S tables with data which are retrieved from frm files and storage engine.
127
The flag means that I_S table uses optimization algorithm.
129
#define OPTIMIZE_I_S_TABLE OPEN_TABLE_ONLY*2
95
132
Minimum length pattern before Turbo Boyer-Moore is used
96
133
for SELECT "text" LIKE "%pattern%", excluding the two
270
339
#define HA_ADMIN_INTERNAL_ERROR -4
271
340
#define HA_ADMIN_INVALID -5
272
341
#define HA_ADMIN_REJECT -6
342
#define HA_ADMIN_TRY_ALTER -7
343
#define HA_ADMIN_NEEDS_UPGRADE -10
344
#define HA_ADMIN_NEEDS_ALTER -11
345
#define HA_ADMIN_NEEDS_CHECK -12
348
/* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
350
/* Return values for check_if_supported_alter */
352
#define HA_ALTER_ERROR -1
353
#define HA_ALTER_SUPPORTED_WAIT_LOCK 0
354
#define HA_ALTER_SUPPORTED_NO_LOCK 1
355
#define HA_ALTER_NOT_SUPPORTED 2
357
/* Bits in table_flags() to show what database can do */
359
#define HA_NO_TRANSACTIONS (1 << 0) /* Doesn't support transactions */
360
#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */
361
#define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */
363
The following should be set if the following is not true when scanning
364
a table with rnd_next()
365
- We will see all rows (including deleted ones)
366
- Row positions are 'table->s->db_record_offset' apart
367
If this flag is not set, filesort will do a postion() call for each matched
368
row to be able to find the row later.
370
#define HA_REC_NOT_IN_SEQ (1 << 3)
373
Reading keys in random order is as fast as reading keys in sort order
374
(Used in records.cc to decide if we should use a record cache and by
375
filesort to decide if we should sort key + data or key + pointer-to-row
377
#define HA_FAST_KEY_READ (1 << 5)
379
Set the following flag if we on delete should force all key to be read
380
and on update read all keys that changes
382
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6)
383
#define HA_NULL_IN_KEY (1 << 7) /* One can have keys with NULL */
384
#define HA_DUPLICATE_POS (1 << 8) /* ha_position() gives dup row */
385
#define HA_NO_BLOBS (1 << 9) /* Doesn't support blobs */
386
#define HA_CAN_INDEX_BLOBS (1 << 10)
387
#define HA_AUTO_PART_KEY (1 << 11) /* auto-increment in multi-part key */
388
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */
389
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */
391
If we get the primary key columns for free when we do an index read
392
It also implies that we have to retrive the primary key when using
393
position() and rnd_pos().
395
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
397
If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
398
uses a primary key. Without primary key, we can't call position().
400
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16)
401
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
403
The following is we need to a primary key to delete (and update) a row.
404
If there is no primary key, all columns needs to be read on update and delete
406
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
407
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
408
#define HA_NO_AUTO_INCREMENT (1 << 23)
409
#define HA_HAS_CHECKSUM (1 << 24)
410
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
411
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
412
#define HA_HAS_RECORDS (INT64_C(1) << 32) /* records() gives exact count*/
413
#define HA_MRR_CANT_SORT (INT64_C(1) << 34)
274
415
/* bits in index_flags(index_number) for what you can do with index */
275
416
#define HA_READ_NEXT 1 /* TODO really use this flag */
416
578
* The following are for the interface with the .frm file
581
#define FIELDFLAG_DECIMAL 1
582
#define FIELDFLAG_BINARY 1 // Shares same flag
583
#define FIELDFLAG_NUMBER 2
584
#define FIELDFLAG_DECIMAL_POSITION 4
585
#define FIELDFLAG_PACK 120 // Bits used for packing
586
#define FIELDFLAG_INTERVAL 256 // mangled with decimals!
587
#define FIELDFLAG_BLOB 1024 // mangled with decimals!
589
#define FIELDFLAG_NO_DEFAULT 16384 /* sql */
590
#define FIELDFLAG_SUM ((uint32_t) 32768)// predit: +#fieldflag
591
#define FIELDFLAG_MAYBE_NULL ((uint32_t) 32768)// sql
592
#define FIELDFLAG_HEX_ESCAPE ((uint32_t) 0x10000)
419
593
#define FIELDFLAG_PACK_SHIFT 3
594
#define FIELDFLAG_DEC_SHIFT 8
420
595
#define FIELDFLAG_MAX_DEC 31
422
597
#define MTYP_TYPENR(type) (type & 127) /* Remove bits from type */
599
#define f_is_dec(x) ((x) & FIELDFLAG_DECIMAL)
600
#define f_is_num(x) ((x) & FIELDFLAG_NUMBER)
601
#define f_is_decimal_precision(x) ((x) & FIELDFLAG_DECIMAL_POSITION)
602
#define f_is_packed(x) ((x) & FIELDFLAG_PACK)
603
#define f_packtype(x) (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
604
#define f_decimals(x) ((uint8_t) (((x) >> FIELDFLAG_DEC_SHIFT) & \
606
#define f_is_alpha(x) (!f_is_num(x))
607
#define f_is_binary(x) ((x) & FIELDFLAG_BINARY) // 4.0- compatibility
608
#define f_is_enum(x) (((x) & (FIELDFLAG_INTERVAL | FIELDFLAG_NUMBER)) == \
610
#define f_is_blob(x) (((x) & (FIELDFLAG_BLOB | FIELDFLAG_NUMBER)) == \
612
#define f_is_equ(x) ((x) & (1+2+FIELDFLAG_PACK+31*256))
424
613
#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 */
614
#define f_maybe_null(x) (x & FIELDFLAG_MAYBE_NULL)
615
#define f_no_default(x) (x & FIELDFLAG_NO_DEFAULT)
616
#define f_is_hex_escape(x) ((x) & FIELDFLAG_HEX_ESCAPE)
618
#endif /* DRIZZLE_SERVER_DEFINITIONS_H */