~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definitions.h

  • Committer: Jay Pipes
  • Date: 2009-11-16 22:00:02 UTC
  • mto: (1234.1.1 push) (1237.2.10 push)
  • mto: This revision was merged to the branch mainline in revision 1229.
  • Revision ID: jpipes@serialcoder-20091116220002-rdsha64utt41i8w8
Adds INFORMATION_SCHEMA views for the transaction log:

TRANSACTION_LOG
TRANSACTION_LOG_ENTRIES
TRANSACTION_LOG_TRANSACTIONS

Adds a new user-defined function:

PRINT_TRANSACTION_MESSAGE(filename, offset)

Adds tests for all of the above

Implementation notes:

An indexer now runs when transaction messages are applied
to the transaction log.  It creates a simple index of the
transaction log entries.  This index is used when the
information schema views' fillTable() method is called.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
#include <stdint.h>
32
32
 
33
 
#include "common.h"
34
 
 
35
 
namespace drizzled
36
 
{
37
 
 
38
 
/* Global value for how we extend our temporary directory */
39
 
#define GLOBAL_TEMPORARY_EXT ".temporary"
40
 
 
41
33
/* These paths are converted to other systems (WIN95) before use */
42
34
 
43
35
#define LANGUAGE        "english/"
44
36
#define TEMP_PREFIX     "MY"
45
37
#define LOG_PREFIX      "ML"
46
 
 
47
 
#define ER(X) ::drizzled::error_message((X))
48
 
 
49
 
/* buffer size for strerror_r() */
50
 
#define STRERROR_MAX 256
51
 
 
 
38
#define PROGDIR         "bin/"
 
39
 
 
40
#define ER(X) error_message((X))
 
41
 
 
42
#define LIBLEN FN_REFLEN-FN_LEN                 /* Max l{ngd p} dev */
52
43
/* extra 4+4 bytes for slave tmp tables */
53
44
#define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
54
45
#define MAX_ALIAS_NAME 256
55
46
#define MAX_FIELD_NAME 34                       /* Max colum name length +2 */
56
47
#define MAX_SYS_VAR_LENGTH 32
57
 
#define MAX_INDEXES 64
58
48
#define MAX_KEY MAX_INDEXES                     /* Max used keys */
59
49
#define MAX_REF_PARTS 16                        /* Max parts used as ref */
60
50
#define MAX_KEY_LENGTH 4096                     /* max possible key */
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 | \
84
74
                           RAND_TABLE_BIT)
85
 
#define MAX_FIELDS      4096      /* Historical limit from MySQL FRM. */
 
75
#define MAX_FIELDS      4096                    /* Limit in the .frm file */
86
76
 
87
77
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
88
78
 
89
79
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
90
80
#define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
91
81
 
 
82
/* Memory allocated when parsing a statement / saving a statement */
 
83
#define MEM_ROOT_BLOCK_SIZE       8192
 
84
#define MEM_ROOT_PREALLOC         8192
 
85
 
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 */
95
94
 
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
97
 
 
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 */
101
101
 
 
102
        /* Defines for use with openfrm, openprt and openfrd */
 
103
 
 
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 */
 
108
/**
 
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.
 
112
*/
 
113
#define OPEN_FRM_FILE_ONLY     32768
 
114
/**
 
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.
 
119
*/
 
120
#define OPEN_TABLE_ONLY        OPEN_FRM_FILE_ONLY*2
 
121
/**
 
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.
 
125
*/
 
126
#define OPTIMIZE_I_S_TABLE     OPEN_TABLE_ONLY*2
 
127
 
102
128
/*
103
129
  Minimum length pattern before Turbo Boyer-Moore is used
104
130
  for SELECT "text" LIKE "%pattern%", excluding the two
114
140
 
115
141
#define BIN_LOG_HEADER_SIZE    4
116
142
 
 
143
#define COLUMN_FORMAT_MASK 7
 
144
#define COLUMN_FORMAT_SHIFT 3
 
145
 
117
146
/* Below are #defines that used to be in mysql_priv.h */
118
147
/***************************************************************************
119
148
  Configuration parameters
120
149
****************************************************************************/
 
150
#define MAX_ACCEPT_RETRY        10      // Test accept this many times
121
151
#define MAX_FIELDS_BEFORE_HASH  32
122
152
#define USER_VARS_HASH_SIZE     16
123
153
#define TABLE_OPEN_CACHE_MIN    64
137
167
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
138
168
#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
139
169
 
 
170
#define TEMP_POOL_SIZE          128
 
171
 
140
172
#define QUERY_ALLOC_BLOCK_SIZE          8192
141
173
#define QUERY_ALLOC_PREALLOC_SIZE       8192
 
174
#define TRANS_ALLOC_BLOCK_SIZE          4096
 
175
#define TRANS_ALLOC_PREALLOC_SIZE       4096
142
176
#define RANGE_ALLOC_BLOCK_SIZE          4096
143
177
#define TABLE_ALLOC_BLOCK_SIZE          1024
144
178
#define WARN_ALLOC_BLOCK_SIZE           2048
150
184
*/
151
185
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
152
186
#define MIN_ROWS_TO_USE_TABLE_CACHE      100
 
187
#define MIN_ROWS_TO_USE_BULK_INSERT      100
153
188
 
154
189
/**
155
190
  The following is used to decide if MySQL should use table scanning
190
225
 
191
226
/** Characters shown for the command in 'show processlist'. */
192
227
#define PROCESS_LIST_WIDTH 100
 
228
/* Characters shown for the command in 'information_schema.processlist' */
 
229
#define PROCESS_LIST_INFO_WIDTH 65535
193
230
 
194
231
#define PRECISION_FOR_DOUBLE 53
195
232
#define PRECISION_FOR_FLOAT  24
199
236
#define FLUSH_TIME              0               /**< Don't flush tables */
200
237
#define MAX_CONNECT_ERRORS      10              ///< errors before disabling host
201
238
 
 
239
#define INTERRUPT_PRIOR 10
 
240
#define CONNECT_PRIOR   9
 
241
#define WAIT_PRIOR      8
 
242
#define QUERY_PRIOR     6
 
243
 
202
244
/* Bits from testflag */
203
245
enum test_flag_bit
204
246
{
218
260
#define MODE_NO_ZERO_DATE               (2)
219
261
#define MODE_INVALID_DATES              (MODE_NO_ZERO_DATE*2)
220
262
 
 
263
/* @@optimizer_switch flags */
 
264
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
 
265
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
 
266
 
221
267
#define MY_CHARSET_BIN_MB_MAXLEN 1
222
268
 
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
233
279
 
234
280
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
235
281
#define UNDEF_POS (-1)
236
282
 
 
283
/* sql_show.cc:show_log_files() */
 
284
#define SHOW_LOG_STATUS_FREE "FREE"
 
285
#define SHOW_LOG_STATUS_INUSE "IN USE"
 
286
 
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
243
292
 
244
293
/* Some portable defines */
245
294
 
259
308
 
260
309
#define STRING_BUFFER_USUAL_SIZE 80
261
310
 
 
311
/*
 
312
  Some defines for exit codes for ::is_equal class functions.
 
313
*/
 
314
#define IS_EQUAL_NO 0
 
315
#define IS_EQUAL_YES 1
 
316
#define IS_EQUAL_PACK_LENGTH 2
 
317
 
 
318
 
 
319
typedef uint64_t query_id_t;
262
320
typedef void *range_seq_t;
263
321
 
264
322
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
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
 
337
 
 
338
/* Bits in table_flags() to show what database can do */
 
339
 
 
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 */
 
343
/*
 
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.
 
350
*/
 
351
#define HA_REC_NOT_IN_SEQ      (1 << 3)
 
352
 
 
353
/*
 
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
 
357
*/
 
358
#define HA_FAST_KEY_READ       (1 << 5)
 
359
/*
 
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
 
362
*/
 
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 */
 
371
/*
 
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().
 
375
*/
 
376
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
 
377
/*
 
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().
 
380
*/
 
381
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16)
 
382
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
 
383
/*
 
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
 
386
*/
 
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)
275
395
 
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 */
285
405
  set for unordered (e.g. HASH) indexes.
286
406
*/
287
407
#define HA_KEY_SCAN_NOT_ROR     128
 
408
#define HA_DO_INDEX_COND_PUSHDOWN  256 /* Supports Index Condition Pushdown */
288
409
 
289
410
/* operations for disable/enable indexes */
290
411
#define HA_KEY_SWITCH_NONUNIQ      0
326
447
#define HA_KEY_NULL_LENGTH      1
327
448
#define HA_KEY_BLOB_LENGTH      2
328
449
 
 
450
#define HA_LEX_CREATE_TMP_TABLE 1
 
451
#define HA_LEX_CREATE_IF_NOT_EXISTS 2
 
452
#define HA_LEX_CREATE_TABLE_LIKE 4
 
453
#define HA_OPTION_NO_CHECKSUM   (1L << 17)
329
454
#define HA_MAX_REC_LENGTH       65535
330
455
 
331
456
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
345
470
#define HA_CREATE_USED_AUTO             (1L << 0)
346
471
#define HA_CREATE_USED_CHARSET          (1L << 8)
347
472
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
 
473
#define HA_CREATE_USED_ENGINE           (1L << 12)
348
474
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
 
475
#define HA_CREATE_USED_COMMENT          (1L << 16)
 
476
#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)
 
477
#define HA_CREATE_USED_BLOCK_SIZE       (1L << 22)
 
478
 
 
479
#define MAXGTRIDSIZE 64
 
480
#define MAXBQUALSIZE 64
349
481
 
350
482
/*
351
483
  The below two are not used (and not handled) in this milestone of this WL
385
517
*/
386
518
#define HA_MRR_USE_DEFAULT_IMPL 64
387
519
 
 
520
/*
 
521
  Used only as parameter to multi_range_read_info():
 
522
  Flag set <=> the caller guarantees that the bounds of the scanned ranges
 
523
  will not have NULL values.
 
524
*/
 
525
#define HA_MRR_NO_NULL_ENDPOINTS 128
 
526
 
388
527
typedef int myf;
389
 
#define MYF(v)          (static_cast<drizzled::myf>(v))
 
528
#define MYF(v)          (myf) (v)
 
529
 
 
530
#define MY_I_S_MAYBE_NULL 1
 
531
#define MY_I_S_UNSIGNED   2
 
532
 
 
533
 
 
534
#define SKIP_OPEN_TABLE 0                // do not open table
 
535
#define OPEN_FRM_ONLY   1                // open FRM file only
 
536
#define OPEN_FULL_TABLE 2                // open FRM,MYD, MYI files
390
537
 
391
538
/*
392
539
   "Declared Type Collation"
409
556
#define MY_COLL_ALLOW_CONV            3
410
557
#define MY_COLL_DISALLOW_NONE         4
411
558
#define MY_COLL_CMP_CONV              7
412
 
 
413
 
inline static void clear_timestamp_auto_bits(enum timestamp_auto_set_type &_target_, 
414
 
                                             const enum timestamp_auto_set_type _bits_)
415
 
{
416
 
  _target_= (enum timestamp_auto_set_type)((int)(_target_) & ~_bits_);
417
 
}
 
559
#define clear_timestamp_auto_bits(_target_, _bits_) \
 
560
  (_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
418
561
 
419
562
/*
420
563
 * The following are for the interface with the .frm file
423
566
#define FIELDFLAG_PACK_SHIFT    3
424
567
#define FIELDFLAG_MAX_DEC    31
425
568
 
426
 
#ifdef __cplusplus
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)
432
 
{
433
 
  return static_cast<T>(type & 127);
434
 
}
435
 
#else
436
569
#define MTYP_TYPENR(type) (type & 127)  /* Remove bits from type */
437
 
#endif
438
 
 
439
 
inline static uint32_t f_settype(const enum enum_field_types x)
440
 
{
441
 
  return (uint32_t(x) << FIELDFLAG_PACK_SHIFT);
442
 
}
443
 
 
444
 
#ifdef __cplusplus
445
 
template <class T> void set_if_bigger(T &a, const T &b)
446
 
{
447
 
  if (a < b)
448
 
    a=b;
449
 
}
450
 
 
451
 
template <class T> void set_if_smaller(T &a, const T &b)
452
 
{
453
 
  if (a > b)
454
 
    a=b;
455
 
}
456
 
#else
457
 
#ifdef __GNUC__
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);                       \
463
 
  } while(0)
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);                       \
469
 
  } while(0)
470
 
 
471
 
#else
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)
474
 
#endif
475
 
#endif
476
 
 
477
 
 
478
 
#define array_elements(a) \
479
 
  ((sizeof(a) / sizeof(*(a))) / \
480
 
   static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
481
 
 
482
 
 
483
 
/* Some types that is different between systems */
484
 
 
485
 
#ifndef FN_LIBCHAR
486
 
#define FN_LIBCHAR  '/'
487
 
#define FN_ROOTDIR  "/"
488
 
#endif
489
 
#define MY_NFILE  64  /* This is only used to save filenames */
490
 
#ifndef OS_FILE_LIMIT
491
 
#define OS_FILE_LIMIT  65535
492
 
#endif
493
 
 
494
 
/*
495
 
  How much overhead does malloc have. The code often allocates
496
 
  something like 1024-MALLOC_OVERHEAD bytes
497
 
*/
498
 
#define MALLOC_OVERHEAD 8
499
 
 
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;
504
 
 
505
 
 
506
 
/* Some things that this system doesn't have */
507
 
 
508
 
/* Some defines of functions for portability */
509
 
 
510
 
#ifndef uint64_t2double
511
 
#define uint64_t2double(A) ((double) (uint64_t) (A))
512
 
#endif
513
 
 
514
 
#ifndef offsetof
515
 
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
516
 
#endif
517
 
#define ulong_to_double(X) ((double) (ulong) (X))
518
 
 
519
 
/* From limits.h instead */
520
 
#ifndef DBL_MIN
521
 
#define DBL_MIN    4.94065645841246544e-324
522
 
#endif
523
 
#ifndef DBL_MAX
524
 
#define DBL_MAX    1.79769313486231470e+308
525
 
#endif
526
 
 
527
 
 
528
 
/* Define missing math constants. */
529
 
#ifndef M_PI
530
 
#define M_PI 3.14159265358979323846
531
 
#endif
532
 
#ifndef M_E
533
 
#define M_E 2.7182818284590452354
534
 
#endif
535
 
#ifndef M_LN2
536
 
#define M_LN2 0.69314718055994530942
537
 
#endif
538
 
 
539
 
/*
540
 
  Max size that must be added to a so that we know Size to make
541
 
  adressable obj.
542
 
*/
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)
549
 
#ifdef __cplusplus
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))
552
 
#else
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))
555
 
#endif
556
 
 
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))]
559
 
 
560
 
/* Typdefs for easyier portability */
561
 
 
562
 
 
563
 
#if defined(SIZEOF_OFF_T)
564
 
# if (SIZEOF_OFF_T == 8)
565
 
#  define OFF_T_MAX (INT64_MAX)
566
 
# else
567
 
#  define OFF_T_MAX (INT32_MAX)
568
 
# endif
569
 
#endif
570
 
 
571
 
#define MY_FILEPOS_ERROR  -1
572
 
 
573
 
#define DRIZZLE_SERVER
574
 
 
575
 
/* Length of decimal number represented by INT32. */
576
 
#define MY_INT32_NUM_DECIMAL_DIGITS 11
577
 
 
578
 
/* Length of decimal number represented by INT64. */
579
 
#define MY_INT64_NUM_DECIMAL_DIGITS 21
580
 
 
581
 
/*
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.
586
 
*/
587
 
#define IO_SIZE 4096
588
 
/* Max file name len */
589
 
#define FN_LEN 256
590
 
/* Max length of extension (part of FN_LEN) */
591
 
#define FN_EXTLEN 20
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 ".."
602
 
 
603
 
/* Quote argument (before cpp) */
604
 
#ifndef QUOTE_ARG
605
 
# define QUOTE_ARG(x) #x
606
 
#endif
607
 
/* Quote argument, (after cpp) */
608
 
#ifndef STRINGIFY_ARG
609
 
# define STRINGIFY_ARG(x) QUOTE_ARG(x)
610
 
#endif
611
 
 
612
 
/*
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
619
 
 */
620
 
#if !defined(__GNUC__)
621
 
#define __builtin_expect(x, expected_value) (x)
622
 
#endif
623
 
 
624
 
#define likely(x)  __builtin_expect((x),1)
625
 
#define unlikely(x)  __builtin_expect((x),0)
626
 
 
627
 
 
628
 
/*
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.
631
 
*/
632
 
#ifdef TARGET_OS_LINUX
633
 
#define NEED_EXPLICIT_SYNC_DIR 1
634
 
#endif
635
 
 
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
640
 
#endif
641
 
 
642
 
typedef uint64_t table_map;   /* Used for table bits in join */
643
 
typedef uint32_t nesting_map; /* Used for flags of nesting constructs */
644
 
 
645
 
} /* namespace drizzled */
 
570
 
 
571
#define f_packtype(x)   (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
 
572
#define f_settype(x)    (((int) x) << FIELDFLAG_PACK_SHIFT)
646
573
 
647
574
#endif /* DRIZZLED_DEFINITIONS_H */