~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definitions.h

  • Committer: Brian Aker
  • Date: 2011-02-22 06:12:02 UTC
  • mfrom: (2190.1.6 drizzle-build)
  • Revision ID: brian@tangent.org-20110222061202-k03czxykqy4x9hjs
List update, header fixes, multiple symbols, and David deletes some code.

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