Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00026 #pragma once
00027
00028 #include <drizzled/enum.h>
00029
00030 #include <stdint.h>
00031
00032 #include "common.h"
00033
00034 namespace drizzled
00035 {
00036
00037
00038 #define GLOBAL_TEMPORARY_EXT ".temporary"
00039
00040
00041
00042 #define LANGUAGE "english/"
00043 #define TEMP_PREFIX "MY"
00044
00045 #define ER(X) ::drizzled::error_message((X))
00046
00047
00048 #define STRERROR_MAX 256
00049
00050
00051 #define MAX_FIELD_NAME 34
00052 #define MAX_SYS_VAR_LENGTH 32
00053 #define MAX_INDEXES 64
00054 const uint32_t MAX_KEY = MAX_INDEXES;
00055 const uint32_t MAX_REF_PARTS = 16;
00056 const uint32_t MAX_KEY_LENGTH = 4096;
00057 const uint32_t MAX_KEY_LENGTH_DECIMAL_WIDTH = 4;
00058
00059 #if SIZEOF_OFF_T > 4
00060 #define MAX_REFLENGTH 8
00061 #else
00062 #define MAX_REFLENGTH 4
00063 #endif
00064
00065 #define MAX_MBWIDTH 4
00066 #define MAX_FIELD_CHARLENGTH 255
00067 #define MAX_FIELD_VARCHARLENGTH 65535
00068 #define CONVERT_IF_BIGGER_TO_BLOB 512
00069
00070
00071 #define MAX_FIELD_WIDTH (MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
00072
00073 #define MAX_TABLES (sizeof(table_map)*8-3)
00074 #define PARAM_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-3))
00075 #define OUTER_REF_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-2))
00076 #define RAND_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-1))
00077 #define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
00078 RAND_TABLE_BIT)
00079 #define MAX_FIELDS 4096
00080
00081 #define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
00082
00083 #define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
00084 #define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
00085
00086 #define DEFAULT_ERROR_COUNT 64
00087 #define EXTRA_RECORDS 10
00088 #define NAMES_SEP_CHAR '\377'
00089
00090 #define READ_RECORD_BUFFER (uint32_t) (IO_SIZE*8)
00091 #define DISK_BUFFER_SIZE (uint32_t) (IO_SIZE*16)
00092
00093 #define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
00094 #define MYF_RW MYF(MY_WME+MY_NABP)
00095
00096
00097
00098
00099
00100
00101 #define MIN_TURBOBM_PATTERN_LEN 3
00102
00103
00104
00105
00106
00107 #define MAX_FIELDS_BEFORE_HASH 32
00108 #define TABLE_OPEN_CACHE_MIN 64
00109 #define TABLE_OPEN_CACHE_DEFAULT 1024
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 #define STACK_MIN_SIZE 12000 ///< Abort if less stack during eval.
00121
00122 #define STACK_MIN_SIZE_FOR_OPEN 1024*80
00123 #define STACK_BUFF_ALLOC 352 ///< For stack overrun checks
00124
00125 #define QUERY_ALLOC_BLOCK_SIZE 8192
00126 #define QUERY_ALLOC_PREALLOC_SIZE 8192
00127 #define RANGE_ALLOC_BLOCK_SIZE 4096
00128 #define TABLE_ALLOC_BLOCK_SIZE 1024
00129 #define WARN_ALLOC_BLOCK_SIZE 2048
00130 #define WARN_ALLOC_PREALLOC_SIZE 1024
00131
00132
00133
00134
00135
00136 #define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
00137 #define MIN_ROWS_TO_USE_TABLE_CACHE 100
00138
00144 #define TIME_FOR_COMPARE 5 // 5 compares == one read
00145
00150 #define TIME_FOR_COMPARE_ROWID (TIME_FOR_COMPARE*2)
00151
00152
00153
00154
00155
00156
00157
00158
00159 #define DISK_SEEK_BASE_COST ((double)0.9)
00160
00161 #define BLOCKS_IN_AVG_SEEK 128
00162
00163 #define DISK_SEEK_PROP_COST ((double)0.1/BLOCKS_IN_AVG_SEEK)
00164
00165
00171 #define MATCHING_ROWS_IN_OTHER_TABLE 10
00172
00174 #define KEY_DEFAULT_PACK_LENGTH 8
00175
00177 #define PROCESS_LIST_WIDTH 100
00178
00179
00180 #define MODE_NO_ZERO_DATE (2)
00181 #define MODE_INVALID_DATES (MODE_NO_ZERO_DATE*2)
00182
00183 #define MY_CHARSET_BIN_MB_MAXLEN 1
00184
00185
00186 static const uint32_t UNCACHEABLE_DEPENDENT= 1;
00187 static const uint32_t UNCACHEABLE_RAND= 2;
00188 static const uint32_t UNCACHEABLE_SIDEEFFECT= 3;
00190 static const uint32_t UNCACHEABLE_EXPLAIN= 4;
00192 static const uint32_t UNCACHEABLE_PREPARE= 5;
00193
00194 static const uint32_t UNCACHEABLE_UNITED= 6;
00195
00196
00197 #define UNDEF_POS (-1)
00198
00199
00200 static const uint32_t TL_OPTION_UPDATING= 0;
00201 static const uint32_t TL_OPTION_FORCE_INDEX= 1;
00202 static const uint32_t TL_OPTION_IGNORE_LEAVES= 2;
00203 static const uint32_t TL_OPTION_ALIAS= 3;
00204 static const uint32_t NUM_OF_TABLE_OPTIONS= 4;
00205
00206
00207
00208 #define portable_sizeof_char_ptr 8
00209
00210 #define TMP_FILE_PREFIX "#sql"
00211 #define TMP_FILE_PREFIX_LENGTH 4
00212
00213
00214 #define WEEK_MONDAY_FIRST 1
00215 #define WEEK_YEAR 2
00216 #define WEEK_FIRST_WEEKDAY 4
00217
00218
00219
00220 #define MAX_DAY_NUMBER 3652424L
00221
00222 #define STRING_BUFFER_USUAL_SIZE 80
00223
00224 typedef void *range_seq_t;
00225
00226 enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
00227
00228
00229 #define HA_ADMIN_ALREADY_DONE 1
00230 #define HA_ADMIN_OK 0
00231 #define HA_ADMIN_NOT_IMPLEMENTED -1
00232 #define HA_ADMIN_FAILED -2
00233 #define HA_ADMIN_CORRUPT -3
00234 #define HA_ADMIN_INTERNAL_ERROR -4
00235 #define HA_ADMIN_INVALID -5
00236 #define HA_ADMIN_REJECT -6
00237
00238
00239 #define HA_READ_NEXT 1
00240 #define HA_READ_PREV 2
00241 #define HA_READ_ORDER 4
00242 #define HA_READ_RANGE 8
00243 #define HA_ONLY_WHOLE_INDEX 16
00244 #define HA_KEYREAD_ONLY 64
00245
00246
00247
00248
00249 #define HA_KEY_SCAN_NOT_ROR 128
00250
00251
00252 #define HA_KEY_SWITCH_NONUNIQ 0
00253 #define HA_KEY_SWITCH_ALL 1
00254 #define HA_KEY_SWITCH_NONUNIQ_SAVE 2
00255 #define HA_KEY_SWITCH_ALL_SAVE 3
00256
00257
00258
00259
00260
00261
00262 #define HA_OPEN_KEYFILE 1
00263 #define HA_OPEN_RNDFILE 2
00264 #define HA_GET_INDEX 4
00265 #define HA_GET_INFO 8
00266 #define HA_READ_ONLY 16
00267
00268 #define HA_TRY_READ_ONLY 32
00269 #define HA_WAIT_IF_LOCKED 64
00270 #define HA_ABORT_IF_LOCKED 128
00271 #define HA_BLOCK_LOCK 256
00272 #define HA_OPEN_TEMPORARY 512
00273
00274
00275 #define HA_KEY_NULL_LENGTH 1
00276 #define HA_KEY_BLOB_LENGTH 2
00277
00278 const uint32_t HA_MAX_REC_LENGTH = 65535;
00279
00280
00281 enum start_transaction_option_t
00282 {
00283 START_TRANS_NO_OPTIONS,
00284 START_TRANS_OPT_WITH_CONS_SNAPSHOT
00285 };
00286
00287
00288 #define HA_CHECK_DUP_KEY 1
00289 #define HA_CHECK_DUP_UNIQUE 2
00290 #define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
00291
00292
00293
00294 #define HA_CREATE_USED_AUTO (1L << 0)
00295 #define HA_CREATE_USED_CHARSET (1L << 8)
00296 #define HA_CREATE_USED_DEFAULT_CHARSET (1L << 9)
00297
00298
00299
00300
00301
00302
00303 #define HA_MRR_SINGLE_POINT 1
00304 #define HA_MRR_FIXED_KEY 2
00305
00306
00307
00308
00309
00310 #define HA_MRR_NO_ASSOCIATION 4
00311
00312
00313
00314
00315
00316 #define HA_MRR_SORTED 8
00317
00318
00319 #define HA_MRR_INDEX_ONLY 16
00320
00321
00322
00323
00324
00325 #define HA_MRR_LIMITS 32
00326
00327
00328
00329
00330
00331
00332
00333
00334 #define HA_MRR_USE_DEFAULT_IMPL 64
00335
00336 typedef int myf;
00337 #define MYF(v) (static_cast<drizzled::myf>(v))
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355 #define MY_COLL_ALLOW_SUPERSET_CONV 1
00356 #define MY_COLL_ALLOW_COERCIBLE_CONV 2
00357 #define MY_COLL_ALLOW_CONV 3
00358 #define MY_COLL_DISALLOW_NONE 4
00359 #define MY_COLL_CMP_CONV 7
00360
00361 inline static void clear_timestamp_auto_bits(timestamp_auto_set_type &_target_,
00362 timestamp_auto_set_type _bits_)
00363 {
00364 _target_= static_cast<timestamp_auto_set_type>(_target_ & ~_bits_);
00365 }
00366
00367
00368
00369
00370
00371 #define FIELDFLAG_PACK_SHIFT 3
00372 #define FIELDFLAG_MAX_DEC 31
00373
00374 #ifdef __cplusplus
00375
00376
00377
00378 template <typename T>
00379 T MTYP_TYPENR(const T& type)
00380 {
00381 return static_cast<T>(type & 127);
00382 }
00383 #else
00384 #define MTYP_TYPENR(type) (type & 127)
00385 #endif
00386
00387 inline static uint32_t f_settype(const enum enum_field_types x)
00388 {
00389 return (uint32_t(x) << FIELDFLAG_PACK_SHIFT);
00390 }
00391
00392 #ifdef __cplusplus
00393 template <class T> void set_if_bigger(T &a, const T &b)
00394 {
00395 if (a < b)
00396 a=b;
00397 }
00398
00399 template <class T> void set_if_smaller(T &a, const T &b)
00400 {
00401 if (a > b)
00402 a=b;
00403 }
00404 #else
00405 #ifdef __GNUC__
00406 #define set_if_bigger(a,b) do { \
00407 const typeof(a) _a = (a); \
00408 const typeof(b) _b = (b); \
00409 (void) (&_a == &_b); \
00410 if ((a) < (b)) (a)=(b); \
00411 } while(0)
00412 #define set_if_smaller(a,b) do { \
00413 const typeof(a) _a = (a); \
00414 const typeof(b) _b = (b); \
00415 (void) (&_a == &_b); \
00416 if ((a) > (b)) (a)=(b); \
00417 } while(0)
00418
00419 #else
00420 #define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
00421 #define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
00422 #endif
00423 #endif
00424
00425 template<class T> inline void safe_delete(T*& ptr)
00426 {
00427 delete ptr;
00428 ptr = 0;
00429 }
00430
00431 #define array_elements(a) \
00432 ((sizeof(a) / sizeof(*(a))) / \
00433 static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
00434
00435 #define FN_LIBCHAR '/'
00436
00437
00438
00439
00440
00441 #define MALLOC_OVERHEAD 8
00442
00443
00444 static const uint32_t ONCE_ALLOC_INIT= 4096;
00445
00446 static const uint32_t RECORD_CACHE_SIZE= 64*1024;
00447
00448
00449
00450
00451
00452
00453 #ifndef uint64_t2double
00454 #define uint64_t2double(A) ((double) (uint64_t) (A))
00455 #endif
00456
00457 #ifndef int64_t2double
00458 #define int64_t2double(A) ((double) (int64_t) (A))
00459 #endif
00460
00461 #ifndef offsetof
00462 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
00463 #endif
00464
00465
00466 #ifndef DBL_MIN
00467 #define DBL_MIN 4.94065645841246544e-324
00468 #endif
00469 #ifndef DBL_MAX
00470 #define DBL_MAX 1.79769313486231470e+308
00471 #endif
00472
00473
00474
00475 #ifndef M_PI
00476 #define M_PI 3.14159265358979323846
00477 #endif
00478 #ifndef M_E
00479 #define M_E 2.7182818284590452354
00480 #endif
00481 #ifndef M_LN2
00482 #define M_LN2 0.69314718055994530942
00483 #endif
00484
00485
00486
00487
00488
00489 #define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
00490 #define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
00491 #ifdef __cplusplus
00492 #define ADD_TO_PTR(ptr,size,type) (type) (reinterpret_cast<const unsigned char*>(ptr)+size)
00493 #else
00494 #define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
00495 #endif
00496
00497 #define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
00498 #define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
00499
00500
00501
00502
00503 #if defined(SIZEOF_OFF_T)
00504 # if (SIZEOF_OFF_T == 8)
00505 # define OFF_T_MAX (INT64_MAX)
00506 # else
00507 # define OFF_T_MAX (INT32_MAX)
00508 # endif
00509 #endif
00510
00511 #define MY_FILEPOS_ERROR -1
00512
00513 #define DRIZZLE_SERVER
00514
00515
00516 #define MY_INT32_NUM_DECIMAL_DIGITS 11
00517
00518
00519 #define MY_INT64_NUM_DECIMAL_DIGITS 21
00520
00521
00522
00523
00524
00525
00526
00527 #define IO_SIZE 4096
00528
00529 #define FN_LEN 256
00530
00531 #define FN_REFLEN 512
00532
00533 #define FN_EXTCHAR '.'
00534
00535 #define FN_HOMELIB '~'
00536
00537 #define FN_CURLIB '.'
00538
00539 #define FN_PARENTDIR ".."
00540
00541
00542 #ifndef QUOTE_ARG
00543 # define QUOTE_ARG(x) #x
00544 #endif
00545
00546 #ifndef STRINGIFY_ARG
00547 # define STRINGIFY_ARG(x) QUOTE_ARG(x)
00548 #endif
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558 #if !defined(__GNUC__)
00559 #define __builtin_expect(x, expected_value) (x)
00560 #endif
00561
00562 #define likely(x) __builtin_expect((x),1)
00563 #define unlikely(x) __builtin_expect((x),0)
00564
00565
00566
00567
00568
00569
00570 #ifdef TARGET_OS_LINUX
00571 #define NEED_EXPLICIT_SYNC_DIR 1
00572 #endif
00573
00574
00575 #if !defined(HAVE_DTRACE)
00576 # undef _DTRACE_VERSION
00577 # define _DTRACE_VERSION 0
00578 #endif
00579
00580 typedef uint64_t table_map;
00581 typedef uint32_t nesting_map;
00582
00583 }
00584