~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definitions.h

  • Committer: Brian Aker
  • Date: 2008-10-29 13:46:43 UTC
  • Revision ID: brian@tangent.org-20081029134643-z6jcwjvyruhk2vlu
Updates for ignore file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
 
20
#include CSTDINT_H
 
21
 
20
22
/**
21
23
 * @file
22
24
 *
23
 
 * Mostly constants and some macros/functions used by the server
 
25
 * Mostly constants and some macros/functions used by the server  
24
26
 */
25
27
 
26
 
#ifndef DRIZZLED_DEFINITIONS_H
27
 
#define DRIZZLED_DEFINITIONS_H
28
 
 
29
 
#include <drizzled/enum.h>
30
 
 
31
 
#include <stdint.h>
32
 
 
33
 
#include "common.h"
34
 
 
35
 
namespace drizzled
36
 
{
37
 
 
38
 
/* Global value for how we extend our temporary directory */
39
 
#define GLOBAL_TEMPORARY_EXT ".temporary"
 
28
#ifndef DRIZZLE_SERVER_DEFINITIONS_H
 
29
#define DRIZZLE_SERVER_DEFINITIONS_H
 
30
 
 
31
#ifndef NO_ALARM_LOOP
 
32
#define NO_ALARM_LOOP           /* lib5 and popen can't use alarm */
 
33
#endif
40
34
 
41
35
/* These paths are converted to other systems (WIN95) before use */
42
36
 
43
37
#define LANGUAGE        "english/"
 
38
#define ERRMSG_FILE     "errmsg.sys"
44
39
#define TEMP_PREFIX     "MY"
45
 
 
46
 
#define ER(X) ::drizzled::error_message((X))
47
 
 
48
 
/* buffer size for strerror_r() */
49
 
#define STRERROR_MAX 256
50
 
 
 
40
#define LOG_PREFIX      "ML"
 
41
#define PROGDIR         "bin/"
 
42
#ifndef DATADIR
 
43
#define DATADIR         "data/"
 
44
#endif
 
45
#ifndef SHAREDIR
 
46
#define SHAREDIR        "share/"
 
47
#endif
 
48
#ifndef PLUGINDIR
 
49
#define PLUGINDIR       "lib/plugin"
 
50
#endif
 
51
 
 
52
#define ER(X) error_message((X))
 
53
 
 
54
#define LIBLEN FN_REFLEN-FN_LEN                 /* Max l{ngd p} dev */
51
55
/* extra 4+4 bytes for slave tmp tables */
 
56
#define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
 
57
#define MAX_ALIAS_NAME 256
52
58
#define MAX_FIELD_NAME 34                       /* Max colum name length +2 */
53
59
#define MAX_SYS_VAR_LENGTH 32
54
 
#define MAX_INDEXES 64
55
 
const uint32_t MAX_KEY = MAX_INDEXES;                     /* Max used keys */
56
 
const uint32_t MAX_REF_PARTS = 16;                      /* Max parts used as ref */
57
 
const uint32_t MAX_KEY_LENGTH = 4096;                    // max possible key
58
 
const uint32_t MAX_KEY_LENGTH_DECIMAL_WIDTH = 4; // strlen("4096")
59
 
 
 
60
#define MAX_KEY MAX_INDEXES                     /* Max used keys */
 
61
#define MAX_REF_PARTS 16                        /* Max parts used as ref */
 
62
#define MAX_KEY_LENGTH 4096                     /* max possible key */
 
63
#define MAX_KEY_LENGTH_DECIMAL_WIDTH 4          /* strlen("4096") */
60
64
#if SIZEOF_OFF_T > 4
61
65
#define MAX_REFLENGTH 8                         /* Max length for record ref */
62
66
#else
63
67
#define MAX_REFLENGTH 4                         /* Max length for record ref */
64
68
#endif
 
69
#define MAX_HOSTNAME  61                        /* len+1 in mysql.user */
65
70
 
66
71
#define MAX_MBWIDTH             4               /* Max multibyte sequence */
67
72
#define MAX_FIELD_CHARLENGTH    255
71
76
/* Max column width +1 */
72
77
#define MAX_FIELD_WIDTH         (MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
73
78
 
 
79
#define MAX_BIT_FIELD_LENGTH    64      /* Max length in bits for bit fields */
 
80
 
 
81
#define MAX_DATE_WIDTH          10      /* YYYY-MM-DD */
 
82
#define MAX_TIME_WIDTH          23      /* -DDDDDD HH:MM:SS.###### */
 
83
#define MAX_DATETIME_FULL_WIDTH 29      /* YYYY-MM-DD HH:MM:SS.###### AM */
 
84
#define MAX_DATETIME_WIDTH      19      /* YYYY-MM-DD HH:MM:SS */
 
85
#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
 
86
 
74
87
#define MAX_TABLES      (sizeof(table_map)*8-3) /* Max tables in join */
75
88
#define PARAM_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-3))
76
89
#define OUTER_REF_TABLE_BIT     (((table_map) 1) << (sizeof(table_map)*8-2))
77
90
#define RAND_TABLE_BIT  (((table_map) 1) << (sizeof(table_map)*8-1))
78
91
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
79
92
                           RAND_TABLE_BIT)
80
 
#define MAX_FIELDS      4096      /* Historical limit from MySQL FRM. */
 
93
#define MAX_FIELDS      4096                    /* Limit in the .frm file */
81
94
 
82
95
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
83
96
 
84
97
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
85
98
#define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
86
99
 
 
100
/* Memory allocated when parsing a statement / saving a statement */
 
101
#define MEM_ROOT_BLOCK_SIZE       8192
 
102
#define MEM_ROOT_PREALLOC         8192
 
103
#define TRANS_MEM_ROOT_BLOCK_SIZE 4096
 
104
#define TRANS_MEM_ROOT_PREALLOC   4096
 
105
 
87
106
#define DEFAULT_ERROR_COUNT     64
88
107
#define EXTRA_RECORDS   10                      /* Extra records in sort */
 
108
#define SCROLL_EXTRA    5                       /* Extra scroll-rows. */
 
109
#define FIELD_NAME_USED ((uint) 32768)          /* Bit set if fieldname used */
 
110
#define FORM_NAME_USED  ((uint) 16384)          /* Bit set if formname used */
 
111
#define FIELD_NR_MASK   16383                   /* To get fieldnumber */
 
112
#define FERR            -1                      /* Error from my_functions */
 
113
#define CREATE_MODE     0                       /* Default mode on new files */
89
114
#define NAMES_SEP_CHAR  '\377'                  /* Char to sep. names */
90
115
 
91
 
#define READ_RECORD_BUFFER      (uint32_t) (IO_SIZE*8) /* Pointer_buffer_size */
92
 
#define DISK_BUFFER_SIZE        (uint32_t) (IO_SIZE*16) /* Size of diskbuffer */
 
116
#define READ_RECORD_BUFFER      (uint) (IO_SIZE*8) /* Pointer_buffer_size */
 
117
#define DISK_BUFFER_SIZE        (uint) (IO_SIZE*16) /* Size of diskbuffer */
93
118
 
 
119
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
94
120
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
95
121
#define MYF_RW MYF(MY_WME+MY_NABP)              /* Vid my_read & my_write */
96
122
 
 
123
        /* Extern defines */
 
124
#define store_record(A,B) memcpy((A)->B,(A)->record[0],(size_t) (A)->s->reclength)
 
125
#define restore_record(A,B) memcpy((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
 
126
#define cmp_record(A,B) memcmp((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
 
127
#define empty_record(A)                                 \
 
128
  do {                                                  \
 
129
    restore_record((A),s->default_values);              \
 
130
    memset((A)->null_flags, 255, (A)->s->null_bytes);   \
 
131
  } while (0)
 
132
 
 
133
        /* Defines for use with openfrm, openprt and openfrd */
 
134
 
 
135
#define READ_ALL                1       /* openfrm: Read all parameters */
 
136
#define CHANGE_FRM              2       /* openfrm: open .frm as O_RDWR */
 
137
#define EXTRA_RECORD            8       /* Reservera plats f|r extra record */
 
138
#define DONT_GIVE_ERROR         256     /* Don't do frm_error on openfrm  */
 
139
#define DELAYED_OPEN            4096    /* Open table later */
 
140
/**
 
141
  This flag is used in function get_all_tables() which fills
 
142
  I_S tables with data which are retrieved from frm files and storage engine
 
143
  The flag means that we need to open FRM file only to get necessary data.
 
144
*/
 
145
#define OPEN_FRM_FILE_ONLY     32768
 
146
/**
 
147
  This flag is used in function get_all_tables() which fills
 
148
  I_S tables with data which are retrieved from frm files and storage engine
 
149
  The flag means that we need to process tables only to get necessary data.
 
150
  Views are not processed.
 
151
*/
 
152
#define OPEN_TABLE_ONLY        OPEN_FRM_FILE_ONLY*2
 
153
/**
 
154
  This flag is used in function get_all_tables() which fills
 
155
  I_S tables with data which are retrieved from frm files and storage engine.
 
156
  The flag means that I_S table uses optimization algorithm.
 
157
*/
 
158
#define OPTIMIZE_I_S_TABLE     OPEN_TABLE_ONLY*2
 
159
 
 
160
#define SC_INFO_LENGTH 4                /* Form format constant */
 
161
#define TE_INFO_LENGTH 3
 
162
#define MTYP_NOEMPTY_BIT 128
 
163
 
 
164
#define FRM_VER_TRUE_VARCHAR (FRM_VER+4) /* 10 */
 
165
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_CGE 50120
 
166
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM 50205
 
167
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_STR "50205"
 
168
 
97
169
/*
98
170
  Minimum length pattern before Turbo Boyer-Moore is used
99
171
  for SELECT "text" LIKE "%pattern%", excluding the two
101
173
*/
102
174
#define MIN_TURBOBM_PATTERN_LEN 3
103
175
 
 
176
/* 
 
177
   Defines for binary logging.
 
178
   Do not decrease the value of BIN_LOG_HEADER_SIZE.
 
179
   Do not even increase it before checking code.
 
180
*/
 
181
 
 
182
#define BIN_LOG_HEADER_SIZE    4 
 
183
 
 
184
#define DEFAULT_KEY_CACHE_NAME "default"
 
185
 
 
186
#define STORAGE_TYPE_MASK 7
 
187
#define COLUMN_FORMAT_MASK 7
 
188
#define COLUMN_FORMAT_SHIFT 3
 
189
 
104
190
/* Below are #defines that used to be in mysql_priv.h */
105
191
/***************************************************************************
106
192
  Configuration parameters
107
193
****************************************************************************/
 
194
#define ACL_CACHE_SIZE          256
 
195
#define MAX_PASSWORD_LENGTH     32
 
196
#define HOST_CACHE_SIZE         128
 
197
#define MAX_ACCEPT_RETRY        10      // Test accept this many times
108
198
#define MAX_FIELDS_BEFORE_HASH  32
 
199
#define USER_VARS_HASH_SIZE     16
109
200
#define TABLE_OPEN_CACHE_MIN    64
110
 
#define TABLE_OPEN_CACHE_DEFAULT 1024
 
201
#define TABLE_OPEN_CACHE_DEFAULT 64
111
202
 
112
 
/*
 
203
/* 
113
204
 Value of 9236 discovered through binary search 2006-09-26 on Ubuntu Dapper
114
 
 Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added
 
205
 Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added 
115
206
 100 bytes as reasonable buffer against growth and other environments'
116
207
 requirements.)
117
208
 
123
214
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
124
215
#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
125
216
 
 
217
/** 
 
218
 * @TODO Move into a drizzled.h since it's only used in drizzled.cc
 
219
 *
 
220
 * @TODO Rename to DRIZZLED_NET_RETRY_COUNT
 
221
 */
 
222
#ifndef MYSQLD_NET_RETRY_COUNT
 
223
#define MYSQLD_NET_RETRY_COUNT  10      ///< Abort read after this many int.
 
224
#endif
 
225
#define TEMP_POOL_SIZE          128
 
226
 
126
227
#define QUERY_ALLOC_BLOCK_SIZE          8192
127
228
#define QUERY_ALLOC_PREALLOC_SIZE       8192
 
229
#define TRANS_ALLOC_BLOCK_SIZE          4096
 
230
#define TRANS_ALLOC_PREALLOC_SIZE       4096
128
231
#define RANGE_ALLOC_BLOCK_SIZE          4096
 
232
#define ACL_ALLOC_BLOCK_SIZE            1024
 
233
#define UDF_ALLOC_BLOCK_SIZE            1024
129
234
#define TABLE_ALLOC_BLOCK_SIZE          1024
 
235
#define BDB_LOG_ALLOC_BLOCK_SIZE        1024
130
236
#define WARN_ALLOC_BLOCK_SIZE           2048
131
237
#define WARN_ALLOC_PREALLOC_SIZE        1024
 
238
#define PROFILE_ALLOC_BLOCK_SIZE  2048
 
239
#define PROFILE_ALLOC_PREALLOC_SIZE 1024
132
240
 
133
241
/*
134
242
  The following parameters is to decide when to use an extra cache to
136
244
*/
137
245
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
138
246
#define MIN_ROWS_TO_USE_TABLE_CACHE      100
 
247
#define MIN_ROWS_TO_USE_BULK_INSERT      100
139
248
 
140
249
/**
141
250
  The following is used to decide if MySQL should use table scanning
145
254
#define TIME_FOR_COMPARE   5    // 5 compares == one read
146
255
 
147
256
/**
148
 
  Number of comparisons of table rowids equivalent to reading one row from a
 
257
  Number of comparisons of table rowids equivalent to reading one row from a 
149
258
  table.
150
259
*/
151
260
#define TIME_FOR_COMPARE_ROWID  (TIME_FOR_COMPARE*2)
152
261
 
153
262
/*
154
263
  For sequential disk seeks the cost formula is:
155
 
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip
156
 
 
157
 
  The cost of average seek
 
264
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip  
 
265
  
 
266
  The cost of average seek 
158
267
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
159
268
*/
160
269
#define DISK_SEEK_BASE_COST ((double)0.9)
176
285
 
177
286
/** Characters shown for the command in 'show processlist'. */
178
287
#define PROCESS_LIST_WIDTH 100
 
288
/* Characters shown for the command in 'information_schema.processlist' */
 
289
#define PROCESS_LIST_INFO_WIDTH 65535
 
290
 
 
291
#define PRECISION_FOR_DOUBLE 53
 
292
#define PRECISION_FOR_FLOAT  24
 
293
 
 
294
/*
 
295
  Default time to wait before aborting a new client connection
 
296
  that does not respond to "initial server greeting" timely
 
297
*/
 
298
#define CONNECT_TIMEOUT         10
 
299
 
 
300
/* The following can also be changed from the command line */
 
301
#define DEFAULT_CONCURRENCY     10
 
302
#define FLUSH_TIME              0               /**< Don't flush tables */
 
303
#define MAX_CONNECT_ERRORS      10              ///< errors before disabling host
 
304
 
 
305
#define INTERRUPT_PRIOR 10
 
306
#define CONNECT_PRIOR   9
 
307
#define WAIT_PRIOR      8
 
308
#define QUERY_PRIOR     6
 
309
 
 
310
        /* Bits from testflag */
 
311
#define TEST_PRINT_CACHED_TABLES 1
 
312
#define TEST_NO_KEY_GROUP        2
 
313
#define TEST_MIT_THREAD         4
 
314
#define TEST_KEEP_TMP_TABLES    16
 
315
#define TEST_READCHECK          64      /**< Force use of readcheck */
 
316
#define TEST_NO_EXTRA           128
 
317
#define TEST_CORE_ON_SIGNAL     256     /**< Give core if signal */
 
318
#define TEST_NO_STACKTRACE      512
 
319
#define TEST_SIGINT             1024    /**< Allow sigint on threads */
 
320
#define TEST_SYNCHRONIZATION    2048    /**< get server to do sleep in some places */
179
321
 
180
322
/* Bits for different SQL modes modes (including ANSI mode) */
181
323
#define MODE_NO_ZERO_DATE               (2)
182
324
#define MODE_INVALID_DATES              (MODE_NO_ZERO_DATE*2)
183
325
 
 
326
/* @@optimizer_switch flags */
 
327
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
 
328
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
 
329
 
184
330
#define MY_CHARSET_BIN_MB_MAXLEN 1
185
331
 
186
332
// uncachable cause
187
 
static const uint32_t UNCACHEABLE_DEPENDENT= 1;
188
 
static const uint32_t UNCACHEABLE_RAND= 2;
189
 
static const uint32_t UNCACHEABLE_SIDEEFFECT= 3;
 
333
#define UNCACHEABLE_DEPENDENT   1
 
334
#define UNCACHEABLE_RAND        2
 
335
#define UNCACHEABLE_SIDEEFFECT  4
190
336
/// forcing to save JOIN for explain
191
 
static const uint32_t UNCACHEABLE_EXPLAIN= 4;
 
337
#define UNCACHEABLE_EXPLAIN     8
192
338
/** Don't evaluate subqueries in prepare even if they're not correlated */
193
 
static const uint32_t UNCACHEABLE_PREPARE= 5;
 
339
#define UNCACHEABLE_PREPARE    16
194
340
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
195
 
static const uint32_t UNCACHEABLE_UNITED= 6;
 
341
#define UNCACHEABLE_UNITED     32
196
342
 
197
343
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
198
344
#define UNDEF_POS (-1)
199
345
 
 
346
/* BINLOG_DUMP options */
 
347
 
 
348
#define BINLOG_DUMP_NON_BLOCK   1
 
349
 
 
350
/* sql_show.cc:show_log_files() */
 
351
#define SHOW_LOG_STATUS_FREE "FREE"
 
352
#define SHOW_LOG_STATUS_INUSE "IN USE"
 
353
 
200
354
/* Options to add_table_to_list() */
201
 
static const uint32_t TL_OPTION_UPDATING= 0;
202
 
static const uint32_t TL_OPTION_FORCE_INDEX= 1;
203
 
static const uint32_t TL_OPTION_IGNORE_LEAVES= 2;
204
 
static const uint32_t TL_OPTION_ALIAS= 3;
205
 
static const uint32_t NUM_OF_TABLE_OPTIONS= 4;
 
355
#define TL_OPTION_UPDATING      1
 
356
#define TL_OPTION_FORCE_INDEX   2
 
357
#define TL_OPTION_IGNORE_LEAVES 4
 
358
#define TL_OPTION_ALIAS         8
206
359
 
207
360
/* Some portable defines */
208
361
 
209
362
#define portable_sizeof_char_ptr 8
210
363
 
211
 
#define TMP_FILE_PREFIX "#sql"                  /**< Prefix for tmp tables */
212
 
#define TMP_FILE_PREFIX_LENGTH 4
 
364
#define tmp_file_prefix "#sql"                  /**< Prefix for tmp tables */
 
365
#define tmp_file_prefix_length 4
213
366
 
214
367
/* Flags for calc_week() function.  */
215
368
#define WEEK_MONDAY_FIRST    1
216
369
#define WEEK_YEAR            2
217
370
#define WEEK_FIRST_WEEKDAY   4
218
371
 
219
 
/* used in date and time conversions */
220
 
/* Daynumber from year 0 to 9999-12-31 */
221
 
#define MAX_DAY_NUMBER 3652424L
222
 
 
223
372
#define STRING_BUFFER_USUAL_SIZE 80
224
373
 
225
 
typedef void *range_seq_t;
226
 
 
227
 
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
228
 
// the following is for checking tables
229
 
 
230
 
#define HA_ADMIN_ALREADY_DONE     1
231
 
#define HA_ADMIN_OK               0
232
 
#define HA_ADMIN_NOT_IMPLEMENTED -1
233
 
#define HA_ADMIN_FAILED          -2
234
 
#define HA_ADMIN_CORRUPT         -3
235
 
#define HA_ADMIN_INTERNAL_ERROR  -4
236
 
#define HA_ADMIN_INVALID         -5
237
 
#define HA_ADMIN_REJECT          -6
238
 
 
239
 
/* bits in index_flags(index_number) for what you can do with index */
240
 
#define HA_READ_NEXT            1       /* TODO really use this flag */
241
 
#define HA_READ_PREV            2       /* supports ::index_prev */
242
 
#define HA_READ_ORDER           4       /* index_next/prev follow sort order */
243
 
#define HA_READ_RANGE           8       /* can find all records in a range */
244
 
#define HA_ONLY_WHOLE_INDEX     16      /* Can't use part key searches */
245
 
#define HA_KEYREAD_ONLY         64      /* Support HA_EXTRA_KEYREAD */
246
 
/*
247
 
  Index scan will not return records in rowid order. Not guaranteed to be
248
 
  set for unordered (e.g. HASH) indexes.
249
 
*/
250
 
#define HA_KEY_SCAN_NOT_ROR     128
251
 
 
252
 
/* operations for disable/enable indexes */
253
 
#define HA_KEY_SWITCH_NONUNIQ      0
254
 
#define HA_KEY_SWITCH_ALL          1
255
 
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
256
 
#define HA_KEY_SWITCH_ALL_SAVE     3
257
 
 
258
 
/*
259
 
  Parameters for open() (in register form->filestat)
260
 
  HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
261
 
*/
262
 
 
263
 
#define HA_OPEN_KEYFILE         1
264
 
#define HA_OPEN_RNDFILE         2
265
 
#define HA_GET_INDEX            4
266
 
#define HA_GET_INFO             8       /* do a ha_info() after open */
267
 
#define HA_READ_ONLY            16      /* File opened as readonly */
268
 
/* Try readonly if can't open with read and write */
269
 
#define HA_TRY_READ_ONLY        32
270
 
#define HA_WAIT_IF_LOCKED       64      /* Wait if locked on open */
271
 
#define HA_ABORT_IF_LOCKED      128     /* skip if locked on open.*/
272
 
#define HA_BLOCK_LOCK           256     /* unlock when reading some records */
273
 
#define HA_OPEN_TEMPORARY       512
274
 
 
275
 
/* Some key definitions */
276
 
#define HA_KEY_NULL_LENGTH      1
277
 
#define HA_KEY_BLOB_LENGTH      2
278
 
 
279
 
const uint32_t HA_MAX_REC_LENGTH = 65535;
280
 
 
281
 
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
282
 
enum start_transaction_option_t
283
 
{
284
 
  START_TRANS_NO_OPTIONS,
285
 
  START_TRANS_OPT_WITH_CONS_SNAPSHOT
286
 
};
287
 
 
288
 
/* Flags for method is_fatal_error */
289
 
#define HA_CHECK_DUP_KEY 1
290
 
#define HA_CHECK_DUP_UNIQUE 2
291
 
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
292
 
 
293
 
 
294
 
/* Bits in used_fields */
295
 
#define HA_CREATE_USED_AUTO             (1L << 0)
296
 
#define HA_CREATE_USED_CHARSET          (1L << 8)
297
 
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
298
 
 
299
 
/*
300
 
  The below two are not used (and not handled) in this milestone of this WL
301
 
  entry because there seems to be no use for them at this stage of
302
 
  implementation.
303
 
*/
304
 
#define HA_MRR_SINGLE_POINT 1
305
 
#define HA_MRR_FIXED_KEY  2
306
 
 
307
 
/*
308
 
  Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
309
 
  'range' parameter.
310
 
*/
311
 
#define HA_MRR_NO_ASSOCIATION 4
312
 
 
313
 
/*
314
 
  The MRR user will provide ranges in key order, and MRR implementation
315
 
  must return rows in key order.
316
 
*/
317
 
#define HA_MRR_SORTED 8
318
 
 
319
 
/* MRR implementation doesn't have to retrieve full records */
320
 
#define HA_MRR_INDEX_ONLY 16
321
 
 
322
 
/*
323
 
  The passed memory buffer is of maximum possible size, the caller can't
324
 
  assume larger buffer.
325
 
*/
326
 
#define HA_MRR_LIMITS 32
327
 
 
328
 
 
329
 
/*
330
 
  Flag set <=> default MRR implementation is used
331
 
  (The choice is made by **_info[_const]() function which may set this
332
 
   flag. SQL layer remembers the flag value and then passes it to
333
 
   multi_read_range_init().
334
 
*/
335
 
#define HA_MRR_USE_DEFAULT_IMPL 64
336
 
 
337
 
typedef int myf;
338
 
#define MYF(v)          (static_cast<drizzled::myf>(v))
339
 
 
340
 
/*
341
 
   "Declared Type Collation"
342
 
   A combination of collation and its derivation.
343
 
 
344
 
  Flags for collation aggregation modes:
345
 
  MY_COLL_ALLOW_SUPERSET_CONV  - allow conversion to a superset
346
 
  MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
347
 
                                 (i.e. constant).
348
 
  MY_COLL_ALLOW_CONV           - allow any kind of conversion
349
 
                                 (combination of the above two)
350
 
  MY_COLL_DISALLOW_NONE        - don't allow return DERIVATION_NONE
351
 
                                 (e.g. when aggregating for comparison)
352
 
  MY_COLL_CMP_CONV             - combination of MY_COLL_ALLOW_CONV
353
 
                                 and MY_COLL_DISALLOW_NONE
354
 
*/
355
 
 
356
 
#define MY_COLL_ALLOW_SUPERSET_CONV   1
357
 
#define MY_COLL_ALLOW_COERCIBLE_CONV  2
358
 
#define MY_COLL_ALLOW_CONV            3
359
 
#define MY_COLL_DISALLOW_NONE         4
360
 
#define MY_COLL_CMP_CONV              7
361
 
 
362
 
inline static void clear_timestamp_auto_bits(timestamp_auto_set_type &_target_, 
363
 
                                             timestamp_auto_set_type _bits_)
364
 
{
365
 
  _target_= static_cast<timestamp_auto_set_type>(_target_ & ~_bits_);
366
 
}
367
 
 
368
 
/*
369
 
 * The following are for the interface with the .frm file
370
 
 */
371
 
 
372
 
#define FIELDFLAG_PACK_SHIFT    3
373
 
#define FIELDFLAG_MAX_DEC    31
374
 
 
375
 
#ifdef __cplusplus
376
 
// FIXME: T will just be drizzled::Field::utype, but that would
377
 
// require including field.h. Moving the function elsewhere might be a
378
 
// better idea. Leaving it for restructuring.
379
 
template <typename T> 
380
 
T MTYP_TYPENR(const T& type)
381
 
{
382
 
  return static_cast<T>(type & 127);
383
 
}
384
 
#else
385
 
#define MTYP_TYPENR(type) (type & 127)  /* Remove bits from type */
386
 
#endif
387
 
 
388
 
inline static uint32_t f_settype(const enum enum_field_types x)
389
 
{
390
 
  return (uint32_t(x) << FIELDFLAG_PACK_SHIFT);
391
 
}
392
 
 
393
 
#ifdef __cplusplus
394
 
template <class T> void set_if_bigger(T &a, const T &b)
395
 
{
396
 
  if (a < b)
397
 
    a=b;
398
 
}
399
 
 
400
 
template <class T> void set_if_smaller(T &a, const T &b)
401
 
{
402
 
  if (a > b)
403
 
    a=b;
404
 
}
405
 
 
406
 
template<class T> inline void safe_delete(T*& ptr)
407
 
{
408
 
  delete ptr;
409
 
  ptr = 0;
410
 
}
411
 
#else
412
 
#ifdef __GNUC__
413
 
#define set_if_bigger(a,b) do {                 \
414
 
  const typeof(a) _a = (a);                     \
415
 
  const typeof(b) _b = (b);                     \
416
 
  (void) (&_a == &_b);                          \
417
 
  if ((a) < (b)) (a)=(b);                       \
418
 
  } while(0)
419
 
#define set_if_smaller(a,b) do {                \
420
 
  const typeof(a) _a = (a);                     \
421
 
  const typeof(b) _b = (b);                     \
422
 
  (void) (&_a == &_b);                          \
423
 
  if ((a) > (b)) (a)=(b);                       \
424
 
  } while(0)
425
 
 
426
 
#else
427
 
#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
428
 
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
429
 
#endif
430
 
#endif
431
 
 
432
 
 
433
 
#define array_elements(a) \
434
 
  ((sizeof(a) / sizeof(*(a))) / \
435
 
   static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
436
 
 
437
 
 
438
 
/* Some types that is different between systems */
439
 
 
440
 
#ifndef FN_LIBCHAR
441
 
#define FN_LIBCHAR  '/'
442
 
#define FN_ROOTDIR  "/"
443
 
#endif
444
 
#define MY_NFILE  64  /* This is only used to save filenames */
445
 
#ifndef OS_FILE_LIMIT
446
 
#define OS_FILE_LIMIT  65535
447
 
#endif
448
 
 
449
 
/*
450
 
  How much overhead does malloc have. The code often allocates
451
 
  something like 1024-MALLOC_OVERHEAD bytes
452
 
*/
453
 
#define MALLOC_OVERHEAD 8
454
 
 
455
 
/* get memory in huncs */
456
 
static const uint32_t ONCE_ALLOC_INIT= 4096;
457
 
/* Typical record cash */
458
 
static const uint32_t RECORD_CACHE_SIZE= 64*1024;
459
 
 
460
 
 
461
 
/* Some things that this system doesn't have */
462
 
 
463
 
/* Some defines of functions for portability */
464
 
 
465
 
#ifndef uint64_t2double
466
 
#define uint64_t2double(A) ((double) (uint64_t) (A))
467
 
#endif
468
 
 
469
 
#ifndef int64_t2double
470
 
#define int64_t2double(A) ((double) (int64_t) (A))
471
 
#endif
472
 
 
473
 
#ifndef offsetof
474
 
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
475
 
#endif
476
 
 
477
 
/* From limits.h instead */
478
 
#ifndef DBL_MIN
479
 
#define DBL_MIN    4.94065645841246544e-324
480
 
#endif
481
 
#ifndef DBL_MAX
482
 
#define DBL_MAX    1.79769313486231470e+308
483
 
#endif
484
 
 
485
 
 
486
 
/* Define missing math constants. */
487
 
#ifndef M_PI
488
 
#define M_PI 3.14159265358979323846
489
 
#endif
490
 
#ifndef M_E
491
 
#define M_E 2.7182818284590452354
492
 
#endif
493
 
#ifndef M_LN2
494
 
#define M_LN2 0.69314718055994530942
495
 
#endif
496
 
 
497
 
/*
498
 
  Max size that must be added to a so that we know Size to make
499
 
  adressable obj.
500
 
*/
501
 
#define MY_ALIGN(A,L)  (((A) + (L) - 1) & ~((L) - 1))
502
 
#define ALIGN_SIZE(A)  MY_ALIGN((A),sizeof(double))
503
 
#ifdef __cplusplus
504
 
#define ADD_TO_PTR(ptr,size,type) (type) (reinterpret_cast<const unsigned char*>(ptr)+size)
505
 
#else
506
 
 #define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
507
 
#endif
508
 
 
509
 
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
510
 
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
511
 
 
512
 
/* Typdefs for easyier portability */
513
 
 
514
 
 
515
 
#if defined(SIZEOF_OFF_T)
516
 
# if (SIZEOF_OFF_T == 8)
517
 
#  define OFF_T_MAX (INT64_MAX)
518
 
# else
519
 
#  define OFF_T_MAX (INT32_MAX)
520
 
# endif
521
 
#endif
522
 
 
523
 
#define MY_FILEPOS_ERROR  -1
524
 
 
525
 
#define DRIZZLE_SERVER
526
 
 
527
 
/* Length of decimal number represented by INT32. */
528
 
#define MY_INT32_NUM_DECIMAL_DIGITS 11
529
 
 
530
 
/* Length of decimal number represented by INT64. */
531
 
#define MY_INT64_NUM_DECIMAL_DIGITS 21
532
 
 
533
 
/*
534
 
  Io buffer size; Must be a power of 2 and
535
 
  a multiple of 512. May be
536
 
  smaller what the disk page size. This influences the speed of the
537
 
  isam btree library. eg to big to slow.
538
 
*/
539
 
#define IO_SIZE 4096
540
 
/* Max file name len */
541
 
#define FN_LEN 256
542
 
/* Max length of full path-name */
543
 
#define FN_REFLEN 512
544
 
/* File extension character */
545
 
#define FN_EXTCHAR '.'
546
 
/* ~ is used as abbrev for home dir */
547
 
#define FN_HOMELIB '~'
548
 
/* ./ is used as abbrev for current dir */
549
 
#define FN_CURLIB '.'
550
 
/* Parent directory; Must be a string */
551
 
#define FN_PARENTDIR ".."
552
 
 
553
 
/* Quote argument (before cpp) */
554
 
#ifndef QUOTE_ARG
555
 
# define QUOTE_ARG(x) #x
556
 
#endif
557
 
/* Quote argument, (after cpp) */
558
 
#ifndef STRINGIFY_ARG
559
 
# define STRINGIFY_ARG(x) QUOTE_ARG(x)
560
 
#endif
561
 
 
562
 
/*
563
 
 * The macros below are borrowed from include/linux/compiler.h in the
564
 
 * Linux kernel. Use them to indicate the likelyhood of the truthfulness
565
 
 * of a condition. This serves two purposes - newer versions of gcc will be
566
 
 * able to optimize for branch predication, which could yield siginficant
567
 
 * performance gains in frequently executed sections of the code, and the
568
 
 * other reason to use them is for documentation
569
 
 */
570
 
#if !defined(__GNUC__)
571
 
#define __builtin_expect(x, expected_value) (x)
572
 
#endif
573
 
 
574
 
#define likely(x)  __builtin_expect((x),1)
575
 
#define unlikely(x)  __builtin_expect((x),0)
576
 
 
577
 
 
578
 
/*
579
 
  Only Linux is known to need an explicit sync of the directory to make sure a
580
 
  file creation/deletion/renaming in(from,to) this directory durable.
581
 
*/
582
 
#ifdef TARGET_OS_LINUX
583
 
#define NEED_EXPLICIT_SYNC_DIR 1
584
 
#endif
585
 
 
586
 
/* We need to turn off _DTRACE_VERSION if we're not going to use dtrace */
587
 
#if !defined(HAVE_DTRACE)
588
 
# undef _DTRACE_VERSION
589
 
# define _DTRACE_VERSION 0
590
 
#endif
591
 
 
592
 
typedef uint64_t table_map;   /* Used for table bits in join */
593
 
typedef uint32_t nesting_map; /* Used for flags of nesting constructs */
594
 
 
595
 
} /* namespace drizzled */
596
 
 
597
 
#endif /* DRIZZLED_DEFINITIONS_H */
 
374
/*
 
375
  Some defines for exit codes for ::is_equal class functions.
 
376
*/
 
377
#define IS_EQUAL_NO 0
 
378
#define IS_EQUAL_YES 1
 
379
#define IS_EQUAL_PACK_LENGTH 2
 
380
 
 
381
 
 
382
/**
 
383
  Query type constants.
 
384
 
 
385
  QT_ORDINARY -- ordinary SQL query.
 
386
  QT_IS -- SQL query to be shown in INFORMATION_SCHEMA (in utf8 and without
 
387
  character set introducers).
 
388
 
 
389
  @TODO
 
390
 
 
391
  Move this out of here once Stew's done with UDF breakout.  The following headers need it:
 
392
 
 
393
    sql_lex.h --> included by sql_class.h
 
394
    item.h
 
395
    table.h
 
396
    item_func.h
 
397
    item_subselect.h
 
398
    item_timefunc.h
 
399
    item_sum.h
 
400
    item_cmpfunc.h
 
401
    item_strfunc.h
 
402
*/
 
403
enum enum_query_type
 
404
{
 
405
  QT_ORDINARY,
 
406
  QT_IS
 
407
};
 
408
 
 
409
 
 
410
/**
 
411
 * @TODO Move to a separate header?
 
412
 *
 
413
 * It's needed by item.h and field.h, which are both inter-dependent
 
414
 * and contain forward declarations of many structs/classes in the
 
415
 * other header file.
 
416
 *
 
417
 * What is needed is a separate header file that is included
 
418
 * by *both* item.h and field.h to resolve inter-dependencies
 
419
 *
 
420
 * But, probably want to hold off on this until Stew finished the UDF cleanup
 
421
 */
 
422
enum Derivation
 
423
{
 
424
  DERIVATION_IGNORABLE= 5,
 
425
  DERIVATION_COERCIBLE= 4,
 
426
  DERIVATION_SYSCONST= 3,
 
427
  DERIVATION_IMPLICIT= 2,
 
428
  DERIVATION_NONE= 1,
 
429
  DERIVATION_EXPLICIT= 0
 
430
};
 
431
 
 
432
/**
 
433
 * Opening modes for open_temporary_table and open_table_from_share
 
434
 *
 
435
 * @TODO Put this into an appropriate header. It is only needed in:
 
436
 *
 
437
 *    table.cc
 
438
 *    sql_base.cc
 
439
 */
 
440
enum open_table_mode
 
441
{
 
442
  OTM_OPEN= 0,
 
443
  OTM_CREATE= 1,
 
444
  OTM_ALTER= 2
 
445
};
 
446
 
 
447
enum enum_parsing_place
 
448
{
 
449
  NO_MATTER
 
450
  , IN_HAVING
 
451
  , SELECT_LIST
 
452
  , IN_WHERE
 
453
  , IN_ON
 
454
};
 
455
 
 
456
enum enum_mysql_completiontype {
 
457
  ROLLBACK_RELEASE= -2
 
458
  , ROLLBACK= 1
 
459
  , ROLLBACK_AND_CHAIN= 7
 
460
  , COMMIT_RELEASE= -1
 
461
  , COMMIT= 0
 
462
  , COMMIT_AND_CHAIN= 6
 
463
};
 
464
 
 
465
enum enum_check_fields
 
466
{
 
467
  CHECK_FIELD_IGNORE
 
468
  , CHECK_FIELD_WARN
 
469
  , CHECK_FIELD_ERROR_FOR_NULL
 
470
};
 
471
 
 
472
enum enum_var_type
 
473
{
 
474
  OPT_DEFAULT= 0
 
475
  , OPT_SESSION
 
476
  , OPT_GLOBAL
 
477
};
 
478
 
 
479
typedef uint64_t query_id_t;
 
480
 
 
481
#endif /* DRIZZLE_SERVER_DEFINITIONS_H */