~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definitions.h

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
 
20
 
20
21
/**
21
22
 * @file
22
23
 *
23
 
 * Mostly constants and some macros/functions used by the server
 
24
 * Mostly constants and some macros/functions used by the server  
24
25
 */
25
26
 
26
 
#ifndef DRIZZLED_DEFINITIONS_H
27
 
#define DRIZZLED_DEFINITIONS_H
28
 
 
29
 
#include <drizzled/enum.h>
30
 
 
31
 
#include <stdint.h>
32
 
 
33
 
namespace drizzled
34
 
{
 
27
#ifndef DRIZZLE_SERVER_DEFINITIONS_H
 
28
#define DRIZZLE_SERVER_DEFINITIONS_H
 
29
 
 
30
#ifndef NO_ALARM_LOOP
 
31
#define NO_ALARM_LOOP           /* lib5 and popen can't use alarm */
 
32
#endif
35
33
 
36
34
/* These paths are converted to other systems (WIN95) before use */
37
35
 
38
36
#define LANGUAGE        "english/"
 
37
#define ERRMSG_FILE     "errmsg.sys"
39
38
#define TEMP_PREFIX     "MY"
40
39
#define LOG_PREFIX      "ML"
41
 
 
42
 
#define ER(X) ::drizzled::error_message((X))
43
 
 
 
40
#define PROGDIR         "bin/"
 
41
#ifndef DATADIR
 
42
#define DATADIR         "data/"
 
43
#endif
 
44
#ifndef SHAREDIR
 
45
#define SHAREDIR        "share/"
 
46
#endif
 
47
#ifndef PLUGINDIR
 
48
#define PLUGINDIR       "lib/plugin"
 
49
#endif
 
50
 
 
51
#define ER(X) _(drizzled_error_messages[(X) - ER_ERROR_FIRST])
 
52
#define ER_SAFE(X) (((X) >= ER_ERROR_FIRST && (X) <= ER_ERROR_LAST) ? ER(X) : _("Invalid error code"))
 
53
 
 
54
#define ERRMAPP 1                               /* Errormap f|r my_error */
 
55
#define LIBLEN FN_REFLEN-FN_LEN                 /* Max l{ngd p} dev */
44
56
/* extra 4+4 bytes for slave tmp tables */
45
57
#define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
46
58
#define MAX_ALIAS_NAME 256
47
59
#define MAX_FIELD_NAME 34                       /* Max colum name length +2 */
48
60
#define MAX_SYS_VAR_LENGTH 32
49
 
#define MAX_INDEXES 64
50
61
#define MAX_KEY MAX_INDEXES                     /* Max used keys */
51
62
#define MAX_REF_PARTS 16                        /* Max parts used as ref */
52
63
#define MAX_KEY_LENGTH 4096                     /* max possible key */
66
77
/* Max column width +1 */
67
78
#define MAX_FIELD_WIDTH         (MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
68
79
 
 
80
#define MAX_BIT_FIELD_LENGTH    64      /* Max length in bits for bit fields */
 
81
 
 
82
#define MAX_DATE_WIDTH          10      /* YYYY-MM-DD */
 
83
#define MAX_TIME_WIDTH          23      /* -DDDDDD HH:MM:SS.###### */
 
84
#define MAX_DATETIME_FULL_WIDTH 29      /* YYYY-MM-DD HH:MM:SS.###### AM */
 
85
#define MAX_DATETIME_WIDTH      19      /* YYYY-MM-DD HH:MM:SS */
69
86
#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
70
87
 
71
88
#define MAX_TABLES      (sizeof(table_map)*8-3) /* Max tables in join */
74
91
#define RAND_TABLE_BIT  (((table_map) 1) << (sizeof(table_map)*8-1))
75
92
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
76
93
                           RAND_TABLE_BIT)
77
 
#define MAX_FIELDS      4096      /* Historical limit from MySQL FRM. */
 
94
#define MAX_FIELDS      4096                    /* Limit in the .frm file */
78
95
 
79
96
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
80
97
 
81
98
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
82
99
#define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
83
100
 
 
101
/* Memory allocated when parsing a statement / saving a statement */
 
102
#define MEM_ROOT_BLOCK_SIZE       8192
 
103
#define MEM_ROOT_PREALLOC         8192
 
104
#define TRANS_MEM_ROOT_BLOCK_SIZE 4096
 
105
#define TRANS_MEM_ROOT_PREALLOC   4096
 
106
 
84
107
#define DEFAULT_ERROR_COUNT     64
85
108
#define EXTRA_RECORDS   10                      /* Extra records in sort */
 
109
#define SCROLL_EXTRA    5                       /* Extra scroll-rows. */
 
110
#define FIELD_NAME_USED ((uint) 32768)          /* Bit set if fieldname used */
 
111
#define FORM_NAME_USED  ((uint) 16384)          /* Bit set if formname used */
 
112
#define FIELD_NR_MASK   16383                   /* To get fieldnumber */
 
113
#define FERR            -1                      /* Error from my_functions */
 
114
#define CREATE_MODE     0                       /* Default mode on new files */
86
115
#define NAMES_SEP_CHAR  '\377'                  /* Char to sep. names */
87
116
 
88
 
#define READ_RECORD_BUFFER      (uint32_t) (IO_SIZE*8) /* Pointer_buffer_size */
89
 
#define DISK_BUFFER_SIZE        (uint32_t) (IO_SIZE*16) /* Size of diskbuffer */
 
117
#define READ_RECORD_BUFFER      (uint) (IO_SIZE*8) /* Pointer_buffer_size */
 
118
#define DISK_BUFFER_SIZE        (uint) (IO_SIZE*16) /* Size of diskbuffer */
90
119
 
 
120
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
91
121
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
92
122
#define MYF_RW MYF(MY_WME+MY_NABP)              /* Vid my_read & my_write */
93
123
 
 
124
        /* Extern defines */
 
125
#define store_record(A,B) memcpy((A)->B,(A)->record[0],(size_t) (A)->s->reclength)
 
126
#define restore_record(A,B) memcpy((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
 
127
#define cmp_record(A,B) memcmp((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
 
128
#define empty_record(A)                                 \
 
129
  do {                                                  \
 
130
    restore_record((A),s->default_values);              \
 
131
    memset((A)->null_flags, 255, (A)->s->null_bytes);   \
 
132
  } while (0)
 
133
 
 
134
        /* Defines for use with openfrm, openprt and openfrd */
 
135
 
 
136
#define READ_ALL                1       /* openfrm: Read all parameters */
 
137
#define CHANGE_FRM              2       /* openfrm: open .frm as O_RDWR */
 
138
#define EXTRA_RECORD            8       /* Reservera plats f|r extra record */
 
139
#define DONT_GIVE_ERROR         256     /* Don't do frm_error on openfrm  */
 
140
#define DELAYED_OPEN            4096    /* Open table later */
 
141
/**
 
142
  This flag is used in function get_all_tables() which fills
 
143
  I_S tables with data which are retrieved from frm files and storage engine
 
144
  The flag means that we need to open FRM file only to get necessary data.
 
145
*/
 
146
#define OPEN_FRM_FILE_ONLY     32768
 
147
/**
 
148
  This flag is used in function get_all_tables() which fills
 
149
  I_S tables with data which are retrieved from frm files and storage engine
 
150
  The flag means that we need to process tables only to get necessary data.
 
151
  Views are not processed.
 
152
*/
 
153
#define OPEN_TABLE_ONLY        OPEN_FRM_FILE_ONLY*2
 
154
/**
 
155
  This flag is used in function get_all_tables() which fills
 
156
  I_S tables with data which are retrieved from frm files and storage engine.
 
157
  The flag means that I_S table uses optimization algorithm.
 
158
*/
 
159
#define OPTIMIZE_I_S_TABLE     OPEN_TABLE_ONLY*2
 
160
 
 
161
#define SC_INFO_LENGTH 4                /* Form format constant */
 
162
#define TE_INFO_LENGTH 3
 
163
#define MTYP_NOEMPTY_BIT 128
 
164
 
 
165
#define FRM_VER_TRUE_VARCHAR (FRM_VER+4) /* 10 */
 
166
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_CGE 50120
 
167
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM 50205
 
168
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_STR "50205"
 
169
 
94
170
/*
95
171
  Minimum length pattern before Turbo Boyer-Moore is used
96
172
  for SELECT "text" LIKE "%pattern%", excluding the two
98
174
*/
99
175
#define MIN_TURBOBM_PATTERN_LEN 3
100
176
 
101
 
/*
 
177
/* 
102
178
   Defines for binary logging.
103
179
   Do not decrease the value of BIN_LOG_HEADER_SIZE.
104
180
   Do not even increase it before checking code.
105
181
*/
106
182
 
107
 
#define BIN_LOG_HEADER_SIZE    4
 
183
#define BIN_LOG_HEADER_SIZE    4 
 
184
 
 
185
#define DEFAULT_KEY_CACHE_NAME "default"
 
186
 
 
187
#define STORAGE_TYPE_MASK 7
 
188
#define COLUMN_FORMAT_MASK 7
 
189
#define COLUMN_FORMAT_SHIFT 3
108
190
 
109
191
/* Below are #defines that used to be in mysql_priv.h */
110
192
/***************************************************************************
111
193
  Configuration parameters
112
194
****************************************************************************/
 
195
#define ACL_CACHE_SIZE          256
 
196
#define MAX_PASSWORD_LENGTH     32
 
197
#define HOST_CACHE_SIZE         128
 
198
#define MAX_ACCEPT_RETRY        10      // Test accept this many times
113
199
#define MAX_FIELDS_BEFORE_HASH  32
114
200
#define USER_VARS_HASH_SIZE     16
115
201
#define TABLE_OPEN_CACHE_MIN    64
116
 
#define TABLE_OPEN_CACHE_DEFAULT 1024
 
202
#define TABLE_OPEN_CACHE_DEFAULT 64
117
203
 
118
 
/*
 
204
/* 
119
205
 Value of 9236 discovered through binary search 2006-09-26 on Ubuntu Dapper
120
 
 Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added
 
206
 Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added 
121
207
 100 bytes as reasonable buffer against growth and other environments'
122
208
 requirements.)
123
209
 
129
215
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
130
216
#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
131
217
 
 
218
/** 
 
219
 * @TODO Move into a drizzled.h since it's only used in drizzled.cc
 
220
 *
 
221
 * @TODO Rename to DRIZZLED_NET_RETRY_COUNT
 
222
 */
 
223
#ifndef MYSQLD_NET_RETRY_COUNT
 
224
#define MYSQLD_NET_RETRY_COUNT  10      ///< Abort read after this many int.
 
225
#endif
 
226
#define TEMP_POOL_SIZE          128
 
227
 
132
228
#define QUERY_ALLOC_BLOCK_SIZE          8192
133
229
#define QUERY_ALLOC_PREALLOC_SIZE       8192
 
230
#define TRANS_ALLOC_BLOCK_SIZE          4096
 
231
#define TRANS_ALLOC_PREALLOC_SIZE       4096
134
232
#define RANGE_ALLOC_BLOCK_SIZE          4096
 
233
#define ACL_ALLOC_BLOCK_SIZE            1024
 
234
#define UDF_ALLOC_BLOCK_SIZE            1024
135
235
#define TABLE_ALLOC_BLOCK_SIZE          1024
 
236
#define BDB_LOG_ALLOC_BLOCK_SIZE        1024
136
237
#define WARN_ALLOC_BLOCK_SIZE           2048
137
238
#define WARN_ALLOC_PREALLOC_SIZE        1024
 
239
#define PROFILE_ALLOC_BLOCK_SIZE  2048
 
240
#define PROFILE_ALLOC_PREALLOC_SIZE 1024
138
241
 
139
242
/*
140
243
  The following parameters is to decide when to use an extra cache to
142
245
*/
143
246
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
144
247
#define MIN_ROWS_TO_USE_TABLE_CACHE      100
 
248
#define MIN_ROWS_TO_USE_BULK_INSERT      100
145
249
 
146
250
/**
147
251
  The following is used to decide if MySQL should use table scanning
151
255
#define TIME_FOR_COMPARE   5    // 5 compares == one read
152
256
 
153
257
/**
154
 
  Number of comparisons of table rowids equivalent to reading one row from a
 
258
  Number of comparisons of table rowids equivalent to reading one row from a 
155
259
  table.
156
260
*/
157
261
#define TIME_FOR_COMPARE_ROWID  (TIME_FOR_COMPARE*2)
158
262
 
159
263
/*
160
264
  For sequential disk seeks the cost formula is:
161
 
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip
162
 
 
163
 
  The cost of average seek
 
265
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip  
 
266
  
 
267
  The cost of average seek 
164
268
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
165
269
*/
166
270
#define DISK_SEEK_BASE_COST ((double)0.9)
188
292
#define PRECISION_FOR_DOUBLE 53
189
293
#define PRECISION_FOR_FLOAT  24
190
294
 
 
295
/*
 
296
  Default time to wait before aborting a new client connection
 
297
  that does not respond to "initial server greeting" timely
 
298
*/
 
299
#define CONNECT_TIMEOUT         10
 
300
 
191
301
/* The following can also be changed from the command line */
192
302
#define DEFAULT_CONCURRENCY     10
193
303
#define FLUSH_TIME              0               /**< Don't flush tables */
198
308
#define WAIT_PRIOR      8
199
309
#define QUERY_PRIOR     6
200
310
 
201
 
/* Bits from testflag */
202
 
enum test_flag_bit
203
 
{
204
 
  TEST_PRINT_CACHED_TABLES= 1,
205
 
  TEST_NO_KEY_GROUP,
206
 
  TEST_MIT_THREAD,
207
 
  TEST_KEEP_TMP_TABLES,
208
 
  TEST_READCHECK, /**< Force use of readcheck */
209
 
  TEST_NO_EXTRA,
210
 
  TEST_CORE_ON_SIGNAL, /**< Give core if signal */
211
 
  TEST_NO_STACKTRACE,
212
 
  TEST_SIGINT, /**< Allow sigint on threads */
213
 
  TEST_SYNCHRONIZATION /**< get server to do sleep in some places */
214
 
};
 
311
        /* Bits from testflag */
 
312
#define TEST_PRINT_CACHED_TABLES 1
 
313
#define TEST_NO_KEY_GROUP        2
 
314
#define TEST_MIT_THREAD         4
 
315
#define TEST_BLOCKING           8
 
316
#define TEST_KEEP_TMP_TABLES    16
 
317
#define TEST_READCHECK          64      /**< Force use of readcheck */
 
318
#define TEST_NO_EXTRA           128
 
319
#define TEST_CORE_ON_SIGNAL     256     /**< Give core if signal */
 
320
#define TEST_NO_STACKTRACE      512
 
321
#define TEST_SIGINT             1024    /**< Allow sigint on threads */
 
322
#define TEST_SYNCHRONIZATION    2048    /**< get server to do sleep in some places */
215
323
 
216
324
/* Bits for different SQL modes modes (including ANSI mode) */
217
325
#define MODE_NO_ZERO_DATE               (2)
218
326
#define MODE_INVALID_DATES              (MODE_NO_ZERO_DATE*2)
219
327
 
 
328
/* @@optimizer_switch flags */
 
329
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
 
330
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
 
331
 
220
332
#define MY_CHARSET_BIN_MB_MAXLEN 1
221
333
 
222
334
// uncachable cause
233
345
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
234
346
#define UNDEF_POS (-1)
235
347
 
 
348
/* BINLOG_DUMP options */
 
349
 
 
350
#define BINLOG_DUMP_NON_BLOCK   1
 
351
 
 
352
/* sql_show.cc:show_log_files() */
 
353
#define SHOW_LOG_STATUS_FREE "FREE"
 
354
#define SHOW_LOG_STATUS_INUSE "IN USE"
 
355
 
236
356
/* Options to add_table_to_list() */
237
357
#define TL_OPTION_UPDATING      1
238
358
#define TL_OPTION_FORCE_INDEX   2
243
363
 
244
364
#define portable_sizeof_char_ptr 8
245
365
 
246
 
#define TMP_FILE_PREFIX "#sql"                  /**< Prefix for tmp tables */
247
 
#define TMP_FILE_PREFIX_LENGTH 4
 
366
#define tmp_file_prefix "#sql"                  /**< Prefix for tmp tables */
 
367
#define tmp_file_prefix_length 4
248
368
 
249
369
/* Flags for calc_week() function.  */
250
370
#define WEEK_MONDAY_FIRST    1
251
371
#define WEEK_YEAR            2
252
372
#define WEEK_FIRST_WEEKDAY   4
253
373
 
254
 
/* used in date and time conversions */
255
 
/* Daynumber from year 0 to 9999-12-31 */
256
 
#define MAX_DAY_NUMBER 3652424L
257
 
 
258
374
#define STRING_BUFFER_USUAL_SIZE 80
259
375
 
260
 
typedef void *range_seq_t;
261
 
 
262
 
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
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
 
*/
285
 
#define HA_KEY_SCAN_NOT_ROR     128
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) */
330
 
enum start_transaction_option_t
331
 
{
332
 
  START_TRANS_NO_OPTIONS,
333
 
  START_TRANS_OPT_WITH_CONS_SNAPSHOT
334
 
};
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
 
#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)
348
 
#define HA_CREATE_USED_BLOCK_SIZE       (1L << 22)
349
 
 
350
 
/*
351
 
  The below two are not used (and not handled) in this milestone of this WL
352
 
  entry because there seems to be no use for them at this stage of
353
 
  implementation.
354
 
*/
355
 
#define HA_MRR_SINGLE_POINT 1
356
 
#define HA_MRR_FIXED_KEY  2
357
 
 
358
 
/*
359
 
  Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
360
 
  'range' parameter.
361
 
*/
362
 
#define HA_MRR_NO_ASSOCIATION 4
363
 
 
364
 
/*
365
 
  The MRR user will provide ranges in key order, and MRR implementation
366
 
  must return rows in key order.
367
 
*/
368
 
#define HA_MRR_SORTED 8
369
 
 
370
 
/* MRR implementation doesn't have to retrieve full records */
371
 
#define HA_MRR_INDEX_ONLY 16
372
 
 
373
 
/*
374
 
  The passed memory buffer is of maximum possible size, the caller can't
375
 
  assume larger buffer.
376
 
*/
377
 
#define HA_MRR_LIMITS 32
378
 
 
379
 
 
380
 
/*
381
 
  Flag set <=> default MRR implementation is used
382
 
  (The choice is made by **_info[_const]() function which may set this
383
 
   flag. SQL layer remembers the flag value and then passes it to
384
 
   multi_read_range_init().
385
 
*/
386
 
#define HA_MRR_USE_DEFAULT_IMPL 64
387
 
 
388
 
typedef int myf;
389
 
#define MYF(v)          (static_cast<drizzled::myf>(v))
390
 
 
391
 
/*
392
 
   "Declared Type Collation"
393
 
   A combination of collation and its derivation.
394
 
 
395
 
  Flags for collation aggregation modes:
396
 
  MY_COLL_ALLOW_SUPERSET_CONV  - allow conversion to a superset
397
 
  MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
398
 
                                 (i.e. constant).
399
 
  MY_COLL_ALLOW_CONV           - allow any kind of conversion
400
 
                                 (combination of the above two)
401
 
  MY_COLL_DISALLOW_NONE        - don't allow return DERIVATION_NONE
402
 
                                 (e.g. when aggregating for comparison)
403
 
  MY_COLL_CMP_CONV             - combination of MY_COLL_ALLOW_CONV
404
 
                                 and MY_COLL_DISALLOW_NONE
405
 
*/
406
 
 
407
 
#define MY_COLL_ALLOW_SUPERSET_CONV   1
408
 
#define MY_COLL_ALLOW_COERCIBLE_CONV  2
409
 
#define MY_COLL_ALLOW_CONV            3
410
 
#define MY_COLL_DISALLOW_NONE         4
411
 
#define MY_COLL_CMP_CONV              7
412
 
#define clear_timestamp_auto_bits(_target_, _bits_) \
413
 
  (_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
414
 
 
415
 
/*
416
 
 * The following are for the interface with the .frm file
417
 
 */
418
 
 
419
 
#define FIELDFLAG_PACK_SHIFT    3
420
 
#define FIELDFLAG_MAX_DEC    31
421
 
 
422
 
#define MTYP_TYPENR(type) (type & 127)  /* Remove bits from type */
423
 
 
424
 
#define f_settype(x)    (((int) x) << FIELDFLAG_PACK_SHIFT)
425
 
 
426
 
 
427
 
#ifdef __cplusplus
428
 
template <class T> void set_if_bigger(T &a, const T &b)
429
 
{
430
 
  if (a < b)
431
 
    a=b;
432
 
}
433
 
 
434
 
template <class T> void set_if_smaller(T &a, const T &b)
435
 
{
436
 
  if (a > b)
437
 
    a=b;
438
 
}
439
 
#else
440
 
#ifdef __GNUC__
441
 
#define set_if_bigger(a,b) do {                 \
442
 
  const typeof(a) _a = (a);                     \
443
 
  const typeof(b) _b = (b);                     \
444
 
  (void) (&_a == &_b);                          \
445
 
  if ((a) < (b)) (a)=(b);                       \
446
 
  } while(0)
447
 
#define set_if_smaller(a,b) do {                \
448
 
  const typeof(a) _a = (a);                     \
449
 
  const typeof(b) _b = (b);                     \
450
 
  (void) (&_a == &_b);                          \
451
 
  if ((a) > (b)) (a)=(b);                       \
452
 
  } while(0)
453
 
 
454
 
#else
455
 
#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
456
 
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
457
 
#endif
458
 
#endif
459
 
 
460
 
 
461
 
#define array_elements(a) \
462
 
  ((sizeof(a) / sizeof(*(a))) / \
463
 
   static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
464
 
 
465
 
 
466
 
/* Some types that is different between systems */
467
 
 
468
 
#ifndef FN_LIBCHAR
469
 
#define FN_LIBCHAR  '/'
470
 
#define FN_ROOTDIR  "/"
471
 
#endif
472
 
#define MY_NFILE  64  /* This is only used to save filenames */
473
 
#ifndef OS_FILE_LIMIT
474
 
#define OS_FILE_LIMIT  65535
475
 
#endif
476
 
 
477
 
/*
478
 
  How much overhead does malloc have. The code often allocates
479
 
  something like 1024-MALLOC_OVERHEAD bytes
480
 
*/
481
 
#define MALLOC_OVERHEAD 8
482
 
 
483
 
/* get memory in huncs */
484
 
static const uint32_t ONCE_ALLOC_INIT= 4096;
485
 
/* Typical record cash */
486
 
static const uint32_t RECORD_CACHE_SIZE= 64*1024;
487
 
/* Typical key cash */
488
 
static const uint32_t KEY_CACHE_SIZE= 8*1024*1024;
489
 
 
490
 
/* Default size of a key cache block  */
491
 
static const uint32_t KEY_CACHE_BLOCK_SIZE= 1024;
492
 
 
493
 
 
494
 
/* Some things that this system doesn't have */
495
 
 
496
 
/* Some defines of functions for portability */
497
 
 
498
 
#ifndef uint64_t2double
499
 
#define uint64_t2double(A) ((double) (uint64_t) (A))
500
 
#endif
501
 
 
502
 
#ifndef offsetof
503
 
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
504
 
#endif
505
 
#define ulong_to_double(X) ((double) (ulong) (X))
506
 
 
507
 
/* From limits.h instead */
508
 
#ifndef DBL_MIN
509
 
#define DBL_MIN    4.94065645841246544e-324
510
 
#endif
511
 
#ifndef DBL_MAX
512
 
#define DBL_MAX    1.79769313486231470e+308
513
 
#endif
514
 
 
515
 
 
516
 
/* Define missing math constants. */
517
 
#ifndef M_PI
518
 
#define M_PI 3.14159265358979323846
519
 
#endif
520
 
#ifndef M_E
521
 
#define M_E 2.7182818284590452354
522
 
#endif
523
 
#ifndef M_LN2
524
 
#define M_LN2 0.69314718055994530942
525
 
#endif
526
 
 
527
 
/*
528
 
  Max size that must be added to a so that we know Size to make
529
 
  adressable obj.
530
 
*/
531
 
#define MY_ALIGN(A,L)  (((A) + (L) - 1) & ~((L) - 1))
532
 
#define ALIGN_SIZE(A)  MY_ALIGN((A),sizeof(double))
533
 
/* Size to make adressable obj. */
534
 
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
535
 
/* Offset of field f in structure t */
536
 
#define OFFSET(t, f)  ((size_t)(char *)&((t *)0)->f)
537
 
#ifdef __cplusplus
538
 
#define ADD_TO_PTR(ptr,size,type) (type) (reinterpret_cast<const unsigned char*>(ptr)+size)
539
 
#define PTR_BYTE_DIFF(A,B) (ptrdiff_t) (reinterpret_cast<const unsigned char*>(A) - reinterpret_cast<const unsigned char*>(B))
540
 
#else
541
 
 #define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
542
 
 #define PTR_BYTE_DIFF(A,B) (ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
543
 
#endif
544
 
 
545
 
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
546
 
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
547
 
 
548
 
/* Typdefs for easyier portability */
549
 
 
550
 
 
551
 
#if defined(SIZEOF_OFF_T)
552
 
# if (SIZEOF_OFF_T == 8)
553
 
#  define OFF_T_MAX (INT64_MAX)
554
 
# else
555
 
#  define OFF_T_MAX (INT32_MAX)
556
 
# endif
557
 
#endif
558
 
 
559
 
#define MY_FILEPOS_ERROR  -1
560
 
 
561
 
#define DRIZZLE_SERVER
562
 
 
563
 
/* Length of decimal number represented by INT32. */
564
 
#define MY_INT32_NUM_DECIMAL_DIGITS 11
565
 
 
566
 
/* Length of decimal number represented by INT64. */
567
 
#define MY_INT64_NUM_DECIMAL_DIGITS 21
568
 
 
569
 
/*
570
 
  Io buffer size; Must be a power of 2 and
571
 
  a multiple of 512. May be
572
 
  smaller what the disk page size. This influences the speed of the
573
 
  isam btree library. eg to big to slow.
574
 
*/
575
 
#define IO_SIZE 4096
576
 
/* Max file name len */
577
 
#define FN_LEN 256
578
 
/* Max length of extension (part of FN_LEN) */
579
 
#define FN_EXTLEN 20
580
 
/* Max length of full path-name */
581
 
#define FN_REFLEN 512
582
 
/* File extension character */
583
 
#define FN_EXTCHAR '.'
584
 
/* ~ is used as abbrev for home dir */
585
 
#define FN_HOMELIB '~'
586
 
/* ./ is used as abbrev for current dir */
587
 
#define FN_CURLIB '.'
588
 
/* Parent directory; Must be a string */
589
 
#define FN_PARENTDIR ".."
590
 
 
591
 
/* Quote argument (before cpp) */
592
 
#ifndef QUOTE_ARG
593
 
# define QUOTE_ARG(x) #x
594
 
#endif
595
 
/* Quote argument, (after cpp) */
596
 
#ifndef STRINGIFY_ARG
597
 
# define STRINGIFY_ARG(x) QUOTE_ARG(x)
598
 
#endif
599
 
 
600
 
/*
601
 
 * The macros below are borrowed from include/linux/compiler.h in the
602
 
 * Linux kernel. Use them to indicate the likelyhood of the truthfulness
603
 
 * of a condition. This serves two purposes - newer versions of gcc will be
604
 
 * able to optimize for branch predication, which could yield siginficant
605
 
 * performance gains in frequently executed sections of the code, and the
606
 
 * other reason to use them is for documentation
607
 
 */
608
 
#if !defined(__GNUC__)
609
 
#define __builtin_expect(x, expected_value) (x)
610
 
#endif
611
 
 
612
 
#define likely(x)  __builtin_expect((x),1)
613
 
#define unlikely(x)  __builtin_expect((x),0)
614
 
 
615
 
 
616
 
/*
617
 
  Only Linux is known to need an explicit sync of the directory to make sure a
618
 
  file creation/deletion/renaming in(from,to) this directory durable.
619
 
*/
620
 
#ifdef TARGET_OS_LINUX
621
 
#define NEED_EXPLICIT_SYNC_DIR 1
622
 
#endif
623
 
 
624
 
/* We need to turn off _DTRACE_VERSION if we're not going to use dtrace */
625
 
#if !defined(HAVE_DTRACE)
626
 
# undef _DTRACE_VERSION
627
 
# define _DTRACE_VERSION 0
628
 
#endif
629
 
 
630
 
} /* namespace drizzled */
631
 
 
632
 
#endif /* DRIZZLED_DEFINITIONS_H */
 
376
/*
 
377
  Some defines for exit codes for ::is_equal class functions.
 
378
*/
 
379
#define IS_EQUAL_NO 0
 
380
#define IS_EQUAL_YES 1
 
381
#define IS_EQUAL_PACK_LENGTH 2
 
382
 
 
383
 
 
384
#endif /* DRIZZLE_SERVER_DEFINITIONS_H */