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
00436
00437
00438 #ifndef FN_LIBCHAR
00439 #define FN_LIBCHAR '/'
00440 #define FN_ROOTDIR "/"
00441 #endif
00442 #define MY_NFILE 64
00443 #ifndef OS_FILE_LIMIT
00444 #define OS_FILE_LIMIT 65535
00445 #endif
00446
00447
00448
00449
00450
00451 #define MALLOC_OVERHEAD 8
00452
00453
00454 static const uint32_t ONCE_ALLOC_INIT= 4096;
00455
00456 static const uint32_t RECORD_CACHE_SIZE= 64*1024;
00457
00458
00459
00460
00461
00462
00463 #ifndef uint64_t2double
00464 #define uint64_t2double(A) ((double) (uint64_t) (A))
00465 #endif
00466
00467 #ifndef int64_t2double
00468 #define int64_t2double(A) ((double) (int64_t) (A))
00469 #endif
00470
00471 #ifndef offsetof
00472 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
00473 #endif
00474
00475
00476 #ifndef DBL_MIN
00477 #define DBL_MIN 4.94065645841246544e-324
00478 #endif
00479 #ifndef DBL_MAX
00480 #define DBL_MAX 1.79769313486231470e+308
00481 #endif
00482
00483
00484
00485 #ifndef M_PI
00486 #define M_PI 3.14159265358979323846
00487 #endif
00488 #ifndef M_E
00489 #define M_E 2.7182818284590452354
00490 #endif
00491 #ifndef M_LN2
00492 #define M_LN2 0.69314718055994530942
00493 #endif
00494
00495
00496
00497
00498
00499 #define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
00500 #define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
00501 #ifdef __cplusplus
00502 #define ADD_TO_PTR(ptr,size,type) (type) (reinterpret_cast<const unsigned char*>(ptr)+size)
00503 #else
00504 #define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
00505 #endif
00506
00507 #define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
00508 #define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
00509
00510
00511
00512
00513 #if defined(SIZEOF_OFF_T)
00514 # if (SIZEOF_OFF_T == 8)
00515 # define OFF_T_MAX (INT64_MAX)
00516 # else
00517 # define OFF_T_MAX (INT32_MAX)
00518 # endif
00519 #endif
00520
00521 #define MY_FILEPOS_ERROR -1
00522
00523 #define DRIZZLE_SERVER
00524
00525
00526 #define MY_INT32_NUM_DECIMAL_DIGITS 11
00527
00528
00529 #define MY_INT64_NUM_DECIMAL_DIGITS 21
00530
00531
00532
00533
00534
00535
00536
00537 #define IO_SIZE 4096
00538
00539 #define FN_LEN 256
00540
00541 #define FN_REFLEN 512
00542
00543 #define FN_EXTCHAR '.'
00544
00545 #define FN_HOMELIB '~'
00546
00547 #define FN_CURLIB '.'
00548
00549 #define FN_PARENTDIR ".."
00550
00551
00552 #ifndef QUOTE_ARG
00553 # define QUOTE_ARG(x) #x
00554 #endif
00555
00556 #ifndef STRINGIFY_ARG
00557 # define STRINGIFY_ARG(x) QUOTE_ARG(x)
00558 #endif
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568 #if !defined(__GNUC__)
00569 #define __builtin_expect(x, expected_value) (x)
00570 #endif
00571
00572 #define likely(x) __builtin_expect((x),1)
00573 #define unlikely(x) __builtin_expect((x),0)
00574
00575
00576
00577
00578
00579
00580 #ifdef TARGET_OS_LINUX
00581 #define NEED_EXPLICIT_SYNC_DIR 1
00582 #endif
00583
00584
00585 #if !defined(HAVE_DTRACE)
00586 # undef _DTRACE_VERSION
00587 # define _DTRACE_VERSION 0
00588 #endif
00589
00590 typedef uint64_t table_map;
00591 typedef uint32_t nesting_map;
00592
00593 }
00594