~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definitions.h

  • Committer: Olaf van der Spek
  • Date: 2011-06-23 11:44:30 UTC
  • mto: This revision was merged to the branch mainline in revision 2348.
  • Revision ID: olafvdspek@gmail.com-20110623114430-no355yypk4y3icqb
Refactor

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
23
23
 * Mostly constants and some macros/functions used by the server
24
24
 */
25
25
 
26
 
#ifndef DRIZZLED_DEFINITIONS_H
27
 
#define DRIZZLED_DEFINITIONS_H
 
26
#pragma once
28
27
 
29
28
#include <drizzled/enum.h>
30
29
 
42
41
 
43
42
#define LANGUAGE        "english/"
44
43
#define TEMP_PREFIX     "MY"
45
 
#define LOG_PREFIX      "ML"
46
44
 
47
45
#define ER(X) ::drizzled::error_message((X))
48
46
 
50
48
#define STRERROR_MAX 256
51
49
 
52
50
/* extra 4+4 bytes for slave tmp tables */
53
 
#define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
54
 
#define MAX_ALIAS_NAME 256
55
51
#define MAX_FIELD_NAME 34                       /* Max colum name length +2 */
56
52
#define MAX_SYS_VAR_LENGTH 32
57
53
#define MAX_INDEXES 64
58
 
#define MAX_KEY MAX_INDEXES                     /* Max used keys */
59
 
#define MAX_REF_PARTS 16                        /* Max parts used as ref */
60
 
#define MAX_KEY_LENGTH 4096                     /* max possible key */
61
 
#define MAX_KEY_LENGTH_DECIMAL_WIDTH 4          /* strlen("4096") */
 
54
const uint32_t MAX_KEY = MAX_INDEXES;                     /* Max used keys */
 
55
const uint32_t MAX_REF_PARTS = 16;                      /* Max parts used as ref */
 
56
const uint32_t MAX_KEY_LENGTH = 4096;                    // max possible key
 
57
const uint32_t MAX_KEY_LENGTH_DECIMAL_WIDTH = 4; // strlen("4096")
 
58
 
62
59
#if SIZEOF_OFF_T > 4
63
60
#define MAX_REFLENGTH 8                         /* Max length for record ref */
64
61
#else
65
62
#define MAX_REFLENGTH 4                         /* Max length for record ref */
66
63
#endif
67
 
#define MAX_HOSTNAME  61                        /* len+1 in mysql.user */
68
64
 
69
65
#define MAX_MBWIDTH             4               /* Max multibyte sequence */
70
66
#define MAX_FIELD_CHARLENGTH    255
74
70
/* Max column width +1 */
75
71
#define MAX_FIELD_WIDTH         (MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
76
72
 
77
 
#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
78
 
 
79
73
#define MAX_TABLES      (sizeof(table_map)*8-3) /* Max tables in join */
80
74
#define PARAM_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-3))
81
75
#define OUTER_REF_TABLE_BIT     (((table_map) 1) << (sizeof(table_map)*8-2))
106
100
*/
107
101
#define MIN_TURBOBM_PATTERN_LEN 3
108
102
 
109
 
/*
110
 
   Defines for binary logging.
111
 
   Do not decrease the value of BIN_LOG_HEADER_SIZE.
112
 
   Do not even increase it before checking code.
113
 
*/
114
 
 
115
 
#define BIN_LOG_HEADER_SIZE    4
116
 
 
117
103
/* Below are #defines that used to be in mysql_priv.h */
118
104
/***************************************************************************
119
105
  Configuration parameters
120
106
****************************************************************************/
121
107
#define MAX_FIELDS_BEFORE_HASH  32
122
 
#define USER_VARS_HASH_SIZE     16
123
108
#define TABLE_OPEN_CACHE_MIN    64
124
109
#define TABLE_OPEN_CACHE_DEFAULT 1024
125
110
 
191
176
/** Characters shown for the command in 'show processlist'. */
192
177
#define PROCESS_LIST_WIDTH 100
193
178
 
194
 
#define PRECISION_FOR_DOUBLE 53
195
 
#define PRECISION_FOR_FLOAT  24
196
 
 
197
 
/* The following can also be changed from the command line */
198
 
#define DEFAULT_CONCURRENCY     10
199
 
#define FLUSH_TIME              0               /**< Don't flush tables */
200
 
#define MAX_CONNECT_ERRORS      10              ///< errors before disabling host
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
 
 
217
179
/* Bits for different SQL modes modes (including ANSI mode) */
218
180
#define MODE_NO_ZERO_DATE               (2)
219
181
#define MODE_INVALID_DATES              (MODE_NO_ZERO_DATE*2)
293
255
#define HA_KEY_SWITCH_ALL_SAVE     3
294
256
 
295
257
/*
296
 
  Note: the following includes binlog and closing 0.
297
 
  so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
298
 
      example + csv + heap + blackhole + federated + 0
299
 
  (yes, the sum is deliberately inaccurate)
300
 
  TODO remove the limit, use dynarrays
301
 
*/
302
 
#define MAX_HA 15
303
 
 
304
 
/*
305
258
  Parameters for open() (in register form->filestat)
306
259
  HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
307
260
*/
318
271
#define HA_BLOCK_LOCK           256     /* unlock when reading some records */
319
272
#define HA_OPEN_TEMPORARY       512
320
273
 
321
 
/* For transactional LOCK Table. handler::lock_table() */
322
 
#define HA_LOCK_IN_SHARE_MODE      F_RDLCK
323
 
#define HA_LOCK_IN_EXCLUSIVE_MODE  F_WRLCK
324
 
 
325
274
/* Some key definitions */
326
275
#define HA_KEY_NULL_LENGTH      1
327
276
#define HA_KEY_BLOB_LENGTH      2
328
277
 
329
 
#define HA_MAX_REC_LENGTH       65535
 
278
const uint32_t HA_MAX_REC_LENGTH = 65535;
330
279
 
331
280
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
332
281
enum start_transaction_option_t
345
294
#define HA_CREATE_USED_AUTO             (1L << 0)
346
295
#define HA_CREATE_USED_CHARSET          (1L << 8)
347
296
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
348
 
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
349
297
 
350
298
/*
351
299
  The below two are not used (and not handled) in this milestone of this WL
410
358
#define MY_COLL_DISALLOW_NONE         4
411
359
#define MY_COLL_CMP_CONV              7
412
360
 
413
 
inline static void clear_timestamp_auto_bits(enum timestamp_auto_set_type &_target_, 
414
 
                                             const enum timestamp_auto_set_type _bits_)
 
361
inline static void clear_timestamp_auto_bits(timestamp_auto_set_type &_target_, 
 
362
                                             timestamp_auto_set_type _bits_)
415
363
{
416
 
  _target_= (enum timestamp_auto_set_type)((int)(_target_) & ~_bits_);
 
364
  _target_= static_cast<timestamp_auto_set_type>(_target_ & ~_bits_);
417
365
}
418
366
 
419
367
/*
474
422
#endif
475
423
#endif
476
424
 
 
425
template<class T> inline void safe_delete(T*& ptr)
 
426
{
 
427
  delete ptr;
 
428
  ptr = 0;
 
429
}
477
430
 
478
431
#define array_elements(a) \
479
432
  ((sizeof(a) / sizeof(*(a))) / \
486
439
#define FN_LIBCHAR  '/'
487
440
#define FN_ROOTDIR  "/"
488
441
#endif
489
 
#define MY_NFILE  64  /* This is only used to save filenames */
490
442
#ifndef OS_FILE_LIMIT
491
443
#define OS_FILE_LIMIT  65535
492
444
#endif
511
463
#define uint64_t2double(A) ((double) (uint64_t) (A))
512
464
#endif
513
465
 
 
466
#ifndef int64_t2double
 
467
#define int64_t2double(A) ((double) (int64_t) (A))
 
468
#endif
 
469
 
514
470
#ifndef offsetof
515
471
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
516
472
#endif
517
 
#define ulong_to_double(X) ((double) (ulong) (X))
518
473
 
519
474
/* From limits.h instead */
520
475
#ifndef DBL_MIN
542
497
*/
543
498
#define MY_ALIGN(A,L)  (((A) + (L) - 1) & ~((L) - 1))
544
499
#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
500
#ifdef __cplusplus
550
501
#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
502
#else
553
503
 #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
504
#endif
556
505
 
557
506
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
587
536
#define IO_SIZE 4096
588
537
/* Max file name len */
589
538
#define FN_LEN 256
590
 
/* Max length of extension (part of FN_LEN) */
591
 
#define FN_EXTLEN 20
592
539
/* Max length of full path-name */
593
540
#define FN_REFLEN 512
594
541
/* File extension character */
644
591
 
645
592
} /* namespace drizzled */
646
593
 
647
 
#endif /* DRIZZLED_DEFINITIONS_H */