~drizzle-trunk/drizzle/development

390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
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
 */
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
19
20
/**
21
 * @file
22
 *
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
23
 * Mostly constants and some macros/functions used by the server
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
24
 */
25
1119.9.4 by Jay Pipes
Removes the FIELDFLAG_NO_DEFAULT bit and f_no_default macro and calls
26
#ifndef DRIZZLED_DEFINITIONS_H
27
#define DRIZZLED_DEFINITIONS_H
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
28
1089.1.11 by Brian Aker
Cleanup on enum
29
#include <drizzled/enum.h>
30
575.1.6 by Monty Taylor
Cleaned up some headers for PCH.
31
#include <stdint.h>
32
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
33
namespace drizzled
34
{
35
1556.1.1 by Brian Aker
Updates for moving temporary directory.
36
/* Global value for how we extend our temporary directory */
1567 by Brian Aker
Remove restriction on schemas named temporary.
37
#define GLOBAL_TEMPORARY_EXT ".temporary"
1556.1.1 by Brian Aker
Updates for moving temporary directory.
38
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
39
/* These paths are converted to other systems (WIN95) before use */
40
41
#define LANGUAGE	"english/"
42
#define TEMP_PREFIX	"MY"
43
#define LOG_PREFIX	"ML"
44
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
45
#define ER(X) ::drizzled::error_message((X))
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
46
1558.2.3 by Hartmut Holzgraefe
strerror() -> strerror_r() conversion started (bug #606478)
47
/* buffer size for strerror_r() */
48
#define STRERROR_MAX 256
49
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
50
/* 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
#define MAX_FIELD_NAME 34			/* Max colum name length +2 */
54
#define MAX_SYS_VAR_LENGTH 32
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
55
#define MAX_INDEXES 64
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
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") */
60
#if SIZEOF_OFF_T > 4
61
#define MAX_REFLENGTH 8				/* Max length for record ref */
62
#else
63
#define MAX_REFLENGTH 4				/* Max length for record ref */
64
#endif
65
#define MAX_HOSTNAME  61			/* len+1 in mysql.user */
66
67
#define MAX_MBWIDTH		4		/* Max multibyte sequence */
68
#define MAX_FIELD_CHARLENGTH	255
69
#define MAX_FIELD_VARCHARLENGTH	65535
70
#define CONVERT_IF_BIGGER_TO_BLOB 512		/* Used for CREATE ... SELECT */
71
72
/* Max column width +1 */
73
#define MAX_FIELD_WIDTH		(MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
74
75
#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
76
77
#define MAX_TABLES	(sizeof(table_map)*8-3)	/* Max tables in join */
78
#define PARAM_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-3))
79
#define OUTER_REF_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-2))
80
#define RAND_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-1))
81
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
82
                           RAND_TABLE_BIT)
1259.5.6 by Stewart Smith
document 4096 column limit as historical MySQL limit, not an actual limit of any FRM file that currently exists.
83
#define MAX_FIELDS	4096      /* Historical limit from MySQL FRM. */
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
84
85
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
86
87
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
88
#define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
89
90
#define DEFAULT_ERROR_COUNT	64
91
#define EXTRA_RECORDS	10			/* Extra records in sort */
92
#define NAMES_SEP_CHAR	'\377'			/* Char to sep. names */
93
895 by Brian Aker
Completion (?) of uint conversion.
94
#define READ_RECORD_BUFFER	(uint32_t) (IO_SIZE*8) /* Pointer_buffer_size */
95
#define DISK_BUFFER_SIZE	(uint32_t) (IO_SIZE*16) /* Size of diskbuffer */
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
96
97
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
98
#define MYF_RW MYF(MY_WME+MY_NABP)		/* Vid my_read & my_write */
99
100
/*
101
  Minimum length pattern before Turbo Boyer-Moore is used
102
  for SELECT "text" LIKE "%pattern%", excluding the two
103
  wildcards in class Item_func_like.
104
*/
105
#define MIN_TURBOBM_PATTERN_LEN 3
106
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
107
/*
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
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
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
113
#define BIN_LOG_HEADER_SIZE    4
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
114
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
115
/* Below are #defines that used to be in mysql_priv.h */
116
/***************************************************************************
117
  Configuration parameters
118
****************************************************************************/
119
#define MAX_FIELDS_BEFORE_HASH	32
120
#define USER_VARS_HASH_SIZE     16
121
#define TABLE_OPEN_CACHE_MIN    64
876 by Brian Aker
Removed some dead definitions.
122
#define TABLE_OPEN_CACHE_DEFAULT 1024
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
123
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
124
/*
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
125
 Value of 9236 discovered through binary search 2006-09-26 on Ubuntu Dapper
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
126
 Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
127
 100 bytes as reasonable buffer against growth and other environments'
128
 requirements.)
129
130
 Feel free to raise this by the smallest amount you can to get the
131
 "execution_constants" test to pass.
132
 */
133
#define STACK_MIN_SIZE          12000   ///< Abort if less stack during eval.
134
135
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
136
#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
137
138
#define QUERY_ALLOC_BLOCK_SIZE		8192
139
#define QUERY_ALLOC_PREALLOC_SIZE   	8192
140
#define RANGE_ALLOC_BLOCK_SIZE		4096
141
#define TABLE_ALLOC_BLOCK_SIZE		1024
142
#define WARN_ALLOC_BLOCK_SIZE		2048
143
#define WARN_ALLOC_PREALLOC_SIZE	1024
144
145
/*
146
  The following parameters is to decide when to use an extra cache to
147
  optimise seeks when reading a big table in sorted order
148
*/
149
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
150
#define MIN_ROWS_TO_USE_TABLE_CACHE	 100
151
152
/**
153
  The following is used to decide if MySQL should use table scanning
154
  instead of reading with keys.  The number says how many evaluation of the
155
  WHERE clause is comparable to reading one extra row from a table.
156
*/
157
#define TIME_FOR_COMPARE   5	// 5 compares == one read
158
159
/**
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
160
  Number of comparisons of table rowids equivalent to reading one row from a
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
161
  table.
162
*/
163
#define TIME_FOR_COMPARE_ROWID  (TIME_FOR_COMPARE*2)
164
165
/*
166
  For sequential disk seeks the cost formula is:
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
167
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip
168
169
  The cost of average seek
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
170
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
171
*/
172
#define DISK_SEEK_BASE_COST ((double)0.9)
173
174
#define BLOCKS_IN_AVG_SEEK  128
175
176
#define DISK_SEEK_PROP_COST ((double)0.1/BLOCKS_IN_AVG_SEEK)
177
178
179
/**
180
  Number of rows in a reference table when refereed through a not unique key.
181
  This value is only used when we don't know anything about the key
182
  distribution.
183
*/
184
#define MATCHING_ROWS_IN_OTHER_TABLE 10
185
186
/** Don't pack string keys shorter than this (if PACK_KEYS=1 isn't used). */
187
#define KEY_DEFAULT_PACK_LENGTH 8
188
189
/** Characters shown for the command in 'show processlist'. */
190
#define PROCESS_LIST_WIDTH 100
191
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
1089.6.2 by Padraig O'Sullivan
Modified the size of the test_flags bitset to be 12 bits instead of 32. No
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
};
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
214
215
/* Bits for different SQL modes modes (including ANSI mode) */
361 by Brian Aker
One more mode down, two more left to go!
216
#define MODE_NO_ZERO_DATE		(2)
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
217
#define MODE_INVALID_DATES		(MODE_NO_ZERO_DATE*2)
218
219
#define MY_CHARSET_BIN_MB_MAXLEN 1
220
221
// uncachable cause
1858.1.2 by Padraig O'Sullivan
Converted another uint8_t type to be a bitset.
222
static const uint32_t UNCACHEABLE_DEPENDENT= 1;
223
static const uint32_t UNCACHEABLE_RAND= 2;
224
static const uint32_t UNCACHEABLE_SIDEEFFECT= 3;
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
225
/// forcing to save JOIN for explain
1858.1.2 by Padraig O'Sullivan
Converted another uint8_t type to be a bitset.
226
static const uint32_t UNCACHEABLE_EXPLAIN= 4;
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
227
/** Don't evaluate subqueries in prepare even if they're not correlated */
1858.1.2 by Padraig O'Sullivan
Converted another uint8_t type to be a bitset.
228
static const uint32_t UNCACHEABLE_PREPARE= 5;
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
229
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
1858.1.2 by Padraig O'Sullivan
Converted another uint8_t type to be a bitset.
230
static const uint32_t UNCACHEABLE_UNITED= 6;
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
231
232
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
233
#define UNDEF_POS (-1)
234
235
/* Options to add_table_to_list() */
1858.1.2 by Padraig O'Sullivan
Converted another uint8_t type to be a bitset.
236
static const uint32_t TL_OPTION_UPDATING= 0;
237
static const uint32_t TL_OPTION_FORCE_INDEX= 1;
238
static const uint32_t TL_OPTION_IGNORE_LEAVES= 2;
239
static const uint32_t TL_OPTION_ALIAS= 3;
240
static const uint32_t NUM_OF_TABLE_OPTIONS= 4;
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
241
242
/* Some portable defines */
243
244
#define portable_sizeof_char_ptr 8
245
584.2.1 by Stewart Smith
convert tmp_file_prefix to TMP_FILE_PREFIX to indicate it's a macro
246
#define TMP_FILE_PREFIX "#sql"			/**< Prefix for tmp tables */
247
#define TMP_FILE_PREFIX_LENGTH 4
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
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
574.3.17 by Lee
moving functions from item_timefunc to functions/time directory
254
/* used in date and time conversions */
255
/* Daynumber from year 0 to 9999-12-31 */
256
#define MAX_DAY_NUMBER 3652424L
257
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
258
#define STRING_BUFFER_USUAL_SIZE 80
259
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
260
typedef void *range_seq_t;
261
1130.1.5 by Monty Taylor
Split StorageEngine into slot. This completes the plugin-slot-reorg. Woot.
262
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
520.8.6 by Monty Taylor
Removed handler from common_includes.
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
*/
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
285
#define HA_KEY_SCAN_NOT_ROR     128
520.8.6 by Monty Taylor
Removed handler from common_includes.
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) */
1206.1.3 by Brian Aker
Valgrind fix for startTransaction()
330
enum start_transaction_option_t
331
{
332
  START_TRANS_NO_OPTIONS,
333
  START_TRANS_OPT_WITH_CONS_SNAPSHOT
334
};
520.8.6 by Monty Taylor
Removed handler from common_includes.
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
348
/*
349
  The below two are not used (and not handled) in this milestone of this WL
350
  entry because there seems to be no use for them at this stage of
351
  implementation.
352
*/
353
#define HA_MRR_SINGLE_POINT 1
354
#define HA_MRR_FIXED_KEY  2
355
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
356
/*
520.8.6 by Monty Taylor
Removed handler from common_includes.
357
  Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
358
  'range' parameter.
359
*/
360
#define HA_MRR_NO_ASSOCIATION 4
361
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
362
/*
520.8.6 by Monty Taylor
Removed handler from common_includes.
363
  The MRR user will provide ranges in key order, and MRR implementation
364
  must return rows in key order.
365
*/
366
#define HA_MRR_SORTED 8
367
368
/* MRR implementation doesn't have to retrieve full records */
369
#define HA_MRR_INDEX_ONLY 16
370
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
371
/*
520.8.6 by Monty Taylor
Removed handler from common_includes.
372
  The passed memory buffer is of maximum possible size, the caller can't
373
  assume larger buffer.
374
*/
375
#define HA_MRR_LIMITS 32
376
377
378
/*
379
  Flag set <=> default MRR implementation is used
380
  (The choice is made by **_info[_const]() function which may set this
381
   flag. SQL layer remembers the flag value and then passes it to
382
   multi_read_range_init().
383
*/
384
#define HA_MRR_USE_DEFAULT_IMPL 64
385
575.1.6 by Monty Taylor
Cleaned up some headers for PCH.
386
typedef int myf;
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
387
#define MYF(v)		(static_cast<drizzled::myf>(v))
575.1.6 by Monty Taylor
Cleaned up some headers for PCH.
388
584.4.1 by Monty Taylor
Split out DTCollation.
389
/*
390
   "Declared Type Collation"
391
   A combination of collation and its derivation.
392
393
  Flags for collation aggregation modes:
394
  MY_COLL_ALLOW_SUPERSET_CONV  - allow conversion to a superset
395
  MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
396
                                 (i.e. constant).
397
  MY_COLL_ALLOW_CONV           - allow any kind of conversion
398
                                 (combination of the above two)
399
  MY_COLL_DISALLOW_NONE        - don't allow return DERIVATION_NONE
400
                                 (e.g. when aggregating for comparison)
401
  MY_COLL_CMP_CONV             - combination of MY_COLL_ALLOW_CONV
402
                                 and MY_COLL_DISALLOW_NONE
403
*/
404
405
#define MY_COLL_ALLOW_SUPERSET_CONV   1
406
#define MY_COLL_ALLOW_COERCIBLE_CONV  2
407
#define MY_COLL_ALLOW_CONV            3
408
#define MY_COLL_DISALLOW_NONE         4
409
#define MY_COLL_CMP_CONV              7
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
410
#define clear_timestamp_auto_bits(_target_, _bits_) \
411
  (_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
412
584.5.1 by Monty Taylor
Removed field includes from field.h.
413
/*
414
 * The following are for the interface with the .frm file
415
 */
416
417
#define FIELDFLAG_PACK_SHIFT    3
418
#define FIELDFLAG_MAX_DEC    31
419
420
#define MTYP_TYPENR(type) (type & 127)  /* Remove bits from type */
421
422
#define f_settype(x)    (((int) x) << FIELDFLAG_PACK_SHIFT)
1119.9.4 by Jay Pipes
Removes the FIELDFLAG_NO_DEFAULT bit and f_no_default macro and calls
423
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
424
425
#ifdef __cplusplus
426
template <class T> void set_if_bigger(T &a, const T &b)
427
{
428
  if (a < b)
429
    a=b;
430
}
431
432
template <class T> void set_if_smaller(T &a, const T &b)
433
{
434
  if (a > b)
435
    a=b;
436
}
437
#else
438
#ifdef __GNUC__
439
#define set_if_bigger(a,b) do {                 \
440
  const typeof(a) _a = (a);                     \
441
  const typeof(b) _b = (b);                     \
442
  (void) (&_a == &_b);                          \
443
  if ((a) < (b)) (a)=(b);                       \
444
  } while(0)
445
#define set_if_smaller(a,b) do {                \
446
  const typeof(a) _a = (a);                     \
447
  const typeof(b) _b = (b);                     \
448
  (void) (&_a == &_b);                          \
449
  if ((a) > (b)) (a)=(b);                       \
450
  } while(0)
451
452
#else
453
#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
454
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
455
#endif
456
#endif
457
1241.9.6 by Monty Taylor
Enhanced our version of array_elements.
458
459
#define array_elements(a) \
460
  ((sizeof(a) / sizeof(*(a))) / \
461
   static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
462
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
463
464
/* Some types that is different between systems */
465
466
#ifndef FN_LIBCHAR
467
#define FN_LIBCHAR  '/'
468
#define FN_ROOTDIR  "/"
469
#endif
470
#define MY_NFILE  64  /* This is only used to save filenames */
471
#ifndef OS_FILE_LIMIT
472
#define OS_FILE_LIMIT  65535
473
#endif
474
475
/*
476
  How much overhead does malloc have. The code often allocates
477
  something like 1024-MALLOC_OVERHEAD bytes
478
*/
479
#define MALLOC_OVERHEAD 8
480
481
/* get memory in huncs */
482
static const uint32_t ONCE_ALLOC_INIT= 4096;
483
/* Typical record cash */
484
static const uint32_t RECORD_CACHE_SIZE= 64*1024;
485
486
487
/* Some things that this system doesn't have */
488
489
/* Some defines of functions for portability */
490
491
#ifndef uint64_t2double
492
#define uint64_t2double(A) ((double) (uint64_t) (A))
493
#endif
494
495
#ifndef offsetof
496
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
497
#endif
498
#define ulong_to_double(X) ((double) (ulong) (X))
499
500
/* From limits.h instead */
501
#ifndef DBL_MIN
502
#define DBL_MIN    4.94065645841246544e-324
503
#endif
504
#ifndef DBL_MAX
505
#define DBL_MAX    1.79769313486231470e+308
506
#endif
507
508
509
/* Define missing math constants. */
510
#ifndef M_PI
511
#define M_PI 3.14159265358979323846
512
#endif
513
#ifndef M_E
514
#define M_E 2.7182818284590452354
515
#endif
516
#ifndef M_LN2
517
#define M_LN2 0.69314718055994530942
518
#endif
519
520
/*
521
  Max size that must be added to a so that we know Size to make
522
  adressable obj.
523
*/
524
#define MY_ALIGN(A,L)  (((A) + (L) - 1) & ~((L) - 1))
525
#define ALIGN_SIZE(A)  MY_ALIGN((A),sizeof(double))
526
/* Size to make adressable obj. */
527
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
528
/* Offset of field f in structure t */
529
#define OFFSET(t, f)  ((size_t)(char *)&((t *)0)->f)
1241.13.2 by Monty Taylor
Merged in change from Trond.
530
#ifdef __cplusplus
531
#define ADD_TO_PTR(ptr,size,type) (type) (reinterpret_cast<const unsigned char*>(ptr)+size)
532
#define PTR_BYTE_DIFF(A,B) (ptrdiff_t) (reinterpret_cast<const unsigned char*>(A) - reinterpret_cast<const unsigned char*>(B))
533
#else
534
 #define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
535
 #define PTR_BYTE_DIFF(A,B) (ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
536
#endif
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
537
538
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
539
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
540
541
/* Typdefs for easyier portability */
542
543
544
#if defined(SIZEOF_OFF_T)
545
# if (SIZEOF_OFF_T == 8)
546
#  define OFF_T_MAX (INT64_MAX)
547
# else
548
#  define OFF_T_MAX (INT32_MAX)
549
# endif
550
#endif
551
552
#define MY_FILEPOS_ERROR  -1
553
554
#define DRIZZLE_SERVER
555
556
/* Length of decimal number represented by INT32. */
557
#define MY_INT32_NUM_DECIMAL_DIGITS 11
558
559
/* Length of decimal number represented by INT64. */
560
#define MY_INT64_NUM_DECIMAL_DIGITS 21
561
562
/*
563
  Io buffer size; Must be a power of 2 and
564
  a multiple of 512. May be
565
  smaller what the disk page size. This influences the speed of the
566
  isam btree library. eg to big to slow.
567
*/
568
#define IO_SIZE 4096
569
/* Max file name len */
570
#define FN_LEN 256
571
/* Max length of extension (part of FN_LEN) */
572
#define FN_EXTLEN 20
573
/* Max length of full path-name */
574
#define FN_REFLEN 512
575
/* File extension character */
576
#define FN_EXTCHAR '.'
577
/* ~ is used as abbrev for home dir */
578
#define FN_HOMELIB '~'
579
/* ./ is used as abbrev for current dir */
580
#define FN_CURLIB '.'
581
/* Parent directory; Must be a string */
582
#define FN_PARENTDIR ".."
583
584
/* Quote argument (before cpp) */
585
#ifndef QUOTE_ARG
586
# define QUOTE_ARG(x) #x
587
#endif
588
/* Quote argument, (after cpp) */
589
#ifndef STRINGIFY_ARG
590
# define STRINGIFY_ARG(x) QUOTE_ARG(x)
591
#endif
592
593
/*
594
 * The macros below are borrowed from include/linux/compiler.h in the
595
 * Linux kernel. Use them to indicate the likelyhood of the truthfulness
596
 * of a condition. This serves two purposes - newer versions of gcc will be
597
 * able to optimize for branch predication, which could yield siginficant
598
 * performance gains in frequently executed sections of the code, and the
599
 * other reason to use them is for documentation
600
 */
601
#if !defined(__GNUC__)
602
#define __builtin_expect(x, expected_value) (x)
603
#endif
604
605
#define likely(x)  __builtin_expect((x),1)
606
#define unlikely(x)  __builtin_expect((x),0)
607
608
609
/*
610
  Only Linux is known to need an explicit sync of the directory to make sure a
611
  file creation/deletion/renaming in(from,to) this directory durable.
612
*/
613
#ifdef TARGET_OS_LINUX
614
#define NEED_EXPLICIT_SYNC_DIR 1
615
#endif
616
617
/* We need to turn off _DTRACE_VERSION if we're not going to use dtrace */
618
#if !defined(HAVE_DTRACE)
619
# undef _DTRACE_VERSION
620
# define _DTRACE_VERSION 0
621
#endif
622
1802.16.11 by Padraig O'Sullivan
Remove cpp and header file with MyBitmap class and associated functions. No longer needed.
623
typedef uint64_t table_map;   /* Used for table bits in join */
624
typedef uint32_t nesting_map; /* Used for flags of nesting constructs */
625
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
626
} /* namespace drizzled */
627
1119.9.4 by Jay Pipes
Removes the FIELDFLAG_NO_DEFAULT bit and f_no_default macro and calls
628
#endif /* DRIZZLED_DEFINITIONS_H */