~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
222
#define UNCACHEABLE_DEPENDENT   1
223
#define UNCACHEABLE_RAND        2
224
#define UNCACHEABLE_SIDEEFFECT	4
225
/// forcing to save JOIN for explain
226
#define UNCACHEABLE_EXPLAIN     8
227
/** Don't evaluate subqueries in prepare even if they're not correlated */
228
#define UNCACHEABLE_PREPARE    16
229
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
230
#define UNCACHEABLE_UNITED     32
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() */
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
240
241
/* Some portable defines */
242
243
#define portable_sizeof_char_ptr 8
244
584.2.1 by Stewart Smith
convert tmp_file_prefix to TMP_FILE_PREFIX to indicate it's a macro
245
#define TMP_FILE_PREFIX "#sql"			/**< Prefix for tmp tables */
246
#define TMP_FILE_PREFIX_LENGTH 4
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
247
248
/* Flags for calc_week() function.  */
249
#define WEEK_MONDAY_FIRST    1
250
#define WEEK_YEAR            2
251
#define WEEK_FIRST_WEEKDAY   4
252
574.3.17 by Lee
moving functions from item_timefunc to functions/time directory
253
/* used in date and time conversions */
254
/* Daynumber from year 0 to 9999-12-31 */
255
#define MAX_DAY_NUMBER 3652424L
256
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
257
#define STRING_BUFFER_USUAL_SIZE 80
258
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
259
typedef void *range_seq_t;
260
1130.1.5 by Monty Taylor
Split StorageEngine into slot. This completes the plugin-slot-reorg. Woot.
261
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
520.8.6 by Monty Taylor
Removed handler from common_includes.
262
// the following is for checking tables
263
264
#define HA_ADMIN_ALREADY_DONE	  1
265
#define HA_ADMIN_OK               0
266
#define HA_ADMIN_NOT_IMPLEMENTED -1
267
#define HA_ADMIN_FAILED		 -2
268
#define HA_ADMIN_CORRUPT         -3
269
#define HA_ADMIN_INTERNAL_ERROR  -4
270
#define HA_ADMIN_INVALID         -5
271
#define HA_ADMIN_REJECT          -6
272
273
/* bits in index_flags(index_number) for what you can do with index */
274
#define HA_READ_NEXT            1       /* TODO really use this flag */
275
#define HA_READ_PREV            2       /* supports ::index_prev */
276
#define HA_READ_ORDER           4       /* index_next/prev follow sort order */
277
#define HA_READ_RANGE           8       /* can find all records in a range */
278
#define HA_ONLY_WHOLE_INDEX	16	/* Can't use part key searches */
279
#define HA_KEYREAD_ONLY         64	/* Support HA_EXTRA_KEYREAD */
280
/*
281
  Index scan will not return records in rowid order. Not guaranteed to be
282
  set for unordered (e.g. HASH) indexes.
283
*/
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
284
#define HA_KEY_SCAN_NOT_ROR     128
520.8.6 by Monty Taylor
Removed handler from common_includes.
285
286
/* operations for disable/enable indexes */
287
#define HA_KEY_SWITCH_NONUNIQ      0
288
#define HA_KEY_SWITCH_ALL          1
289
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
290
#define HA_KEY_SWITCH_ALL_SAVE     3
291
292
/*
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
  Parameters for open() (in register form->filestat)
303
  HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
304
*/
305
306
#define HA_OPEN_KEYFILE		1
307
#define HA_OPEN_RNDFILE		2
308
#define HA_GET_INDEX		4
309
#define HA_GET_INFO		8	/* do a ha_info() after open */
310
#define HA_READ_ONLY		16	/* File opened as readonly */
311
/* Try readonly if can't open with read and write */
312
#define HA_TRY_READ_ONLY	32
313
#define HA_WAIT_IF_LOCKED	64	/* Wait if locked on open */
314
#define HA_ABORT_IF_LOCKED	128	/* skip if locked on open.*/
315
#define HA_BLOCK_LOCK		256	/* unlock when reading some records */
316
#define HA_OPEN_TEMPORARY	512
317
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
/* Some key definitions */
323
#define HA_KEY_NULL_LENGTH	1
324
#define HA_KEY_BLOB_LENGTH	2
325
326
#define HA_MAX_REC_LENGTH	65535
327
328
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
1206.1.3 by Brian Aker
Valgrind fix for startTransaction()
329
enum start_transaction_option_t
330
{
331
  START_TRANS_NO_OPTIONS,
332
  START_TRANS_OPT_WITH_CONS_SNAPSHOT
333
};
520.8.6 by Monty Taylor
Removed handler from common_includes.
334
335
/* Flags for method is_fatal_error */
336
#define HA_CHECK_DUP_KEY 1
337
#define HA_CHECK_DUP_UNIQUE 2
338
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
339
340
341
/* Bits in used_fields */
342
#define HA_CREATE_USED_AUTO             (1L << 0)
343
#define HA_CREATE_USED_CHARSET          (1L << 8)
344
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
345
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
346
347
/*
348
  The below two are not used (and not handled) in this milestone of this WL
349
  entry because there seems to be no use for them at this stage of
350
  implementation.
351
*/
352
#define HA_MRR_SINGLE_POINT 1
353
#define HA_MRR_FIXED_KEY  2
354
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
355
/*
520.8.6 by Monty Taylor
Removed handler from common_includes.
356
  Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
357
  'range' parameter.
358
*/
359
#define HA_MRR_NO_ASSOCIATION 4
360
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
361
/*
520.8.6 by Monty Taylor
Removed handler from common_includes.
362
  The MRR user will provide ranges in key order, and MRR implementation
363
  must return rows in key order.
364
*/
365
#define HA_MRR_SORTED 8
366
367
/* MRR implementation doesn't have to retrieve full records */
368
#define HA_MRR_INDEX_ONLY 16
369
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
370
/*
520.8.6 by Monty Taylor
Removed handler from common_includes.
371
  The passed memory buffer is of maximum possible size, the caller can't
372
  assume larger buffer.
373
*/
374
#define HA_MRR_LIMITS 32
375
376
377
/*
378
  Flag set <=> default MRR implementation is used
379
  (The choice is made by **_info[_const]() function which may set this
380
   flag. SQL layer remembers the flag value and then passes it to
381
   multi_read_range_init().
382
*/
383
#define HA_MRR_USE_DEFAULT_IMPL 64
384
575.1.6 by Monty Taylor
Cleaned up some headers for PCH.
385
typedef int myf;
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
386
#define MYF(v)		(static_cast<drizzled::myf>(v))
575.1.6 by Monty Taylor
Cleaned up some headers for PCH.
387
584.4.1 by Monty Taylor
Split out DTCollation.
388
/*
389
   "Declared Type Collation"
390
   A combination of collation and its derivation.
391
392
  Flags for collation aggregation modes:
393
  MY_COLL_ALLOW_SUPERSET_CONV  - allow conversion to a superset
394
  MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
395
                                 (i.e. constant).
396
  MY_COLL_ALLOW_CONV           - allow any kind of conversion
397
                                 (combination of the above two)
398
  MY_COLL_DISALLOW_NONE        - don't allow return DERIVATION_NONE
399
                                 (e.g. when aggregating for comparison)
400
  MY_COLL_CMP_CONV             - combination of MY_COLL_ALLOW_CONV
401
                                 and MY_COLL_DISALLOW_NONE
402
*/
403
404
#define MY_COLL_ALLOW_SUPERSET_CONV   1
405
#define MY_COLL_ALLOW_COERCIBLE_CONV  2
406
#define MY_COLL_ALLOW_CONV            3
407
#define MY_COLL_DISALLOW_NONE         4
408
#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.
409
#define clear_timestamp_auto_bits(_target_, _bits_) \
410
  (_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
411
584.5.1 by Monty Taylor
Removed field includes from field.h.
412
/*
413
 * The following are for the interface with the .frm file
414
 */
415
416
#define FIELDFLAG_PACK_SHIFT    3
417
#define FIELDFLAG_MAX_DEC    31
418
419
#define MTYP_TYPENR(type) (type & 127)  /* Remove bits from type */
420
421
#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
422
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
423
424
#ifdef __cplusplus
425
template <class T> void set_if_bigger(T &a, const T &b)
426
{
427
  if (a < b)
428
    a=b;
429
}
430
431
template <class T> void set_if_smaller(T &a, const T &b)
432
{
433
  if (a > b)
434
    a=b;
435
}
436
#else
437
#ifdef __GNUC__
438
#define set_if_bigger(a,b) do {                 \
439
  const typeof(a) _a = (a);                     \
440
  const typeof(b) _b = (b);                     \
441
  (void) (&_a == &_b);                          \
442
  if ((a) < (b)) (a)=(b);                       \
443
  } while(0)
444
#define set_if_smaller(a,b) do {                \
445
  const typeof(a) _a = (a);                     \
446
  const typeof(b) _b = (b);                     \
447
  (void) (&_a == &_b);                          \
448
  if ((a) > (b)) (a)=(b);                       \
449
  } while(0)
450
451
#else
452
#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
453
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
454
#endif
455
#endif
456
1241.9.6 by Monty Taylor
Enhanced our version of array_elements.
457
458
#define array_elements(a) \
459
  ((sizeof(a) / sizeof(*(a))) / \
460
   static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
461
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
462
463
/* Some types that is different between systems */
464
465
#ifndef FN_LIBCHAR
466
#define FN_LIBCHAR  '/'
467
#define FN_ROOTDIR  "/"
468
#endif
469
#define MY_NFILE  64  /* This is only used to save filenames */
470
#ifndef OS_FILE_LIMIT
471
#define OS_FILE_LIMIT  65535
472
#endif
473
474
/*
475
  How much overhead does malloc have. The code often allocates
476
  something like 1024-MALLOC_OVERHEAD bytes
477
*/
478
#define MALLOC_OVERHEAD 8
479
480
/* get memory in huncs */
481
static const uint32_t ONCE_ALLOC_INIT= 4096;
482
/* Typical record cash */
483
static const uint32_t RECORD_CACHE_SIZE= 64*1024;
484
485
486
/* Some things that this system doesn't have */
487
488
/* Some defines of functions for portability */
489
490
#ifndef uint64_t2double
491
#define uint64_t2double(A) ((double) (uint64_t) (A))
492
#endif
493
494
#ifndef offsetof
495
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
496
#endif
497
#define ulong_to_double(X) ((double) (ulong) (X))
498
499
/* From limits.h instead */
500
#ifndef DBL_MIN
501
#define DBL_MIN    4.94065645841246544e-324
502
#endif
503
#ifndef DBL_MAX
504
#define DBL_MAX    1.79769313486231470e+308
505
#endif
506
507
508
/* Define missing math constants. */
509
#ifndef M_PI
510
#define M_PI 3.14159265358979323846
511
#endif
512
#ifndef M_E
513
#define M_E 2.7182818284590452354
514
#endif
515
#ifndef M_LN2
516
#define M_LN2 0.69314718055994530942
517
#endif
518
519
/*
520
  Max size that must be added to a so that we know Size to make
521
  adressable obj.
522
*/
523
#define MY_ALIGN(A,L)  (((A) + (L) - 1) & ~((L) - 1))
524
#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)
1241.13.2 by Monty Taylor
Merged in change from Trond.
529
#ifdef __cplusplus
530
#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
#else
533
 #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
#endif
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
536
537
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
538
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
539
540
/* Typdefs for easyier portability */
541
542
543
#if defined(SIZEOF_OFF_T)
544
# if (SIZEOF_OFF_T == 8)
545
#  define OFF_T_MAX (INT64_MAX)
546
# else
547
#  define OFF_T_MAX (INT32_MAX)
548
# endif
549
#endif
550
551
#define MY_FILEPOS_ERROR  -1
552
553
#define DRIZZLE_SERVER
554
555
/* Length of decimal number represented by INT32. */
556
#define MY_INT32_NUM_DECIMAL_DIGITS 11
557
558
/* Length of decimal number represented by INT64. */
559
#define MY_INT64_NUM_DECIMAL_DIGITS 21
560
561
/*
562
  Io buffer size; Must be a power of 2 and
563
  a multiple of 512. May be
564
  smaller what the disk page size. This influences the speed of the
565
  isam btree library. eg to big to slow.
566
*/
567
#define IO_SIZE 4096
568
/* Max file name len */
569
#define FN_LEN 256
570
/* Max length of extension (part of FN_LEN) */
571
#define FN_EXTLEN 20
572
/* Max length of full path-name */
573
#define FN_REFLEN 512
574
/* File extension character */
575
#define FN_EXTCHAR '.'
576
/* ~ is used as abbrev for home dir */
577
#define FN_HOMELIB '~'
578
/* ./ is used as abbrev for current dir */
579
#define FN_CURLIB '.'
580
/* Parent directory; Must be a string */
581
#define FN_PARENTDIR ".."
582
583
/* Quote argument (before cpp) */
584
#ifndef QUOTE_ARG
585
# define QUOTE_ARG(x) #x
586
#endif
587
/* Quote argument, (after cpp) */
588
#ifndef STRINGIFY_ARG
589
# define STRINGIFY_ARG(x) QUOTE_ARG(x)
590
#endif
591
592
/*
593
 * The macros below are borrowed from include/linux/compiler.h in the
594
 * Linux kernel. Use them to indicate the likelyhood of the truthfulness
595
 * of a condition. This serves two purposes - newer versions of gcc will be
596
 * able to optimize for branch predication, which could yield siginficant
597
 * performance gains in frequently executed sections of the code, and the
598
 * other reason to use them is for documentation
599
 */
600
#if !defined(__GNUC__)
601
#define __builtin_expect(x, expected_value) (x)
602
#endif
603
604
#define likely(x)  __builtin_expect((x),1)
605
#define unlikely(x)  __builtin_expect((x),0)
606
607
608
/*
609
  Only Linux is known to need an explicit sync of the directory to make sure a
610
  file creation/deletion/renaming in(from,to) this directory durable.
611
*/
612
#ifdef TARGET_OS_LINUX
613
#define NEED_EXPLICIT_SYNC_DIR 1
614
#endif
615
616
/* We need to turn off _DTRACE_VERSION if we're not going to use dtrace */
617
#if !defined(HAVE_DTRACE)
618
# undef _DTRACE_VERSION
619
# define _DTRACE_VERSION 0
620
#endif
621
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
622
} /* namespace drizzled */
623
1119.9.4 by Jay Pipes
Removes the FIELDFLAG_NO_DEFAULT bit and f_no_default macro and calls
624
#endif /* DRIZZLED_DEFINITIONS_H */