~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definitions.h

Merge in Stewart's FK work

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
30
30
 
31
31
#include <stdint.h>
32
32
 
33
 
#include "common.h"
34
 
 
35
33
namespace drizzled
36
34
{
37
35
 
42
40
 
43
41
#define LANGUAGE        "english/"
44
42
#define TEMP_PREFIX     "MY"
 
43
#define LOG_PREFIX      "ML"
45
44
 
46
45
#define ER(X) ::drizzled::error_message((X))
47
46
 
48
 
/* buffer size for strerror_r() */
49
 
#define STRERROR_MAX 256
50
 
 
51
47
/* extra 4+4 bytes for slave tmp tables */
 
48
#define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
 
49
#define MAX_ALIAS_NAME 256
52
50
#define MAX_FIELD_NAME 34                       /* Max colum name length +2 */
53
51
#define MAX_SYS_VAR_LENGTH 32
54
52
#define MAX_INDEXES 64
55
 
const uint32_t MAX_KEY = MAX_INDEXES;                     /* Max used keys */
56
 
const uint32_t MAX_REF_PARTS = 16;                      /* Max parts used as ref */
57
 
const uint32_t MAX_KEY_LENGTH = 4096;                    // max possible key
58
 
const uint32_t MAX_KEY_LENGTH_DECIMAL_WIDTH = 4; // strlen("4096")
59
 
 
 
53
#define MAX_KEY MAX_INDEXES                     /* Max used keys */
 
54
#define MAX_REF_PARTS 16                        /* Max parts used as ref */
 
55
#define MAX_KEY_LENGTH 4096                     /* max possible key */
 
56
#define MAX_KEY_LENGTH_DECIMAL_WIDTH 4          /* strlen("4096") */
60
57
#if SIZEOF_OFF_T > 4
61
58
#define MAX_REFLENGTH 8                         /* Max length for record ref */
62
59
#else
63
60
#define MAX_REFLENGTH 4                         /* Max length for record ref */
64
61
#endif
 
62
#define MAX_HOSTNAME  61                        /* len+1 in mysql.user */
65
63
 
66
64
#define MAX_MBWIDTH             4               /* Max multibyte sequence */
67
65
#define MAX_FIELD_CHARLENGTH    255
71
69
/* Max column width +1 */
72
70
#define MAX_FIELD_WIDTH         (MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
73
71
 
 
72
#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
 
73
 
74
74
#define MAX_TABLES      (sizeof(table_map)*8-3) /* Max tables in join */
75
75
#define PARAM_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-3))
76
76
#define OUTER_REF_TABLE_BIT     (((table_map) 1) << (sizeof(table_map)*8-2))
101
101
*/
102
102
#define MIN_TURBOBM_PATTERN_LEN 3
103
103
 
 
104
/*
 
105
   Defines for binary logging.
 
106
   Do not decrease the value of BIN_LOG_HEADER_SIZE.
 
107
   Do not even increase it before checking code.
 
108
*/
 
109
 
 
110
#define BIN_LOG_HEADER_SIZE    4
 
111
 
104
112
/* Below are #defines that used to be in mysql_priv.h */
105
113
/***************************************************************************
106
114
  Configuration parameters
107
115
****************************************************************************/
108
116
#define MAX_FIELDS_BEFORE_HASH  32
 
117
#define USER_VARS_HASH_SIZE     16
109
118
#define TABLE_OPEN_CACHE_MIN    64
110
119
#define TABLE_OPEN_CACHE_DEFAULT 1024
111
120
 
177
186
/** Characters shown for the command in 'show processlist'. */
178
187
#define PROCESS_LIST_WIDTH 100
179
188
 
 
189
#define PRECISION_FOR_DOUBLE 53
 
190
#define PRECISION_FOR_FLOAT  24
 
191
 
 
192
/* The following can also be changed from the command line */
 
193
#define DEFAULT_CONCURRENCY     10
 
194
#define FLUSH_TIME              0               /**< Don't flush tables */
 
195
#define MAX_CONNECT_ERRORS      10              ///< errors before disabling host
 
196
 
 
197
#define INTERRUPT_PRIOR 10
 
198
#define CONNECT_PRIOR   9
 
199
#define WAIT_PRIOR      8
 
200
#define QUERY_PRIOR     6
 
201
 
 
202
/* Bits from testflag */
 
203
enum test_flag_bit
 
204
{
 
205
  TEST_PRINT_CACHED_TABLES= 1,
 
206
  TEST_NO_KEY_GROUP,
 
207
  TEST_MIT_THREAD,
 
208
  TEST_KEEP_TMP_TABLES,
 
209
  TEST_READCHECK, /**< Force use of readcheck */
 
210
  TEST_NO_EXTRA,
 
211
  TEST_CORE_ON_SIGNAL, /**< Give core if signal */
 
212
  TEST_NO_STACKTRACE,
 
213
  TEST_SIGINT, /**< Allow sigint on threads */
 
214
  TEST_SYNCHRONIZATION /**< get server to do sleep in some places */
 
215
};
 
216
 
180
217
/* Bits for different SQL modes modes (including ANSI mode) */
181
218
#define MODE_NO_ZERO_DATE               (2)
182
219
#define MODE_INVALID_DATES              (MODE_NO_ZERO_DATE*2)
184
221
#define MY_CHARSET_BIN_MB_MAXLEN 1
185
222
 
186
223
// uncachable cause
187
 
static const uint32_t UNCACHEABLE_DEPENDENT= 1;
188
 
static const uint32_t UNCACHEABLE_RAND= 2;
189
 
static const uint32_t UNCACHEABLE_SIDEEFFECT= 3;
 
224
#define UNCACHEABLE_DEPENDENT   1
 
225
#define UNCACHEABLE_RAND        2
 
226
#define UNCACHEABLE_SIDEEFFECT  4
190
227
/// forcing to save JOIN for explain
191
 
static const uint32_t UNCACHEABLE_EXPLAIN= 4;
 
228
#define UNCACHEABLE_EXPLAIN     8
192
229
/** Don't evaluate subqueries in prepare even if they're not correlated */
193
 
static const uint32_t UNCACHEABLE_PREPARE= 5;
 
230
#define UNCACHEABLE_PREPARE    16
194
231
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
195
 
static const uint32_t UNCACHEABLE_UNITED= 6;
 
232
#define UNCACHEABLE_UNITED     32
196
233
 
197
234
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
198
235
#define UNDEF_POS (-1)
199
236
 
200
237
/* Options to add_table_to_list() */
201
 
static const uint32_t TL_OPTION_UPDATING= 0;
202
 
static const uint32_t TL_OPTION_FORCE_INDEX= 1;
203
 
static const uint32_t TL_OPTION_IGNORE_LEAVES= 2;
204
 
static const uint32_t TL_OPTION_ALIAS= 3;
205
 
static const uint32_t NUM_OF_TABLE_OPTIONS= 4;
 
238
#define TL_OPTION_UPDATING      1
 
239
#define TL_OPTION_FORCE_INDEX   2
 
240
#define TL_OPTION_IGNORE_LEAVES 4
 
241
#define TL_OPTION_ALIAS         8
206
242
 
207
243
/* Some portable defines */
208
244
 
256
292
#define HA_KEY_SWITCH_ALL_SAVE     3
257
293
 
258
294
/*
 
295
  Note: the following includes binlog and closing 0.
 
296
  so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
 
297
      example + csv + heap + blackhole + federated + 0
 
298
  (yes, the sum is deliberately inaccurate)
 
299
  TODO remove the limit, use dynarrays
 
300
*/
 
301
#define MAX_HA 15
 
302
 
 
303
/*
259
304
  Parameters for open() (in register form->filestat)
260
305
  HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
261
306
*/
272
317
#define HA_BLOCK_LOCK           256     /* unlock when reading some records */
273
318
#define HA_OPEN_TEMPORARY       512
274
319
 
 
320
/* For transactional LOCK Table. handler::lock_table() */
 
321
#define HA_LOCK_IN_SHARE_MODE      F_RDLCK
 
322
#define HA_LOCK_IN_EXCLUSIVE_MODE  F_WRLCK
 
323
 
275
324
/* Some key definitions */
276
325
#define HA_KEY_NULL_LENGTH      1
277
326
#define HA_KEY_BLOB_LENGTH      2
278
327
 
279
 
const uint32_t HA_MAX_REC_LENGTH = 65535;
 
328
#define HA_MAX_REC_LENGTH       65535
280
329
 
281
330
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
282
331
enum start_transaction_option_t
295
344
#define HA_CREATE_USED_AUTO             (1L << 0)
296
345
#define HA_CREATE_USED_CHARSET          (1L << 8)
297
346
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
 
347
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
298
348
 
299
349
/*
300
350
  The below two are not used (and not handled) in this milestone of this WL
358
408
#define MY_COLL_ALLOW_CONV            3
359
409
#define MY_COLL_DISALLOW_NONE         4
360
410
#define MY_COLL_CMP_CONV              7
361
 
 
362
 
inline static void clear_timestamp_auto_bits(timestamp_auto_set_type &_target_, 
363
 
                                             timestamp_auto_set_type _bits_)
364
 
{
365
 
  _target_= static_cast<timestamp_auto_set_type>(_target_ & ~_bits_);
366
 
}
 
411
#define clear_timestamp_auto_bits(_target_, _bits_) \
 
412
  (_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
367
413
 
368
414
/*
369
415
 * The following are for the interface with the .frm file
372
418
#define FIELDFLAG_PACK_SHIFT    3
373
419
#define FIELDFLAG_MAX_DEC    31
374
420
 
375
 
#ifdef __cplusplus
376
 
// FIXME: T will just be drizzled::Field::utype, but that would
377
 
// require including field.h. Moving the function elsewhere might be a
378
 
// better idea. Leaving it for restructuring.
379
 
template <typename T> 
380
 
T MTYP_TYPENR(const T& type)
381
 
{
382
 
  return static_cast<T>(type & 127);
383
 
}
384
 
#else
385
421
#define MTYP_TYPENR(type) (type & 127)  /* Remove bits from type */
386
 
#endif
387
 
 
388
 
inline static uint32_t f_settype(const enum enum_field_types x)
389
 
{
390
 
  return (uint32_t(x) << FIELDFLAG_PACK_SHIFT);
391
 
}
 
422
 
 
423
#define f_settype(x)    (((int) x) << FIELDFLAG_PACK_SHIFT)
 
424
 
392
425
 
393
426
#ifdef __cplusplus
394
427
template <class T> void set_if_bigger(T &a, const T &b)
402
435
  if (a > b)
403
436
    a=b;
404
437
}
405
 
 
406
 
template<class T> inline void safe_delete(T*& ptr)
407
 
{
408
 
  delete ptr;
409
 
  ptr = 0;
410
 
}
411
438
#else
412
439
#ifdef __GNUC__
413
440
#define set_if_bigger(a,b) do {                 \
466
493
#define uint64_t2double(A) ((double) (uint64_t) (A))
467
494
#endif
468
495
 
469
 
#ifndef int64_t2double
470
 
#define int64_t2double(A) ((double) (int64_t) (A))
471
 
#endif
472
 
 
473
496
#ifndef offsetof
474
497
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
475
498
#endif
 
499
#define ulong_to_double(X) ((double) (ulong) (X))
476
500
 
477
501
/* From limits.h instead */
478
502
#ifndef DBL_MIN
500
524
*/
501
525
#define MY_ALIGN(A,L)  (((A) + (L) - 1) & ~((L) - 1))
502
526
#define ALIGN_SIZE(A)  MY_ALIGN((A),sizeof(double))
 
527
/* Size to make adressable obj. */
 
528
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
 
529
/* Offset of field f in structure t */
 
530
#define OFFSET(t, f)  ((size_t)(char *)&((t *)0)->f)
503
531
#ifdef __cplusplus
504
532
#define ADD_TO_PTR(ptr,size,type) (type) (reinterpret_cast<const unsigned char*>(ptr)+size)
 
533
#define PTR_BYTE_DIFF(A,B) (ptrdiff_t) (reinterpret_cast<const unsigned char*>(A) - reinterpret_cast<const unsigned char*>(B))
505
534
#else
506
535
 #define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
 
536
 #define PTR_BYTE_DIFF(A,B) (ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
507
537
#endif
508
538
 
509
539
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
539
569
#define IO_SIZE 4096
540
570
/* Max file name len */
541
571
#define FN_LEN 256
 
572
/* Max length of extension (part of FN_LEN) */
 
573
#define FN_EXTLEN 20
542
574
/* Max length of full path-name */
543
575
#define FN_REFLEN 512
544
576
/* File extension character */
589
621
# define _DTRACE_VERSION 0
590
622
#endif
591
623
 
592
 
typedef uint64_t table_map;   /* Used for table bits in join */
593
 
typedef uint32_t nesting_map; /* Used for flags of nesting constructs */
594
 
 
595
624
} /* namespace drizzled */
596
625
 
597
626
#endif /* DRIZZLED_DEFINITIONS_H */