~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
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
33
/* These paths are converted to other systems (WIN95) before use */
34
35
#define LANGUAGE	"english/"
36
#define TEMP_PREFIX	"MY"
37
#define LOG_PREFIX	"ML"
38
#define PROGDIR		"bin/"
39
549 by Monty Taylor
Took gettext.h out of header files.
40
#define ER(X) error_message((X))
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
41
42
#define LIBLEN FN_REFLEN-FN_LEN			/* Max l{ngd p} dev */
43
/* extra 4+4 bytes for slave tmp tables */
44
#define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
45
#define MAX_ALIAS_NAME 256
46
#define MAX_FIELD_NAME 34			/* Max colum name length +2 */
47
#define MAX_SYS_VAR_LENGTH 32
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
48
#define MAX_INDEXES 64
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
49
#define MAX_KEY MAX_INDEXES                     /* Max used keys */
50
#define MAX_REF_PARTS 16			/* Max parts used as ref */
51
#define MAX_KEY_LENGTH 4096			/* max possible key */
52
#define MAX_KEY_LENGTH_DECIMAL_WIDTH 4          /* strlen("4096") */
53
#if SIZEOF_OFF_T > 4
54
#define MAX_REFLENGTH 8				/* Max length for record ref */
55
#else
56
#define MAX_REFLENGTH 4				/* Max length for record ref */
57
#endif
58
#define MAX_HOSTNAME  61			/* len+1 in mysql.user */
59
60
#define MAX_MBWIDTH		4		/* Max multibyte sequence */
61
#define MAX_FIELD_CHARLENGTH	255
62
#define MAX_FIELD_VARCHARLENGTH	65535
63
#define CONVERT_IF_BIGGER_TO_BLOB 512		/* Used for CREATE ... SELECT */
64
65
/* Max column width +1 */
66
#define MAX_FIELD_WIDTH		(MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
67
68
#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
69
70
#define MAX_TABLES	(sizeof(table_map)*8-3)	/* Max tables in join */
71
#define PARAM_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-3))
72
#define OUTER_REF_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-2))
73
#define RAND_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-1))
74
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
75
                           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.
76
#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
77
78
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
79
80
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
81
#define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
82
83
/* Memory allocated when parsing a statement / saving a statement */
84
#define MEM_ROOT_BLOCK_SIZE       8192
85
#define MEM_ROOT_PREALLOC         8192
86
87
#define DEFAULT_ERROR_COUNT	64
88
#define EXTRA_RECORDS	10			/* Extra records in sort */
89
#define SCROLL_EXTRA	5			/* Extra scroll-rows. */
895 by Brian Aker
Completion (?) of uint conversion.
90
#define FIELD_NAME_USED ((uint32_t) 32768)		/* Bit set if fieldname used */
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
91
#define FIELD_NR_MASK	16383			/* To get fieldnumber */
92
#define FERR		-1			/* Error from my_functions */
93
#define CREATE_MODE	0			/* Default mode on new files */
94
#define NAMES_SEP_CHAR	'\377'			/* Char to sep. names */
95
895 by Brian Aker
Completion (?) of uint conversion.
96
#define READ_RECORD_BUFFER	(uint32_t) (IO_SIZE*8) /* Pointer_buffer_size */
97
#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
98
99
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
100
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
101
#define MYF_RW MYF(MY_WME+MY_NABP)		/* Vid my_read & my_write */
102
103
/*
104
  Minimum length pattern before Turbo Boyer-Moore is used
105
  for SELECT "text" LIKE "%pattern%", excluding the two
106
  wildcards in class Item_func_like.
107
*/
108
#define MIN_TURBOBM_PATTERN_LEN 3
109
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
110
/*
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
111
   Defines for binary logging.
112
   Do not decrease the value of BIN_LOG_HEADER_SIZE.
113
   Do not even increase it before checking code.
114
*/
115
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
116
#define BIN_LOG_HEADER_SIZE    4
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
117
118
#define COLUMN_FORMAT_MASK 7
119
#define COLUMN_FORMAT_SHIFT 3
120
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
121
/* Below are #defines that used to be in mysql_priv.h */
122
/***************************************************************************
123
  Configuration parameters
124
****************************************************************************/
125
#define MAX_FIELDS_BEFORE_HASH	32
126
#define USER_VARS_HASH_SIZE     16
127
#define TABLE_OPEN_CACHE_MIN    64
876 by Brian Aker
Removed some dead definitions.
128
#define TABLE_OPEN_CACHE_DEFAULT 1024
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
129
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
130
/*
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
131
 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:
132
 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
133
 100 bytes as reasonable buffer against growth and other environments'
134
 requirements.)
135
136
 Feel free to raise this by the smallest amount you can to get the
137
 "execution_constants" test to pass.
138
 */
139
#define STACK_MIN_SIZE          12000   ///< Abort if less stack during eval.
140
141
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
142
#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
143
144
#define TEMP_POOL_SIZE          128
145
146
#define QUERY_ALLOC_BLOCK_SIZE		8192
147
#define QUERY_ALLOC_PREALLOC_SIZE   	8192
148
#define TRANS_ALLOC_BLOCK_SIZE		4096
149
#define TRANS_ALLOC_PREALLOC_SIZE	4096
150
#define RANGE_ALLOC_BLOCK_SIZE		4096
151
#define TABLE_ALLOC_BLOCK_SIZE		1024
152
#define WARN_ALLOC_BLOCK_SIZE		2048
153
#define WARN_ALLOC_PREALLOC_SIZE	1024
154
155
/*
156
  The following parameters is to decide when to use an extra cache to
157
  optimise seeks when reading a big table in sorted order
158
*/
159
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
160
#define MIN_ROWS_TO_USE_TABLE_CACHE	 100
161
#define MIN_ROWS_TO_USE_BULK_INSERT	 100
162
163
/**
164
  The following is used to decide if MySQL should use table scanning
165
  instead of reading with keys.  The number says how many evaluation of the
166
  WHERE clause is comparable to reading one extra row from a table.
167
*/
168
#define TIME_FOR_COMPARE   5	// 5 compares == one read
169
170
/**
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
171
  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
172
  table.
173
*/
174
#define TIME_FOR_COMPARE_ROWID  (TIME_FOR_COMPARE*2)
175
176
/*
177
  For sequential disk seeks the cost formula is:
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
178
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip
179
180
  The cost of average seek
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
181
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
182
*/
183
#define DISK_SEEK_BASE_COST ((double)0.9)
184
185
#define BLOCKS_IN_AVG_SEEK  128
186
187
#define DISK_SEEK_PROP_COST ((double)0.1/BLOCKS_IN_AVG_SEEK)
188
189
190
/**
191
  Number of rows in a reference table when refereed through a not unique key.
192
  This value is only used when we don't know anything about the key
193
  distribution.
194
*/
195
#define MATCHING_ROWS_IN_OTHER_TABLE 10
196
197
/** Don't pack string keys shorter than this (if PACK_KEYS=1 isn't used). */
198
#define KEY_DEFAULT_PACK_LENGTH 8
199
200
/** Characters shown for the command in 'show processlist'. */
201
#define PROCESS_LIST_WIDTH 100
202
/* Characters shown for the command in 'information_schema.processlist' */
203
#define PROCESS_LIST_INFO_WIDTH 65535
204
205
#define PRECISION_FOR_DOUBLE 53
206
#define PRECISION_FOR_FLOAT  24
207
208
/* The following can also be changed from the command line */
209
#define DEFAULT_CONCURRENCY	10
210
#define FLUSH_TIME		0		/**< Don't flush tables */
211
#define MAX_CONNECT_ERRORS	10		///< errors before disabling host
212
213
#define INTERRUPT_PRIOR 10
214
#define CONNECT_PRIOR	9
215
#define WAIT_PRIOR	8
216
#define QUERY_PRIOR	6
217
1089.6.2 by Padraig O'Sullivan
Modified the size of the test_flags bitset to be 12 bits instead of 32. No
218
/* Bits from testflag */
219
enum test_flag_bit
220
{
221
  TEST_PRINT_CACHED_TABLES= 1,
222
  TEST_NO_KEY_GROUP,
223
  TEST_MIT_THREAD,
224
  TEST_KEEP_TMP_TABLES,
225
  TEST_READCHECK, /**< Force use of readcheck */
226
  TEST_NO_EXTRA,
227
  TEST_CORE_ON_SIGNAL, /**< Give core if signal */
228
  TEST_NO_STACKTRACE,
229
  TEST_SIGINT, /**< Allow sigint on threads */
230
  TEST_SYNCHRONIZATION /**< get server to do sleep in some places */
231
};
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
232
233
/* Bits for different SQL modes modes (including ANSI mode) */
361 by Brian Aker
One more mode down, two more left to go!
234
#define MODE_NO_ZERO_DATE		(2)
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
235
#define MODE_INVALID_DATES		(MODE_NO_ZERO_DATE*2)
236
237
#define MY_CHARSET_BIN_MB_MAXLEN 1
238
239
// uncachable cause
240
#define UNCACHEABLE_DEPENDENT   1
241
#define UNCACHEABLE_RAND        2
242
#define UNCACHEABLE_SIDEEFFECT	4
243
/// forcing to save JOIN for explain
244
#define UNCACHEABLE_EXPLAIN     8
245
/** Don't evaluate subqueries in prepare even if they're not correlated */
246
#define UNCACHEABLE_PREPARE    16
247
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
248
#define UNCACHEABLE_UNITED     32
249
250
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
251
#define UNDEF_POS (-1)
252
253
/* sql_show.cc:show_log_files() */
254
#define SHOW_LOG_STATUS_FREE "FREE"
255
#define SHOW_LOG_STATUS_INUSE "IN USE"
256
257
/* Options to add_table_to_list() */
258
#define TL_OPTION_UPDATING	1
259
#define TL_OPTION_FORCE_INDEX	2
260
#define TL_OPTION_IGNORE_LEAVES 4
261
#define TL_OPTION_ALIAS         8
262
263
/* Some portable defines */
264
265
#define portable_sizeof_char_ptr 8
266
584.2.1 by Stewart Smith
convert tmp_file_prefix to TMP_FILE_PREFIX to indicate it's a macro
267
#define TMP_FILE_PREFIX "#sql"			/**< Prefix for tmp tables */
268
#define TMP_FILE_PREFIX_LENGTH 4
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
269
270
/* Flags for calc_week() function.  */
271
#define WEEK_MONDAY_FIRST    1
272
#define WEEK_YEAR            2
273
#define WEEK_FIRST_WEEKDAY   4
274
574.3.17 by Lee
moving functions from item_timefunc to functions/time directory
275
/* used in date and time conversions */
276
/* Daynumber from year 0 to 9999-12-31 */
277
#define MAX_DAY_NUMBER 3652424L
278
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
279
#define STRING_BUFFER_USUAL_SIZE 80
280
281
/*
282
  Some defines for exit codes for ::is_equal class functions.
283
*/
284
#define IS_EQUAL_NO 0
285
#define IS_EQUAL_YES 1
286
#define IS_EQUAL_PACK_LENGTH 2
287
561.1.3 by Monty Taylor
Split some more things out of common_includes.h.
288
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
289
typedef void *range_seq_t;
290
1130.1.5 by Monty Taylor
Split StorageEngine into slot. This completes the plugin-slot-reorg. Woot.
291
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
520.8.6 by Monty Taylor
Removed handler from common_includes.
292
// the following is for checking tables
293
294
#define HA_ADMIN_ALREADY_DONE	  1
295
#define HA_ADMIN_OK               0
296
#define HA_ADMIN_NOT_IMPLEMENTED -1
297
#define HA_ADMIN_FAILED		 -2
298
#define HA_ADMIN_CORRUPT         -3
299
#define HA_ADMIN_INTERNAL_ERROR  -4
300
#define HA_ADMIN_INVALID         -5
301
#define HA_ADMIN_REJECT          -6
302
303
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
1233.1.6 by Brian Aker
Remove table_flags from MyISAM.
304
520.8.6 by Monty Taylor
Removed handler from common_includes.
305
/* bits in index_flags(index_number) for what you can do with index */
306
#define HA_READ_NEXT            1       /* TODO really use this flag */
307
#define HA_READ_PREV            2       /* supports ::index_prev */
308
#define HA_READ_ORDER           4       /* index_next/prev follow sort order */
309
#define HA_READ_RANGE           8       /* can find all records in a range */
310
#define HA_ONLY_WHOLE_INDEX	16	/* Can't use part key searches */
311
#define HA_KEYREAD_ONLY         64	/* Support HA_EXTRA_KEYREAD */
312
/*
313
  Index scan will not return records in rowid order. Not guaranteed to be
314
  set for unordered (e.g. HASH) indexes.
315
*/
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
316
#define HA_KEY_SCAN_NOT_ROR     128
520.8.6 by Monty Taylor
Removed handler from common_includes.
317
#define HA_DO_INDEX_COND_PUSHDOWN  256 /* Supports Index Condition Pushdown */
318
319
/* operations for disable/enable indexes */
320
#define HA_KEY_SWITCH_NONUNIQ      0
321
#define HA_KEY_SWITCH_ALL          1
322
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
323
#define HA_KEY_SWITCH_ALL_SAVE     3
324
325
/*
326
  Note: the following includes binlog and closing 0.
327
  so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
328
      example + csv + heap + blackhole + federated + 0
329
  (yes, the sum is deliberately inaccurate)
330
  TODO remove the limit, use dynarrays
331
*/
332
#define MAX_HA 15
333
334
/*
335
  Parameters for open() (in register form->filestat)
336
  HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
337
*/
338
339
#define HA_OPEN_KEYFILE		1
340
#define HA_OPEN_RNDFILE		2
341
#define HA_GET_INDEX		4
342
#define HA_GET_INFO		8	/* do a ha_info() after open */
343
#define HA_READ_ONLY		16	/* File opened as readonly */
344
/* Try readonly if can't open with read and write */
345
#define HA_TRY_READ_ONLY	32
346
#define HA_WAIT_IF_LOCKED	64	/* Wait if locked on open */
347
#define HA_ABORT_IF_LOCKED	128	/* skip if locked on open.*/
348
#define HA_BLOCK_LOCK		256	/* unlock when reading some records */
349
#define HA_OPEN_TEMPORARY	512
350
351
/* For transactional LOCK Table. handler::lock_table() */
352
#define HA_LOCK_IN_SHARE_MODE      F_RDLCK
353
#define HA_LOCK_IN_EXCLUSIVE_MODE  F_WRLCK
354
355
/* Some key definitions */
356
#define HA_KEY_NULL_LENGTH	1
357
#define HA_KEY_BLOB_LENGTH	2
358
359
#define HA_MAX_REC_LENGTH	65535
360
361
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
1206.1.3 by Brian Aker
Valgrind fix for startTransaction()
362
enum start_transaction_option_t
363
{
364
  START_TRANS_NO_OPTIONS,
365
  START_TRANS_OPT_WITH_CONS_SNAPSHOT
366
};
520.8.6 by Monty Taylor
Removed handler from common_includes.
367
368
/* Flags for method is_fatal_error */
369
#define HA_CHECK_DUP_KEY 1
370
#define HA_CHECK_DUP_UNIQUE 2
371
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
372
373
374
/* Bits in used_fields */
375
#define HA_CREATE_USED_AUTO             (1L << 0)
376
#define HA_CREATE_USED_CHARSET          (1L << 8)
377
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
378
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
379
#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)
380
#define HA_CREATE_USED_BLOCK_SIZE       (1L << 22)
381
382
#define MAXGTRIDSIZE 64
383
#define MAXBQUALSIZE 64
384
385
/*
386
  The below two are not used (and not handled) in this milestone of this WL
387
  entry because there seems to be no use for them at this stage of
388
  implementation.
389
*/
390
#define HA_MRR_SINGLE_POINT 1
391
#define HA_MRR_FIXED_KEY  2
392
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
393
/*
520.8.6 by Monty Taylor
Removed handler from common_includes.
394
  Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
395
  'range' parameter.
396
*/
397
#define HA_MRR_NO_ASSOCIATION 4
398
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
399
/*
520.8.6 by Monty Taylor
Removed handler from common_includes.
400
  The MRR user will provide ranges in key order, and MRR implementation
401
  must return rows in key order.
402
*/
403
#define HA_MRR_SORTED 8
404
405
/* MRR implementation doesn't have to retrieve full records */
406
#define HA_MRR_INDEX_ONLY 16
407
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
408
/*
520.8.6 by Monty Taylor
Removed handler from common_includes.
409
  The passed memory buffer is of maximum possible size, the caller can't
410
  assume larger buffer.
411
*/
412
#define HA_MRR_LIMITS 32
413
414
415
/*
416
  Flag set <=> default MRR implementation is used
417
  (The choice is made by **_info[_const]() function which may set this
418
   flag. SQL layer remembers the flag value and then passes it to
419
   multi_read_range_init().
420
*/
421
#define HA_MRR_USE_DEFAULT_IMPL 64
422
575.1.6 by Monty Taylor
Cleaned up some headers for PCH.
423
typedef int myf;
424
#define MYF(v)		(myf) (v)
425
584.1.1 by Monty Taylor
Moved an enum def to fix Lee's problem.
426
#define MY_I_S_MAYBE_NULL 1
427
#define MY_I_S_UNSIGNED   2
428
429
584.4.1 by Monty Taylor
Split out DTCollation.
430
/*
431
   "Declared Type Collation"
432
   A combination of collation and its derivation.
433
434
  Flags for collation aggregation modes:
435
  MY_COLL_ALLOW_SUPERSET_CONV  - allow conversion to a superset
436
  MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
437
                                 (i.e. constant).
438
  MY_COLL_ALLOW_CONV           - allow any kind of conversion
439
                                 (combination of the above two)
440
  MY_COLL_DISALLOW_NONE        - don't allow return DERIVATION_NONE
441
                                 (e.g. when aggregating for comparison)
442
  MY_COLL_CMP_CONV             - combination of MY_COLL_ALLOW_CONV
443
                                 and MY_COLL_DISALLOW_NONE
444
*/
445
446
#define MY_COLL_ALLOW_SUPERSET_CONV   1
447
#define MY_COLL_ALLOW_COERCIBLE_CONV  2
448
#define MY_COLL_ALLOW_CONV            3
449
#define MY_COLL_DISALLOW_NONE         4
450
#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.
451
#define clear_timestamp_auto_bits(_target_, _bits_) \
452
  (_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
453
584.5.1 by Monty Taylor
Removed field includes from field.h.
454
/*
455
 * The following are for the interface with the .frm file
456
 */
457
458
#define FIELDFLAG_PACK_SHIFT    3
459
#define FIELDFLAG_MAX_DEC    31
460
461
#define MTYP_TYPENR(type) (type & 127)  /* Remove bits from type */
462
463
#define f_packtype(x)   (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
464
#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
465
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
466
467
#ifdef __cplusplus
468
template <class T> void set_if_bigger(T &a, const T &b)
469
{
470
  if (a < b)
471
    a=b;
472
}
473
474
template <class T> void set_if_smaller(T &a, const T &b)
475
{
476
  if (a > b)
477
    a=b;
478
}
479
#else
480
#ifdef __GNUC__
481
#define set_if_bigger(a,b) do {                 \
482
  const typeof(a) _a = (a);                     \
483
  const typeof(b) _b = (b);                     \
484
  (void) (&_a == &_b);                          \
485
  if ((a) < (b)) (a)=(b);                       \
486
  } while(0)
487
#define set_if_smaller(a,b) do {                \
488
  const typeof(a) _a = (a);                     \
489
  const typeof(b) _b = (b);                     \
490
  (void) (&_a == &_b);                          \
491
  if ((a) > (b)) (a)=(b);                       \
492
  } while(0)
493
494
#else
495
#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
496
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
497
#endif
498
#endif
499
1241.9.6 by Monty Taylor
Enhanced our version of array_elements.
500
501
#define array_elements(a) \
502
  ((sizeof(a) / sizeof(*(a))) / \
503
   static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
504
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
505
506
/* Some types that is different between systems */
507
508
#ifndef FN_LIBCHAR
509
#define FN_LIBCHAR  '/'
510
#define FN_ROOTDIR  "/"
511
#endif
512
#define MY_NFILE  64  /* This is only used to save filenames */
513
#ifndef OS_FILE_LIMIT
514
#define OS_FILE_LIMIT  65535
515
#endif
516
517
/*
518
  How much overhead does malloc have. The code often allocates
519
  something like 1024-MALLOC_OVERHEAD bytes
520
*/
521
#define MALLOC_OVERHEAD 8
522
523
/* get memory in huncs */
524
static const uint32_t ONCE_ALLOC_INIT= 4096;
525
/* Typical record cash */
526
static const uint32_t RECORD_CACHE_SIZE= 64*1024;
527
/* Typical key cash */
528
static const uint32_t KEY_CACHE_SIZE= 8*1024*1024;
529
530
/* Default size of a key cache block  */
531
static const uint32_t KEY_CACHE_BLOCK_SIZE= 1024;
532
533
534
/* Some things that this system doesn't have */
535
536
/* Some defines of functions for portability */
537
538
#undef remove    /* Crashes MySQL on SCO 5.0.0 */
539
#ifndef uint64_t2double
540
#define uint64_t2double(A) ((double) (uint64_t) (A))
541
#endif
542
543
#ifndef offsetof
544
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
545
#endif
546
#define ulong_to_double(X) ((double) (ulong) (X))
547
548
#ifndef STACK_DIRECTION
549
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
550
#endif
551
552
/* From limits.h instead */
553
#ifndef DBL_MIN
554
#define DBL_MIN    4.94065645841246544e-324
555
#endif
556
#ifndef DBL_MAX
557
#define DBL_MAX    1.79769313486231470e+308
558
#endif
559
560
561
/* Define missing math constants. */
562
#ifndef M_PI
563
#define M_PI 3.14159265358979323846
564
#endif
565
#ifndef M_E
566
#define M_E 2.7182818284590452354
567
#endif
568
#ifndef M_LN2
569
#define M_LN2 0.69314718055994530942
570
#endif
571
572
/*
573
  Max size that must be added to a so that we know Size to make
574
  adressable obj.
575
*/
576
#define MY_ALIGN(A,L)  (((A) + (L) - 1) & ~((L) - 1))
577
#define ALIGN_SIZE(A)  MY_ALIGN((A),sizeof(double))
578
/* Size to make adressable obj. */
579
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
580
/* Offset of field f in structure t */
581
#define OFFSET(t, f)  ((size_t)(char *)&((t *)0)->f)
1241.13.2 by Monty Taylor
Merged in change from Trond.
582
#ifdef __cplusplus
583
#define ADD_TO_PTR(ptr,size,type) (type) (reinterpret_cast<const unsigned char*>(ptr)+size)
584
#define PTR_BYTE_DIFF(A,B) (ptrdiff_t) (reinterpret_cast<const unsigned char*>(A) - reinterpret_cast<const unsigned char*>(B))
585
#else
586
 #define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
587
 #define PTR_BYTE_DIFF(A,B) (ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
588
#endif
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
589
590
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
591
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
592
593
/* Typdefs for easyier portability */
594
595
596
#if defined(SIZEOF_OFF_T)
597
# if (SIZEOF_OFF_T == 8)
598
#  define OFF_T_MAX (INT64_MAX)
599
# else
600
#  define OFF_T_MAX (INT32_MAX)
601
# endif
602
#endif
603
604
#define MY_FILEPOS_ERROR  -1
605
606
/* Defines for time function */
607
#define SCALE_SEC  100
608
#define SCALE_USEC  10000
609
610
#define DRIZZLE_SERVER
611
612
/* Length of decimal number represented by INT32. */
613
#define MY_INT32_NUM_DECIMAL_DIGITS 11
614
615
/* Length of decimal number represented by INT64. */
616
#define MY_INT64_NUM_DECIMAL_DIGITS 21
617
618
/*
619
  Io buffer size; Must be a power of 2 and
620
  a multiple of 512. May be
621
  smaller what the disk page size. This influences the speed of the
622
  isam btree library. eg to big to slow.
623
*/
624
#define IO_SIZE 4096
625
/* Max file name len */
626
#define FN_LEN 256
627
/* Max length of extension (part of FN_LEN) */
628
#define FN_EXTLEN 20
629
/* Max length of full path-name */
630
#define FN_REFLEN 512
631
/* File extension character */
632
#define FN_EXTCHAR '.'
633
/* ~ is used as abbrev for home dir */
634
#define FN_HOMELIB '~'
635
/* ./ is used as abbrev for current dir */
636
#define FN_CURLIB '.'
637
/* Parent directory; Must be a string */
638
#define FN_PARENTDIR ".."
639
640
/* Quote argument (before cpp) */
641
#ifndef QUOTE_ARG
642
# define QUOTE_ARG(x) #x
643
#endif
644
/* Quote argument, (after cpp) */
645
#ifndef STRINGIFY_ARG
646
# define STRINGIFY_ARG(x) QUOTE_ARG(x)
647
#endif
648
649
/*
650
 * The macros below are borrowed from include/linux/compiler.h in the
651
 * Linux kernel. Use them to indicate the likelyhood of the truthfulness
652
 * of a condition. This serves two purposes - newer versions of gcc will be
653
 * able to optimize for branch predication, which could yield siginficant
654
 * performance gains in frequently executed sections of the code, and the
655
 * other reason to use them is for documentation
656
 */
657
#if !defined(__GNUC__)
658
#define __builtin_expect(x, expected_value) (x)
659
#endif
660
661
#define likely(x)  __builtin_expect((x),1)
662
#define unlikely(x)  __builtin_expect((x),0)
663
664
665
/*
666
  Only Linux is known to need an explicit sync of the directory to make sure a
667
  file creation/deletion/renaming in(from,to) this directory durable.
668
*/
669
#ifdef TARGET_OS_LINUX
670
#define NEED_EXPLICIT_SYNC_DIR 1
671
#endif
672
673
/* We need to turn off _DTRACE_VERSION if we're not going to use dtrace */
674
#if !defined(HAVE_DTRACE)
675
# undef _DTRACE_VERSION
676
# define _DTRACE_VERSION 0
677
#endif
678
1119.9.4 by Jay Pipes
Removes the FIELDFLAG_NO_DEFAULT bit and f_no_default macro and calls
679
#endif /* DRIZZLED_DEFINITIONS_H */