82
72
#define RAND_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-1))
83
73
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
85
#define MAX_FIELDS 4096 /* Historical limit from MySQL FRM. */
75
#define MAX_FIELDS 4096 /* Limit in the .frm file */
87
77
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
89
79
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
90
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
92
86
#define DEFAULT_ERROR_COUNT 64
93
87
#define EXTRA_RECORDS 10 /* Extra records in sort */
88
#define SCROLL_EXTRA 5 /* Extra scroll-rows. */
89
#define FIELD_NAME_USED ((uint32_t) 32768) /* Bit set if fieldname used */
90
#define FIELD_NR_MASK 16383 /* To get fieldnumber */
91
#define FERR -1 /* Error from my_functions */
92
#define CREATE_MODE 0 /* Default mode on new files */
94
93
#define NAMES_SEP_CHAR '\377' /* Char to sep. names */
96
95
#define READ_RECORD_BUFFER (uint32_t) (IO_SIZE*8) /* Pointer_buffer_size */
97
96
#define DISK_BUFFER_SIZE (uint32_t) (IO_SIZE*16) /* Size of diskbuffer */
98
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
99
99
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
100
100
#define MYF_RW MYF(MY_WME+MY_NABP) /* Vid my_read & my_write */
102
/* Defines for use with openfrm, openprt and openfrd */
104
#define READ_ALL 1 /* openfrm: Read all parameters */
105
#define EXTRA_RECORD 8 /* Reservera plats f|r extra record */
106
#define DONT_GIVE_ERROR 256 /* Don't do frm_error on openfrm */
107
#define DELAYED_OPEN 4096 /* Open table later */
109
This flag is used in function get_all_tables() which fills
110
I_S tables with data which are retrieved from frm files and storage engine
111
The flag means that we need to open FRM file only to get necessary data.
113
#define OPEN_FRM_FILE_ONLY 32768
115
This flag is used in function get_all_tables() which fills
116
I_S tables with data which are retrieved from frm files and storage engine
117
The flag means that we need to process tables only to get necessary data.
118
Views are not processed.
120
#define OPEN_TABLE_ONLY OPEN_FRM_FILE_ONLY*2
122
This flag is used in function get_all_tables() which fills
123
I_S tables with data which are retrieved from frm files and storage engine.
124
The flag means that I_S table uses optimization algorithm.
126
#define OPTIMIZE_I_S_TABLE OPEN_TABLE_ONLY*2
103
129
Minimum length pattern before Turbo Boyer-Moore is used
104
130
for SELECT "text" LIKE "%pattern%", excluding the two
218
260
#define MODE_NO_ZERO_DATE (2)
219
261
#define MODE_INVALID_DATES (MODE_NO_ZERO_DATE*2)
263
/* @@optimizer_switch flags */
264
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
265
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
221
267
#define MY_CHARSET_BIN_MB_MAXLEN 1
223
269
// uncachable cause
224
static const uint32_t UNCACHEABLE_DEPENDENT= 1;
225
static const uint32_t UNCACHEABLE_RAND= 2;
226
static const uint32_t UNCACHEABLE_SIDEEFFECT= 3;
270
#define UNCACHEABLE_DEPENDENT 1
271
#define UNCACHEABLE_RAND 2
272
#define UNCACHEABLE_SIDEEFFECT 4
227
273
/// forcing to save JOIN for explain
228
static const uint32_t UNCACHEABLE_EXPLAIN= 4;
274
#define UNCACHEABLE_EXPLAIN 8
229
275
/** Don't evaluate subqueries in prepare even if they're not correlated */
230
static const uint32_t UNCACHEABLE_PREPARE= 5;
276
#define UNCACHEABLE_PREPARE 16
231
277
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
232
static const uint32_t UNCACHEABLE_UNITED= 6;
278
#define UNCACHEABLE_UNITED 32
234
280
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
235
281
#define UNDEF_POS (-1)
283
/* sql_show.cc:show_log_files() */
284
#define SHOW_LOG_STATUS_FREE "FREE"
285
#define SHOW_LOG_STATUS_INUSE "IN USE"
237
287
/* Options to add_table_to_list() */
238
static const uint32_t TL_OPTION_UPDATING= 0;
239
static const uint32_t TL_OPTION_FORCE_INDEX= 1;
240
static const uint32_t TL_OPTION_IGNORE_LEAVES= 2;
241
static const uint32_t TL_OPTION_ALIAS= 3;
242
static const uint32_t NUM_OF_TABLE_OPTIONS= 4;
288
#define TL_OPTION_UPDATING 1
289
#define TL_OPTION_FORCE_INDEX 2
290
#define TL_OPTION_IGNORE_LEAVES 4
291
#define TL_OPTION_ALIAS 8
244
293
/* Some portable defines */
272
330
#define HA_ADMIN_INTERNAL_ERROR -4
273
331
#define HA_ADMIN_INVALID -5
274
332
#define HA_ADMIN_REJECT -6
333
#define HA_ADMIN_TRY_ALTER -7
334
#define HA_ADMIN_NEEDS_UPGRADE -10
335
#define HA_ADMIN_NEEDS_ALTER -11
336
#define HA_ADMIN_NEEDS_CHECK -12
338
/* Bits in table_flags() to show what database can do */
340
#define HA_NO_TRANSACTIONS (1 << 0) /* Doesn't support transactions */
341
#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */
342
#define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */
344
The following should be set if the following is not true when scanning
345
a table with rnd_next()
346
- We will see all rows (including deleted ones)
347
- Row positions are 'table->s->db_record_offset' apart
348
If this flag is not set, filesort will do a postion() call for each matched
349
row to be able to find the row later.
351
#define HA_REC_NOT_IN_SEQ (1 << 3)
354
Reading keys in random order is as fast as reading keys in sort order
355
(Used in records.cc to decide if we should use a record cache and by
356
filesort to decide if we should sort key + data or key + pointer-to-row
358
#define HA_FAST_KEY_READ (1 << 5)
360
Set the following flag if we on delete should force all key to be read
361
and on update read all keys that changes
363
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6)
364
#define HA_NULL_IN_KEY (1 << 7) /* One can have keys with NULL */
365
#define HA_DUPLICATE_POS (1 << 8) /* ha_position() gives dup row */
366
#define HA_NO_BLOBS (1 << 9) /* Doesn't support blobs */
367
#define HA_CAN_INDEX_BLOBS (1 << 10)
368
#define HA_AUTO_PART_KEY (1 << 11) /* auto-increment in multi-part key */
369
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */
370
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */
372
If we get the primary key columns for free when we do an index read
373
It also implies that we have to retrive the primary key when using
374
position() and rnd_pos().
376
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
378
If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
379
uses a primary key. Without primary key, we can't call position().
381
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16)
382
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
384
The following is we need to a primary key to delete (and update) a row.
385
If there is no primary key, all columns needs to be read on update and delete
387
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
388
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
389
#define HA_NO_AUTO_INCREMENT (1 << 23)
390
#define HA_HAS_CHECKSUM (1 << 24)
391
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
392
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
393
#define HA_HAS_RECORDS (INT64_C(1) << 32) /* records() gives exact count*/
394
#define HA_MRR_CANT_SORT (INT64_C(1) << 34)
276
396
/* bits in index_flags(index_number) for what you can do with index */
277
397
#define HA_READ_NEXT 1 /* TODO really use this flag */
423
566
#define FIELDFLAG_PACK_SHIFT 3
424
567
#define FIELDFLAG_MAX_DEC 31
427
// FIXME: T will just be drizzled::Field::utype, but that would
428
// require including field.h. Moving the function elsewhere might be a
429
// better idea. Leaving it for restructuring.
430
template <typename T>
431
T MTYP_TYPENR(const T& type)
433
return static_cast<T>(type & 127);
436
569
#define MTYP_TYPENR(type) (type & 127) /* Remove bits from type */
439
inline static uint32_t f_settype(const enum enum_field_types x)
441
return (uint32_t(x) << FIELDFLAG_PACK_SHIFT);
445
template <class T> void set_if_bigger(T &a, const T &b)
451
template <class T> void set_if_smaller(T &a, const T &b)
458
#define set_if_bigger(a,b) do { \
459
const typeof(a) _a = (a); \
460
const typeof(b) _b = (b); \
461
(void) (&_a == &_b); \
462
if ((a) < (b)) (a)=(b); \
464
#define set_if_smaller(a,b) do { \
465
const typeof(a) _a = (a); \
466
const typeof(b) _b = (b); \
467
(void) (&_a == &_b); \
468
if ((a) > (b)) (a)=(b); \
472
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
473
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
478
#define array_elements(a) \
479
((sizeof(a) / sizeof(*(a))) / \
480
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
483
/* Some types that is different between systems */
486
#define FN_LIBCHAR '/'
487
#define FN_ROOTDIR "/"
489
#define MY_NFILE 64 /* This is only used to save filenames */
490
#ifndef OS_FILE_LIMIT
491
#define OS_FILE_LIMIT 65535
495
How much overhead does malloc have. The code often allocates
496
something like 1024-MALLOC_OVERHEAD bytes
498
#define MALLOC_OVERHEAD 8
500
/* get memory in huncs */
501
static const uint32_t ONCE_ALLOC_INIT= 4096;
502
/* Typical record cash */
503
static const uint32_t RECORD_CACHE_SIZE= 64*1024;
506
/* Some things that this system doesn't have */
508
/* Some defines of functions for portability */
510
#ifndef uint64_t2double
511
#define uint64_t2double(A) ((double) (uint64_t) (A))
515
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
517
#define ulong_to_double(X) ((double) (ulong) (X))
519
/* From limits.h instead */
521
#define DBL_MIN 4.94065645841246544e-324
524
#define DBL_MAX 1.79769313486231470e+308
528
/* Define missing math constants. */
530
#define M_PI 3.14159265358979323846
533
#define M_E 2.7182818284590452354
536
#define M_LN2 0.69314718055994530942
540
Max size that must be added to a so that we know Size to make
543
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
544
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
545
/* Size to make adressable obj. */
546
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
547
/* Offset of field f in structure t */
548
#define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f)
550
#define ADD_TO_PTR(ptr,size,type) (type) (reinterpret_cast<const unsigned char*>(ptr)+size)
551
#define PTR_BYTE_DIFF(A,B) (ptrdiff_t) (reinterpret_cast<const unsigned char*>(A) - reinterpret_cast<const unsigned char*>(B))
553
#define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
554
#define PTR_BYTE_DIFF(A,B) (ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
557
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
558
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
560
/* Typdefs for easyier portability */
563
#if defined(SIZEOF_OFF_T)
564
# if (SIZEOF_OFF_T == 8)
565
# define OFF_T_MAX (INT64_MAX)
567
# define OFF_T_MAX (INT32_MAX)
571
#define MY_FILEPOS_ERROR -1
573
#define DRIZZLE_SERVER
575
/* Length of decimal number represented by INT32. */
576
#define MY_INT32_NUM_DECIMAL_DIGITS 11
578
/* Length of decimal number represented by INT64. */
579
#define MY_INT64_NUM_DECIMAL_DIGITS 21
582
Io buffer size; Must be a power of 2 and
583
a multiple of 512. May be
584
smaller what the disk page size. This influences the speed of the
585
isam btree library. eg to big to slow.
588
/* Max file name len */
590
/* Max length of extension (part of FN_LEN) */
592
/* Max length of full path-name */
593
#define FN_REFLEN 512
594
/* File extension character */
595
#define FN_EXTCHAR '.'
596
/* ~ is used as abbrev for home dir */
597
#define FN_HOMELIB '~'
598
/* ./ is used as abbrev for current dir */
599
#define FN_CURLIB '.'
600
/* Parent directory; Must be a string */
601
#define FN_PARENTDIR ".."
603
/* Quote argument (before cpp) */
605
# define QUOTE_ARG(x) #x
607
/* Quote argument, (after cpp) */
608
#ifndef STRINGIFY_ARG
609
# define STRINGIFY_ARG(x) QUOTE_ARG(x)
613
* The macros below are borrowed from include/linux/compiler.h in the
614
* Linux kernel. Use them to indicate the likelyhood of the truthfulness
615
* of a condition. This serves two purposes - newer versions of gcc will be
616
* able to optimize for branch predication, which could yield siginficant
617
* performance gains in frequently executed sections of the code, and the
618
* other reason to use them is for documentation
620
#if !defined(__GNUC__)
621
#define __builtin_expect(x, expected_value) (x)
624
#define likely(x) __builtin_expect((x),1)
625
#define unlikely(x) __builtin_expect((x),0)
629
Only Linux is known to need an explicit sync of the directory to make sure a
630
file creation/deletion/renaming in(from,to) this directory durable.
632
#ifdef TARGET_OS_LINUX
633
#define NEED_EXPLICIT_SYNC_DIR 1
636
/* We need to turn off _DTRACE_VERSION if we're not going to use dtrace */
637
#if !defined(HAVE_DTRACE)
638
# undef _DTRACE_VERSION
639
# define _DTRACE_VERSION 0
642
typedef uint64_t table_map; /* Used for table bits in join */
643
typedef uint32_t nesting_map; /* Used for flags of nesting constructs */
645
} /* namespace drizzled */
571
#define f_packtype(x) (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
572
#define f_settype(x) (((int) x) << FIELDFLAG_PACK_SHIFT)
647
574
#endif /* DRIZZLED_DEFINITIONS_H */