83
72
#define RAND_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-1))
84
73
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
86
#define MAX_FIELDS 4096 /* Historical limit from MySQL FRM. */
75
#define MAX_FIELDS 4096 /* Limit in the .frm file */
88
77
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
90
79
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
91
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
93
88
#define DEFAULT_ERROR_COUNT 64
94
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 */
95
95
#define NAMES_SEP_CHAR '\377' /* Char to sep. names */
97
97
#define READ_RECORD_BUFFER (uint32_t) (IO_SIZE*8) /* Pointer_buffer_size */
98
98
#define DISK_BUFFER_SIZE (uint32_t) (IO_SIZE*16) /* Size of diskbuffer */
100
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
100
101
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
101
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
104
132
Minimum length pattern before Turbo Boyer-Moore is used
105
133
for SELECT "text" LIKE "%pattern%", excluding the two
190
244
/* The following can also be changed from the command line */
191
245
#define DEFAULT_CONCURRENCY 10
192
246
#define FLUSH_TIME 0 /**< Don't flush tables */
247
#define MAX_CONNECT_ERRORS 10 ///< errors before disabling host
249
#define INTERRUPT_PRIOR 10
250
#define CONNECT_PRIOR 9
252
#define QUERY_PRIOR 6
254
/* Bits from testflag */
257
TEST_PRINT_CACHED_TABLES= 1,
260
TEST_KEEP_TMP_TABLES,
261
TEST_READCHECK, /**< Force use of readcheck */
263
TEST_CORE_ON_SIGNAL, /**< Give core if signal */
265
TEST_SIGINT, /**< Allow sigint on threads */
266
TEST_SYNCHRONIZATION /**< get server to do sleep in some places */
194
269
/* Bits for different SQL modes modes (including ANSI mode) */
195
270
#define MODE_NO_ZERO_DATE (2)
196
271
#define MODE_INVALID_DATES (MODE_NO_ZERO_DATE*2)
273
/* @@optimizer_switch flags */
274
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
275
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
198
277
#define MY_CHARSET_BIN_MB_MAXLEN 1
200
279
// uncachable cause
201
static const uint32_t UNCACHEABLE_DEPENDENT= 1;
202
static const uint32_t UNCACHEABLE_RAND= 2;
203
static const uint32_t UNCACHEABLE_SIDEEFFECT= 3;
280
#define UNCACHEABLE_DEPENDENT 1
281
#define UNCACHEABLE_RAND 2
282
#define UNCACHEABLE_SIDEEFFECT 4
204
283
/// forcing to save JOIN for explain
205
static const uint32_t UNCACHEABLE_EXPLAIN= 4;
284
#define UNCACHEABLE_EXPLAIN 8
206
285
/** Don't evaluate subqueries in prepare even if they're not correlated */
207
static const uint32_t UNCACHEABLE_PREPARE= 5;
286
#define UNCACHEABLE_PREPARE 16
208
287
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
209
static const uint32_t UNCACHEABLE_UNITED= 6;
288
#define UNCACHEABLE_UNITED 32
211
290
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
212
291
#define UNDEF_POS (-1)
293
/* sql_show.cc:show_log_files() */
294
#define SHOW_LOG_STATUS_FREE "FREE"
295
#define SHOW_LOG_STATUS_INUSE "IN USE"
214
297
/* Options to add_table_to_list() */
215
static const uint32_t TL_OPTION_UPDATING= 0;
216
static const uint32_t TL_OPTION_FORCE_INDEX= 1;
217
static const uint32_t TL_OPTION_IGNORE_LEAVES= 2;
218
static const uint32_t TL_OPTION_ALIAS= 3;
219
static const uint32_t NUM_OF_TABLE_OPTIONS= 4;
298
#define TL_OPTION_UPDATING 1
299
#define TL_OPTION_FORCE_INDEX 2
300
#define TL_OPTION_IGNORE_LEAVES 4
301
#define TL_OPTION_ALIAS 8
221
303
/* Some portable defines */
249
339
#define HA_ADMIN_INTERNAL_ERROR -4
250
340
#define HA_ADMIN_INVALID -5
251
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)
253
415
/* bits in index_flags(index_number) for what you can do with index */
254
416
#define HA_READ_NEXT 1 /* TODO really use this flag */
386
574
#define MY_COLL_ALLOW_CONV 3
387
575
#define MY_COLL_DISALLOW_NONE 4
388
576
#define MY_COLL_CMP_CONV 7
390
inline static void clear_timestamp_auto_bits(timestamp_auto_set_type &_target_,
391
timestamp_auto_set_type _bits_)
393
_target_= static_cast<timestamp_auto_set_type>(_target_ & ~_bits_);
577
#define clear_timestamp_auto_bits(_target_, _bits_) \
578
(_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
397
581
* The following are for the interface with the .frm file
584
#define FIELDFLAG_DECIMAL 1
585
#define FIELDFLAG_BINARY 1 // Shares same flag
586
#define FIELDFLAG_NUMBER 2
587
#define FIELDFLAG_DECIMAL_POSITION 4
588
#define FIELDFLAG_PACK 120 // Bits used for packing
589
#define FIELDFLAG_INTERVAL 256 // mangled with decimals!
590
#define FIELDFLAG_BLOB 1024 // mangled with decimals!
592
#define FIELDFLAG_NO_DEFAULT 16384 /* sql */
593
#define FIELDFLAG_SUM ((uint32_t) 32768)// predit: +#fieldflag
594
#define FIELDFLAG_MAYBE_NULL ((uint32_t) 32768)// sql
595
#define FIELDFLAG_HEX_ESCAPE ((uint32_t) 0x10000)
400
596
#define FIELDFLAG_PACK_SHIFT 3
597
#define FIELDFLAG_DEC_SHIFT 8
401
598
#define FIELDFLAG_MAX_DEC 31
404
// FIXME: T will just be drizzled::Field::utype, but that would
405
// require including field.h. Moving the function elsewhere might be a
406
// better idea. Leaving it for restructuring.
407
template <typename T>
408
T MTYP_TYPENR(const T& type)
410
return static_cast<T>(type & 127);
413
600
#define MTYP_TYPENR(type) (type & 127) /* Remove bits from type */
416
inline static uint32_t f_settype(const enum enum_field_types x)
418
return (uint32_t(x) << FIELDFLAG_PACK_SHIFT);
422
template <class T> void set_if_bigger(T &a, const T &b)
428
template <class T> void set_if_smaller(T &a, const T &b)
435
#define set_if_bigger(a,b) do { \
436
const typeof(a) _a = (a); \
437
const typeof(b) _b = (b); \
438
(void) (&_a == &_b); \
439
if ((a) < (b)) (a)=(b); \
441
#define set_if_smaller(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); \
449
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
450
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
455
#define array_elements(a) \
456
((sizeof(a) / sizeof(*(a))) / \
457
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
460
/* Some types that is different between systems */
463
#define FN_LIBCHAR '/'
464
#define FN_ROOTDIR "/"
466
#define MY_NFILE 64 /* This is only used to save filenames */
467
#ifndef OS_FILE_LIMIT
468
#define OS_FILE_LIMIT 65535
472
How much overhead does malloc have. The code often allocates
473
something like 1024-MALLOC_OVERHEAD bytes
475
#define MALLOC_OVERHEAD 8
477
/* get memory in huncs */
478
static const uint32_t ONCE_ALLOC_INIT= 4096;
479
/* Typical record cash */
480
static const uint32_t RECORD_CACHE_SIZE= 64*1024;
483
/* Some things that this system doesn't have */
485
/* Some defines of functions for portability */
487
#ifndef uint64_t2double
488
#define uint64_t2double(A) ((double) (uint64_t) (A))
491
#ifndef int64_t2double
492
#define int64_t2double(A) ((double) (int64_t) (A))
496
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
498
#define ulong_to_double(X) ((double) (ulong) (X))
500
/* From limits.h instead */
502
#define DBL_MIN 4.94065645841246544e-324
505
#define DBL_MAX 1.79769313486231470e+308
509
/* Define missing math constants. */
511
#define M_PI 3.14159265358979323846
514
#define M_E 2.7182818284590452354
517
#define M_LN2 0.69314718055994530942
521
Max size that must be added to a so that we know Size to make
524
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
525
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
526
/* Size to make adressable obj. */
527
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
528
/* Offset of field f in structure t */
529
#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
531
#define ADD_TO_PTR(ptr,size,type) (type) (reinterpret_cast<const unsigned char*>(ptr)+size)
532
#define PTR_BYTE_DIFF(A,B) (ptrdiff_t) (reinterpret_cast<const unsigned char*>(A) - reinterpret_cast<const unsigned char*>(B))
534
#define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
535
#define PTR_BYTE_DIFF(A,B) (ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
538
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
539
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
541
/* Typdefs for easyier portability */
544
#if defined(SIZEOF_OFF_T)
545
# if (SIZEOF_OFF_T == 8)
546
# define OFF_T_MAX (INT64_MAX)
548
# define OFF_T_MAX (INT32_MAX)
552
#define MY_FILEPOS_ERROR -1
554
#define DRIZZLE_SERVER
556
/* Length of decimal number represented by INT32. */
557
#define MY_INT32_NUM_DECIMAL_DIGITS 11
559
/* Length of decimal number represented by INT64. */
560
#define MY_INT64_NUM_DECIMAL_DIGITS 21
563
Io buffer size; Must be a power of 2 and
564
a multiple of 512. May be
565
smaller what the disk page size. This influences the speed of the
566
isam btree library. eg to big to slow.
569
/* Max file name len */
571
/* Max length of extension (part of FN_LEN) */
573
/* Max length of full path-name */
574
#define FN_REFLEN 512
575
/* File extension character */
576
#define FN_EXTCHAR '.'
577
/* ~ is used as abbrev for home dir */
578
#define FN_HOMELIB '~'
579
/* ./ is used as abbrev for current dir */
580
#define FN_CURLIB '.'
581
/* Parent directory; Must be a string */
582
#define FN_PARENTDIR ".."
584
/* Quote argument (before cpp) */
586
# define QUOTE_ARG(x) #x
588
/* Quote argument, (after cpp) */
589
#ifndef STRINGIFY_ARG
590
# define STRINGIFY_ARG(x) QUOTE_ARG(x)
594
* The macros below are borrowed from include/linux/compiler.h in the
595
* Linux kernel. Use them to indicate the likelyhood of the truthfulness
596
* of a condition. This serves two purposes - newer versions of gcc will be
597
* able to optimize for branch predication, which could yield siginficant
598
* performance gains in frequently executed sections of the code, and the
599
* other reason to use them is for documentation
601
#if !defined(__GNUC__)
602
#define __builtin_expect(x, expected_value) (x)
605
#define likely(x) __builtin_expect((x),1)
606
#define unlikely(x) __builtin_expect((x),0)
610
Only Linux is known to need an explicit sync of the directory to make sure a
611
file creation/deletion/renaming in(from,to) this directory durable.
613
#ifdef TARGET_OS_LINUX
614
#define NEED_EXPLICIT_SYNC_DIR 1
617
/* We need to turn off _DTRACE_VERSION if we're not going to use dtrace */
618
#if !defined(HAVE_DTRACE)
619
# undef _DTRACE_VERSION
620
# define _DTRACE_VERSION 0
623
typedef uint64_t table_map; /* Used for table bits in join */
624
typedef uint32_t nesting_map; /* Used for flags of nesting constructs */
626
} /* namespace drizzled */
628
#endif /* DRIZZLED_DEFINITIONS_H */
602
#define f_is_dec(x) ((x) & FIELDFLAG_DECIMAL)
603
#define f_is_num(x) ((x) & FIELDFLAG_NUMBER)
604
#define f_is_decimal_precision(x) ((x) & FIELDFLAG_DECIMAL_POSITION)
605
#define f_is_packed(x) ((x) & FIELDFLAG_PACK)
606
#define f_packtype(x) (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
607
#define f_decimals(x) ((uint8_t) (((x) >> FIELDFLAG_DEC_SHIFT) & \
609
#define f_is_alpha(x) (!f_is_num(x))
610
#define f_is_binary(x) ((x) & FIELDFLAG_BINARY) // 4.0- compatibility
611
#define f_is_enum(x) (((x) & (FIELDFLAG_INTERVAL | FIELDFLAG_NUMBER)) == \
613
#define f_is_blob(x) (((x) & (FIELDFLAG_BLOB | FIELDFLAG_NUMBER)) == \
615
#define f_is_equ(x) ((x) & (1+2+FIELDFLAG_PACK+31*256))
616
#define f_settype(x) (((int) x) << FIELDFLAG_PACK_SHIFT)
617
#define f_maybe_null(x) (x & FIELDFLAG_MAYBE_NULL)
618
#define f_no_default(x) (x & FIELDFLAG_NO_DEFAULT)
619
#define f_is_hex_escape(x) ((x) & FIELDFLAG_HEX_ESCAPE)
621
#endif /* DRIZZLE_SERVER_DEFINITIONS_H */