~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definitions.h

  • Committer: Stewart Smith
  • Date: 2008-07-13 06:56:15 UTC
  • mto: (210.1.1 drizzle)
  • mto: This revision was merged to the branch mainline in revision 211.
  • Revision ID: stewart@flamingspork.com-20080713065615-vzok75kgnnviokl9
Move MD5() into a UDF

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
/**
21
 
 * @file
22
 
 *
23
 
 * Mostly constants and some macros/functions used by the server
24
 
 */
25
 
 
26
 
#ifndef DRIZZLED_DEFINITIONS_H
27
 
#define DRIZZLED_DEFINITIONS_H
28
 
 
29
 
#include <drizzled/enum.h>
30
 
 
31
 
#include <stdint.h>
32
 
 
33
 
namespace drizzled
34
 
{
35
 
 
36
 
/* These paths are converted to other systems (WIN95) before use */
37
 
 
38
 
#define LANGUAGE        "english/"
39
 
#define TEMP_PREFIX     "MY"
40
 
#define LOG_PREFIX      "ML"
41
 
 
42
 
#define ER(X) ::drizzled::error_message((X))
43
 
 
44
 
/* extra 4+4 bytes for slave tmp tables */
45
 
#define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
46
 
#define MAX_ALIAS_NAME 256
47
 
#define MAX_FIELD_NAME 34                       /* Max colum name length +2 */
48
 
#define MAX_SYS_VAR_LENGTH 32
49
 
#define MAX_INDEXES 64
50
 
#define MAX_KEY MAX_INDEXES                     /* Max used keys */
51
 
#define MAX_REF_PARTS 16                        /* Max parts used as ref */
52
 
#define MAX_KEY_LENGTH 4096                     /* max possible key */
53
 
#define MAX_KEY_LENGTH_DECIMAL_WIDTH 4          /* strlen("4096") */
54
 
#if SIZEOF_OFF_T > 4
55
 
#define MAX_REFLENGTH 8                         /* Max length for record ref */
56
 
#else
57
 
#define MAX_REFLENGTH 4                         /* Max length for record ref */
58
 
#endif
59
 
#define MAX_HOSTNAME  61                        /* len+1 in mysql.user */
60
 
 
61
 
#define MAX_MBWIDTH             4               /* Max multibyte sequence */
62
 
#define MAX_FIELD_CHARLENGTH    255
63
 
#define MAX_FIELD_VARCHARLENGTH 65535
64
 
#define CONVERT_IF_BIGGER_TO_BLOB 512           /* Used for CREATE ... SELECT */
65
 
 
66
 
/* Max column width +1 */
67
 
#define MAX_FIELD_WIDTH         (MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
68
 
 
69
 
#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
70
 
 
71
 
#define MAX_TABLES      (sizeof(table_map)*8-3) /* Max tables in join */
72
 
#define PARAM_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-3))
73
 
#define OUTER_REF_TABLE_BIT     (((table_map) 1) << (sizeof(table_map)*8-2))
74
 
#define RAND_TABLE_BIT  (((table_map) 1) << (sizeof(table_map)*8-1))
75
 
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
76
 
                           RAND_TABLE_BIT)
77
 
#define MAX_FIELDS      4096      /* Historical limit from MySQL FRM. */
78
 
 
79
 
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
80
 
 
81
 
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
82
 
#define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
83
 
 
84
 
#define DEFAULT_ERROR_COUNT     64
85
 
#define EXTRA_RECORDS   10                      /* Extra records in sort */
86
 
#define NAMES_SEP_CHAR  '\377'                  /* Char to sep. names */
87
 
 
88
 
#define READ_RECORD_BUFFER      (uint32_t) (IO_SIZE*8) /* Pointer_buffer_size */
89
 
#define DISK_BUFFER_SIZE        (uint32_t) (IO_SIZE*16) /* Size of diskbuffer */
90
 
 
91
 
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
92
 
#define MYF_RW MYF(MY_WME+MY_NABP)              /* Vid my_read & my_write */
93
 
 
94
 
/*
95
 
  Minimum length pattern before Turbo Boyer-Moore is used
96
 
  for SELECT "text" LIKE "%pattern%", excluding the two
97
 
  wildcards in class Item_func_like.
98
 
*/
99
 
#define MIN_TURBOBM_PATTERN_LEN 3
100
 
 
101
 
/*
102
 
   Defines for binary logging.
103
 
   Do not decrease the value of BIN_LOG_HEADER_SIZE.
104
 
   Do not even increase it before checking code.
105
 
*/
106
 
 
107
 
#define BIN_LOG_HEADER_SIZE    4
108
 
 
109
 
/* Below are #defines that used to be in mysql_priv.h */
110
 
/***************************************************************************
111
 
  Configuration parameters
112
 
****************************************************************************/
113
 
#define MAX_FIELDS_BEFORE_HASH  32
114
 
#define USER_VARS_HASH_SIZE     16
115
 
#define TABLE_OPEN_CACHE_MIN    64
116
 
#define TABLE_OPEN_CACHE_DEFAULT 1024
117
 
 
118
 
/*
119
 
 Value of 9236 discovered through binary search 2006-09-26 on Ubuntu Dapper
120
 
 Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added
121
 
 100 bytes as reasonable buffer against growth and other environments'
122
 
 requirements.)
123
 
 
124
 
 Feel free to raise this by the smallest amount you can to get the
125
 
 "execution_constants" test to pass.
126
 
 */
127
 
#define STACK_MIN_SIZE          12000   ///< Abort if less stack during eval.
128
 
 
129
 
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
130
 
#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
131
 
 
132
 
#define QUERY_ALLOC_BLOCK_SIZE          8192
133
 
#define QUERY_ALLOC_PREALLOC_SIZE       8192
134
 
#define RANGE_ALLOC_BLOCK_SIZE          4096
135
 
#define TABLE_ALLOC_BLOCK_SIZE          1024
136
 
#define WARN_ALLOC_BLOCK_SIZE           2048
137
 
#define WARN_ALLOC_PREALLOC_SIZE        1024
138
 
 
139
 
/*
140
 
  The following parameters is to decide when to use an extra cache to
141
 
  optimise seeks when reading a big table in sorted order
142
 
*/
143
 
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
144
 
#define MIN_ROWS_TO_USE_TABLE_CACHE      100
145
 
 
146
 
/**
147
 
  The following is used to decide if MySQL should use table scanning
148
 
  instead of reading with keys.  The number says how many evaluation of the
149
 
  WHERE clause is comparable to reading one extra row from a table.
150
 
*/
151
 
#define TIME_FOR_COMPARE   5    // 5 compares == one read
152
 
 
153
 
/**
154
 
  Number of comparisons of table rowids equivalent to reading one row from a
155
 
  table.
156
 
*/
157
 
#define TIME_FOR_COMPARE_ROWID  (TIME_FOR_COMPARE*2)
158
 
 
159
 
/*
160
 
  For sequential disk seeks the cost formula is:
161
 
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip
162
 
 
163
 
  The cost of average seek
164
 
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
165
 
*/
166
 
#define DISK_SEEK_BASE_COST ((double)0.9)
167
 
 
168
 
#define BLOCKS_IN_AVG_SEEK  128
169
 
 
170
 
#define DISK_SEEK_PROP_COST ((double)0.1/BLOCKS_IN_AVG_SEEK)
171
 
 
172
 
 
173
 
/**
174
 
  Number of rows in a reference table when refereed through a not unique key.
175
 
  This value is only used when we don't know anything about the key
176
 
  distribution.
177
 
*/
178
 
#define MATCHING_ROWS_IN_OTHER_TABLE 10
179
 
 
180
 
/** Don't pack string keys shorter than this (if PACK_KEYS=1 isn't used). */
181
 
#define KEY_DEFAULT_PACK_LENGTH 8
182
 
 
183
 
/** Characters shown for the command in 'show processlist'. */
184
 
#define PROCESS_LIST_WIDTH 100
185
 
/* Characters shown for the command in 'information_schema.processlist' */
186
 
#define PROCESS_LIST_INFO_WIDTH 65535
187
 
 
188
 
#define PRECISION_FOR_DOUBLE 53
189
 
#define PRECISION_FOR_FLOAT  24
190
 
 
191
 
/* The following can also be changed from the command line */
192
 
#define DEFAULT_CONCURRENCY     10
193
 
#define FLUSH_TIME              0               /**< Don't flush tables */
194
 
#define MAX_CONNECT_ERRORS      10              ///< errors before disabling host
195
 
 
196
 
#define INTERRUPT_PRIOR 10
197
 
#define CONNECT_PRIOR   9
198
 
#define WAIT_PRIOR      8
199
 
#define QUERY_PRIOR     6
200
 
 
201
 
/* Bits from testflag */
202
 
enum test_flag_bit
203
 
{
204
 
  TEST_PRINT_CACHED_TABLES= 1,
205
 
  TEST_NO_KEY_GROUP,
206
 
  TEST_MIT_THREAD,
207
 
  TEST_KEEP_TMP_TABLES,
208
 
  TEST_READCHECK, /**< Force use of readcheck */
209
 
  TEST_NO_EXTRA,
210
 
  TEST_CORE_ON_SIGNAL, /**< Give core if signal */
211
 
  TEST_NO_STACKTRACE,
212
 
  TEST_SIGINT, /**< Allow sigint on threads */
213
 
  TEST_SYNCHRONIZATION /**< get server to do sleep in some places */
214
 
};
215
 
 
216
 
/* Bits for different SQL modes modes (including ANSI mode) */
217
 
#define MODE_NO_ZERO_DATE               (2)
218
 
#define MODE_INVALID_DATES              (MODE_NO_ZERO_DATE*2)
219
 
 
220
 
#define MY_CHARSET_BIN_MB_MAXLEN 1
221
 
 
222
 
// uncachable cause
223
 
#define UNCACHEABLE_DEPENDENT   1
224
 
#define UNCACHEABLE_RAND        2
225
 
#define UNCACHEABLE_SIDEEFFECT  4
226
 
/// forcing to save JOIN for explain
227
 
#define UNCACHEABLE_EXPLAIN     8
228
 
/** Don't evaluate subqueries in prepare even if they're not correlated */
229
 
#define UNCACHEABLE_PREPARE    16
230
 
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
231
 
#define UNCACHEABLE_UNITED     32
232
 
 
233
 
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
234
 
#define UNDEF_POS (-1)
235
 
 
236
 
/* Options to add_table_to_list() */
237
 
#define TL_OPTION_UPDATING      1
238
 
#define TL_OPTION_FORCE_INDEX   2
239
 
#define TL_OPTION_IGNORE_LEAVES 4
240
 
#define TL_OPTION_ALIAS         8
241
 
 
242
 
/* Some portable defines */
243
 
 
244
 
#define portable_sizeof_char_ptr 8
245
 
 
246
 
#define TMP_FILE_PREFIX "#sql"                  /**< Prefix for tmp tables */
247
 
#define TMP_FILE_PREFIX_LENGTH 4
248
 
 
249
 
/* Flags for calc_week() function.  */
250
 
#define WEEK_MONDAY_FIRST    1
251
 
#define WEEK_YEAR            2
252
 
#define WEEK_FIRST_WEEKDAY   4
253
 
 
254
 
/* used in date and time conversions */
255
 
/* Daynumber from year 0 to 9999-12-31 */
256
 
#define MAX_DAY_NUMBER 3652424L
257
 
 
258
 
#define STRING_BUFFER_USUAL_SIZE 80
259
 
 
260
 
typedef void *range_seq_t;
261
 
 
262
 
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
263
 
// the following is for checking tables
264
 
 
265
 
#define HA_ADMIN_ALREADY_DONE     1
266
 
#define HA_ADMIN_OK               0
267
 
#define HA_ADMIN_NOT_IMPLEMENTED -1
268
 
#define HA_ADMIN_FAILED          -2
269
 
#define HA_ADMIN_CORRUPT         -3
270
 
#define HA_ADMIN_INTERNAL_ERROR  -4
271
 
#define HA_ADMIN_INVALID         -5
272
 
#define HA_ADMIN_REJECT          -6
273
 
 
274
 
/* bits in index_flags(index_number) for what you can do with index */
275
 
#define HA_READ_NEXT            1       /* TODO really use this flag */
276
 
#define HA_READ_PREV            2       /* supports ::index_prev */
277
 
#define HA_READ_ORDER           4       /* index_next/prev follow sort order */
278
 
#define HA_READ_RANGE           8       /* can find all records in a range */
279
 
#define HA_ONLY_WHOLE_INDEX     16      /* Can't use part key searches */
280
 
#define HA_KEYREAD_ONLY         64      /* Support HA_EXTRA_KEYREAD */
281
 
/*
282
 
  Index scan will not return records in rowid order. Not guaranteed to be
283
 
  set for unordered (e.g. HASH) indexes.
284
 
*/
285
 
#define HA_KEY_SCAN_NOT_ROR     128
286
 
 
287
 
/* operations for disable/enable indexes */
288
 
#define HA_KEY_SWITCH_NONUNIQ      0
289
 
#define HA_KEY_SWITCH_ALL          1
290
 
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
291
 
#define HA_KEY_SWITCH_ALL_SAVE     3
292
 
 
293
 
/*
294
 
  Note: the following includes binlog and closing 0.
295
 
  so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
296
 
      example + csv + heap + blackhole + federated + 0
297
 
  (yes, the sum is deliberately inaccurate)
298
 
  TODO remove the limit, use dynarrays
299
 
*/
300
 
#define MAX_HA 15
301
 
 
302
 
/*
303
 
  Parameters for open() (in register form->filestat)
304
 
  HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
305
 
*/
306
 
 
307
 
#define HA_OPEN_KEYFILE         1
308
 
#define HA_OPEN_RNDFILE         2
309
 
#define HA_GET_INDEX            4
310
 
#define HA_GET_INFO             8       /* do a ha_info() after open */
311
 
#define HA_READ_ONLY            16      /* File opened as readonly */
312
 
/* Try readonly if can't open with read and write */
313
 
#define HA_TRY_READ_ONLY        32
314
 
#define HA_WAIT_IF_LOCKED       64      /* Wait if locked on open */
315
 
#define HA_ABORT_IF_LOCKED      128     /* skip if locked on open.*/
316
 
#define HA_BLOCK_LOCK           256     /* unlock when reading some records */
317
 
#define HA_OPEN_TEMPORARY       512
318
 
 
319
 
/* For transactional LOCK Table. handler::lock_table() */
320
 
#define HA_LOCK_IN_SHARE_MODE      F_RDLCK
321
 
#define HA_LOCK_IN_EXCLUSIVE_MODE  F_WRLCK
322
 
 
323
 
/* Some key definitions */
324
 
#define HA_KEY_NULL_LENGTH      1
325
 
#define HA_KEY_BLOB_LENGTH      2
326
 
 
327
 
#define HA_MAX_REC_LENGTH       65535
328
 
 
329
 
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
330
 
enum start_transaction_option_t
331
 
{
332
 
  START_TRANS_NO_OPTIONS,
333
 
  START_TRANS_OPT_WITH_CONS_SNAPSHOT
334
 
};
335
 
 
336
 
/* Flags for method is_fatal_error */
337
 
#define HA_CHECK_DUP_KEY 1
338
 
#define HA_CHECK_DUP_UNIQUE 2
339
 
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
340
 
 
341
 
 
342
 
/* Bits in used_fields */
343
 
#define HA_CREATE_USED_AUTO             (1L << 0)
344
 
#define HA_CREATE_USED_CHARSET          (1L << 8)
345
 
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
346
 
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
347
 
#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)
348
 
#define HA_CREATE_USED_BLOCK_SIZE       (1L << 22)
349
 
 
350
 
/*
351
 
  The below two are not used (and not handled) in this milestone of this WL
352
 
  entry because there seems to be no use for them at this stage of
353
 
  implementation.
354
 
*/
355
 
#define HA_MRR_SINGLE_POINT 1
356
 
#define HA_MRR_FIXED_KEY  2
357
 
 
358
 
/*
359
 
  Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
360
 
  'range' parameter.
361
 
*/
362
 
#define HA_MRR_NO_ASSOCIATION 4
363
 
 
364
 
/*
365
 
  The MRR user will provide ranges in key order, and MRR implementation
366
 
  must return rows in key order.
367
 
*/
368
 
#define HA_MRR_SORTED 8
369
 
 
370
 
/* MRR implementation doesn't have to retrieve full records */
371
 
#define HA_MRR_INDEX_ONLY 16
372
 
 
373
 
/*
374
 
  The passed memory buffer is of maximum possible size, the caller can't
375
 
  assume larger buffer.
376
 
*/
377
 
#define HA_MRR_LIMITS 32
378
 
 
379
 
 
380
 
/*
381
 
  Flag set <=> default MRR implementation is used
382
 
  (The choice is made by **_info[_const]() function which may set this
383
 
   flag. SQL layer remembers the flag value and then passes it to
384
 
   multi_read_range_init().
385
 
*/
386
 
#define HA_MRR_USE_DEFAULT_IMPL 64
387
 
 
388
 
typedef int myf;
389
 
#define MYF(v)          (static_cast<drizzled::myf>(v))
390
 
 
391
 
/*
392
 
   "Declared Type Collation"
393
 
   A combination of collation and its derivation.
394
 
 
395
 
  Flags for collation aggregation modes:
396
 
  MY_COLL_ALLOW_SUPERSET_CONV  - allow conversion to a superset
397
 
  MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
398
 
                                 (i.e. constant).
399
 
  MY_COLL_ALLOW_CONV           - allow any kind of conversion
400
 
                                 (combination of the above two)
401
 
  MY_COLL_DISALLOW_NONE        - don't allow return DERIVATION_NONE
402
 
                                 (e.g. when aggregating for comparison)
403
 
  MY_COLL_CMP_CONV             - combination of MY_COLL_ALLOW_CONV
404
 
                                 and MY_COLL_DISALLOW_NONE
405
 
*/
406
 
 
407
 
#define MY_COLL_ALLOW_SUPERSET_CONV   1
408
 
#define MY_COLL_ALLOW_COERCIBLE_CONV  2
409
 
#define MY_COLL_ALLOW_CONV            3
410
 
#define MY_COLL_DISALLOW_NONE         4
411
 
#define MY_COLL_CMP_CONV              7
412
 
#define clear_timestamp_auto_bits(_target_, _bits_) \
413
 
  (_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
414
 
 
415
 
/*
416
 
 * The following are for the interface with the .frm file
417
 
 */
418
 
 
419
 
#define FIELDFLAG_PACK_SHIFT    3
420
 
#define FIELDFLAG_MAX_DEC    31
421
 
 
422
 
#define MTYP_TYPENR(type) (type & 127)  /* Remove bits from type */
423
 
 
424
 
#define f_settype(x)    (((int) x) << FIELDFLAG_PACK_SHIFT)
425
 
 
426
 
 
427
 
#ifdef __cplusplus
428
 
template <class T> void set_if_bigger(T &a, const T &b)
429
 
{
430
 
  if (a < b)
431
 
    a=b;
432
 
}
433
 
 
434
 
template <class T> void set_if_smaller(T &a, const T &b)
435
 
{
436
 
  if (a > b)
437
 
    a=b;
438
 
}
439
 
#else
440
 
#ifdef __GNUC__
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);                       \
446
 
  } while(0)
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);                       \
452
 
  } while(0)
453
 
 
454
 
#else
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)
457
 
#endif
458
 
#endif
459
 
 
460
 
 
461
 
#define array_elements(a) \
462
 
  ((sizeof(a) / sizeof(*(a))) / \
463
 
   static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
464
 
 
465
 
 
466
 
/* Some types that is different between systems */
467
 
 
468
 
#ifndef FN_LIBCHAR
469
 
#define FN_LIBCHAR  '/'
470
 
#define FN_ROOTDIR  "/"
471
 
#endif
472
 
#define MY_NFILE  64  /* This is only used to save filenames */
473
 
#ifndef OS_FILE_LIMIT
474
 
#define OS_FILE_LIMIT  65535
475
 
#endif
476
 
 
477
 
/*
478
 
  How much overhead does malloc have. The code often allocates
479
 
  something like 1024-MALLOC_OVERHEAD bytes
480
 
*/
481
 
#define MALLOC_OVERHEAD 8
482
 
 
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;
489
 
 
490
 
/* Default size of a key cache block  */
491
 
static const uint32_t KEY_CACHE_BLOCK_SIZE= 1024;
492
 
 
493
 
 
494
 
/* Some things that this system doesn't have */
495
 
 
496
 
/* Some defines of functions for portability */
497
 
 
498
 
#ifndef uint64_t2double
499
 
#define uint64_t2double(A) ((double) (uint64_t) (A))
500
 
#endif
501
 
 
502
 
#ifndef offsetof
503
 
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
504
 
#endif
505
 
#define ulong_to_double(X) ((double) (ulong) (X))
506
 
 
507
 
/* From limits.h instead */
508
 
#ifndef DBL_MIN
509
 
#define DBL_MIN    4.94065645841246544e-324
510
 
#endif
511
 
#ifndef DBL_MAX
512
 
#define DBL_MAX    1.79769313486231470e+308
513
 
#endif
514
 
 
515
 
 
516
 
/* Define missing math constants. */
517
 
#ifndef M_PI
518
 
#define M_PI 3.14159265358979323846
519
 
#endif
520
 
#ifndef M_E
521
 
#define M_E 2.7182818284590452354
522
 
#endif
523
 
#ifndef M_LN2
524
 
#define M_LN2 0.69314718055994530942
525
 
#endif
526
 
 
527
 
/*
528
 
  Max size that must be added to a so that we know Size to make
529
 
  adressable obj.
530
 
*/
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)
537
 
#ifdef __cplusplus
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))
540
 
#else
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))
543
 
#endif
544
 
 
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))]
547
 
 
548
 
/* Typdefs for easyier portability */
549
 
 
550
 
 
551
 
#if defined(SIZEOF_OFF_T)
552
 
# if (SIZEOF_OFF_T == 8)
553
 
#  define OFF_T_MAX (INT64_MAX)
554
 
# else
555
 
#  define OFF_T_MAX (INT32_MAX)
556
 
# endif
557
 
#endif
558
 
 
559
 
#define MY_FILEPOS_ERROR  -1
560
 
 
561
 
#define DRIZZLE_SERVER
562
 
 
563
 
/* Length of decimal number represented by INT32. */
564
 
#define MY_INT32_NUM_DECIMAL_DIGITS 11
565
 
 
566
 
/* Length of decimal number represented by INT64. */
567
 
#define MY_INT64_NUM_DECIMAL_DIGITS 21
568
 
 
569
 
/*
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.
574
 
*/
575
 
#define IO_SIZE 4096
576
 
/* Max file name len */
577
 
#define FN_LEN 256
578
 
/* Max length of extension (part of FN_LEN) */
579
 
#define FN_EXTLEN 20
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 ".."
590
 
 
591
 
/* Quote argument (before cpp) */
592
 
#ifndef QUOTE_ARG
593
 
# define QUOTE_ARG(x) #x
594
 
#endif
595
 
/* Quote argument, (after cpp) */
596
 
#ifndef STRINGIFY_ARG
597
 
# define STRINGIFY_ARG(x) QUOTE_ARG(x)
598
 
#endif
599
 
 
600
 
/*
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
607
 
 */
608
 
#if !defined(__GNUC__)
609
 
#define __builtin_expect(x, expected_value) (x)
610
 
#endif
611
 
 
612
 
#define likely(x)  __builtin_expect((x),1)
613
 
#define unlikely(x)  __builtin_expect((x),0)
614
 
 
615
 
 
616
 
/*
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.
619
 
*/
620
 
#ifdef TARGET_OS_LINUX
621
 
#define NEED_EXPLICIT_SYNC_DIR 1
622
 
#endif
623
 
 
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
628
 
#endif
629
 
 
630
 
} /* namespace drizzled */
631
 
 
632
 
#endif /* DRIZZLED_DEFINITIONS_H */