~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definitions.h

  • Committer: Jay Pipes
  • Date: 2008-09-11 16:03:22 UTC
  • mto: (383.5.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 386.
  • Revision ID: jay@mysql.com-20080911160322-vrl0k1djo6q6ytv1
Removed SQL_MODE variances from comment_table.test and ensured correct error thrown when a comment that is too long was input.  After moving to proto buffer definition for table, the 2048 length will go away.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 */
 
1
/* Copyright (C) 2000-2006 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
19
16
 
20
17
/**
21
18
 * @file
22
19
 *
23
 
 * Mostly constants and some macros/functions used by the server
 
20
 * Mostly constants and some macros/functions used by the server  
24
21
 */
25
22
 
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"
 
23
#ifndef DRIZZLE_SERVER_DEFINITIONS_H
 
24
#define DRIZZLE_SERVER_DEFINITIONS_H
 
25
 
 
26
#ifndef NO_ALARM_LOOP
 
27
#define NO_ALARM_LOOP           /* lib5 and popen can't use alarm */
 
28
#endif
40
29
 
41
30
/* These paths are converted to other systems (WIN95) before use */
42
31
 
43
32
#define LANGUAGE        "english/"
 
33
#define ERRMSG_FILE     "errmsg.sys"
44
34
#define TEMP_PREFIX     "MY"
45
35
#define LOG_PREFIX      "ML"
46
 
 
47
 
#define ER(X) ::drizzled::error_message((X))
48
 
 
49
 
/* buffer size for strerror_r() */
50
 
#define STRERROR_MAX 256
51
 
 
 
36
#define PROGDIR         "bin/"
 
37
#ifndef DATADIR
 
38
#define DATADIR         "data/"
 
39
#endif
 
40
#ifndef SHAREDIR
 
41
#define SHAREDIR        "share/"
 
42
#endif
 
43
#ifndef PLUGINDIR
 
44
#define PLUGINDIR       "lib/plugin"
 
45
#endif
 
46
 
 
47
#define ER(X) _(drizzled_error_messages[(X) - ER_ERROR_FIRST])
 
48
#define ER_SAFE(X) (((X) >= ER_ERROR_FIRST && (X) <= ER_ERROR_LAST) ? ER(X) : _("Invalid error code"))
 
49
 
 
50
#define ERRMAPP 1                               /* Errormap f|r my_error */
 
51
#define LIBLEN FN_REFLEN-FN_LEN                 /* Max l{ngd p} dev */
52
52
/* extra 4+4 bytes for slave tmp tables */
53
53
#define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
54
54
#define MAX_ALIAS_NAME 256
55
55
#define MAX_FIELD_NAME 34                       /* Max colum name length +2 */
56
56
#define MAX_SYS_VAR_LENGTH 32
57
 
#define MAX_INDEXES 64
58
57
#define MAX_KEY MAX_INDEXES                     /* Max used keys */
59
58
#define MAX_REF_PARTS 16                        /* Max parts used as ref */
60
59
#define MAX_KEY_LENGTH 4096                     /* max possible key */
74
73
/* Max column width +1 */
75
74
#define MAX_FIELD_WIDTH         (MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
76
75
 
 
76
#define MAX_BIT_FIELD_LENGTH    64      /* Max length in bits for bit fields */
 
77
 
 
78
#define MAX_DATE_WIDTH          10      /* YYYY-MM-DD */
 
79
#define MAX_TIME_WIDTH          23      /* -DDDDDD HH:MM:SS.###### */
 
80
#define MAX_DATETIME_FULL_WIDTH 29      /* YYYY-MM-DD HH:MM:SS.###### AM */
 
81
#define MAX_DATETIME_WIDTH      19      /* YYYY-MM-DD HH:MM:SS */
77
82
#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
78
83
 
79
84
#define MAX_TABLES      (sizeof(table_map)*8-3) /* Max tables in join */
82
87
#define RAND_TABLE_BIT  (((table_map) 1) << (sizeof(table_map)*8-1))
83
88
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
84
89
                           RAND_TABLE_BIT)
85
 
#define MAX_FIELDS      4096      /* Historical limit from MySQL FRM. */
 
90
#define MAX_FIELDS      4096                    /* Limit in the .frm file */
86
91
 
87
92
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
88
93
 
89
94
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
90
95
#define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
91
96
 
 
97
/* Memory allocated when parsing a statement / saving a statement */
 
98
#define MEM_ROOT_BLOCK_SIZE       8192
 
99
#define MEM_ROOT_PREALLOC         8192
 
100
#define TRANS_MEM_ROOT_BLOCK_SIZE 4096
 
101
#define TRANS_MEM_ROOT_PREALLOC   4096
 
102
 
92
103
#define DEFAULT_ERROR_COUNT     64
93
104
#define EXTRA_RECORDS   10                      /* Extra records in sort */
 
105
#define SCROLL_EXTRA    5                       /* Extra scroll-rows. */
 
106
#define FIELD_NAME_USED ((uint) 32768)          /* Bit set if fieldname used */
 
107
#define FORM_NAME_USED  ((uint) 16384)          /* Bit set if formname used */
 
108
#define FIELD_NR_MASK   16383                   /* To get fieldnumber */
 
109
#define FERR            -1                      /* Error from my_functions */
 
110
#define CREATE_MODE     0                       /* Default mode on new files */
94
111
#define NAMES_SEP_CHAR  '\377'                  /* Char to sep. names */
95
112
 
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 */
 
113
#define READ_RECORD_BUFFER      (uint) (IO_SIZE*8) /* Pointer_buffer_size */
 
114
#define DISK_BUFFER_SIZE        (uint) (IO_SIZE*16) /* Size of diskbuffer */
98
115
 
 
116
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
99
117
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
100
118
#define MYF_RW MYF(MY_WME+MY_NABP)              /* Vid my_read & my_write */
101
119
 
 
120
        /* Extern defines */
 
121
#define store_record(A,B) memcpy((A)->B,(A)->record[0],(size_t) (A)->s->reclength)
 
122
#define restore_record(A,B) memcpy((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
 
123
#define cmp_record(A,B) memcmp((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
 
124
#define empty_record(A)                                 \
 
125
  do {                                                  \
 
126
    restore_record((A),s->default_values);              \
 
127
    memset((A)->null_flags, 255, (A)->s->null_bytes);   \
 
128
  } while (0)
 
129
 
 
130
        /* Defines for use with openfrm, openprt and openfrd */
 
131
 
 
132
#define READ_ALL                1       /* openfrm: Read all parameters */
 
133
#define CHANGE_FRM              2       /* openfrm: open .frm as O_RDWR */
 
134
#define EXTRA_RECORD            8       /* Reservera plats f|r extra record */
 
135
#define DONT_GIVE_ERROR         256     /* Don't do frm_error on openfrm  */
 
136
#define DELAYED_OPEN            4096    /* Open table later */
 
137
/**
 
138
  This flag is used in function get_all_tables() which fills
 
139
  I_S tables with data which are retrieved from frm files and storage engine
 
140
  The flag means that we need to open FRM file only to get necessary data.
 
141
*/
 
142
#define OPEN_FRM_FILE_ONLY     32768
 
143
/**
 
144
  This flag is used in function get_all_tables() which fills
 
145
  I_S tables with data which are retrieved from frm files and storage engine
 
146
  The flag means that we need to process tables only to get necessary data.
 
147
  Views are not processed.
 
148
*/
 
149
#define OPEN_TABLE_ONLY        OPEN_FRM_FILE_ONLY*2
 
150
/**
 
151
  This flag is used in function get_all_tables() which fills
 
152
  I_S tables with data which are retrieved from frm files and storage engine.
 
153
  The flag means that I_S table uses optimization algorithm.
 
154
*/
 
155
#define OPTIMIZE_I_S_TABLE     OPEN_TABLE_ONLY*2
 
156
 
 
157
#define SC_INFO_LENGTH 4                /* Form format constant */
 
158
#define TE_INFO_LENGTH 3
 
159
#define MTYP_NOEMPTY_BIT 128
 
160
 
 
161
#define FRM_VER_TRUE_VARCHAR (FRM_VER+4) /* 10 */
 
162
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_CGE 50120
 
163
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM 50205
 
164
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_STR "50205"
 
165
 
102
166
/*
103
167
  Minimum length pattern before Turbo Boyer-Moore is used
104
168
  for SELECT "text" LIKE "%pattern%", excluding the two
106
170
*/
107
171
#define MIN_TURBOBM_PATTERN_LEN 3
108
172
 
109
 
/*
 
173
/* 
110
174
   Defines for binary logging.
111
175
   Do not decrease the value of BIN_LOG_HEADER_SIZE.
112
176
   Do not even increase it before checking code.
113
177
*/
114
178
 
115
 
#define BIN_LOG_HEADER_SIZE    4
 
179
#define BIN_LOG_HEADER_SIZE    4 
 
180
 
 
181
#define DEFAULT_KEY_CACHE_NAME "default"
 
182
 
 
183
#define STORAGE_TYPE_MASK 7
 
184
#define COLUMN_FORMAT_MASK 7
 
185
#define COLUMN_FORMAT_SHIFT 3
116
186
 
117
187
/* Below are #defines that used to be in mysql_priv.h */
118
188
/***************************************************************************
119
189
  Configuration parameters
120
190
****************************************************************************/
 
191
#define ACL_CACHE_SIZE          256
 
192
#define MAX_PASSWORD_LENGTH     32
 
193
#define HOST_CACHE_SIZE         128
 
194
#define MAX_ACCEPT_RETRY        10      // Test accept this many times
121
195
#define MAX_FIELDS_BEFORE_HASH  32
122
196
#define USER_VARS_HASH_SIZE     16
123
197
#define TABLE_OPEN_CACHE_MIN    64
124
 
#define TABLE_OPEN_CACHE_DEFAULT 1024
 
198
#define TABLE_OPEN_CACHE_DEFAULT 64
125
199
 
126
 
/*
 
200
/* 
127
201
 Value of 9236 discovered through binary search 2006-09-26 on Ubuntu Dapper
128
 
 Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added
 
202
 Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added 
129
203
 100 bytes as reasonable buffer against growth and other environments'
130
204
 requirements.)
131
205
 
137
211
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
138
212
#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
139
213
 
 
214
/** 
 
215
 * @TODO Move into a drizzled.h since it's only used in drizzled.cc
 
216
 *
 
217
 * @TODO Rename to DRIZZLED_NET_RETRY_COUNT
 
218
 */
 
219
#ifndef MYSQLD_NET_RETRY_COUNT
 
220
#define MYSQLD_NET_RETRY_COUNT  10      ///< Abort read after this many int.
 
221
#endif
 
222
#define TEMP_POOL_SIZE          128
 
223
 
140
224
#define QUERY_ALLOC_BLOCK_SIZE          8192
141
225
#define QUERY_ALLOC_PREALLOC_SIZE       8192
 
226
#define TRANS_ALLOC_BLOCK_SIZE          4096
 
227
#define TRANS_ALLOC_PREALLOC_SIZE       4096
142
228
#define RANGE_ALLOC_BLOCK_SIZE          4096
 
229
#define ACL_ALLOC_BLOCK_SIZE            1024
 
230
#define UDF_ALLOC_BLOCK_SIZE            1024
143
231
#define TABLE_ALLOC_BLOCK_SIZE          1024
 
232
#define BDB_LOG_ALLOC_BLOCK_SIZE        1024
144
233
#define WARN_ALLOC_BLOCK_SIZE           2048
145
234
#define WARN_ALLOC_PREALLOC_SIZE        1024
 
235
#define PROFILE_ALLOC_BLOCK_SIZE  2048
 
236
#define PROFILE_ALLOC_PREALLOC_SIZE 1024
146
237
 
147
238
/*
148
239
  The following parameters is to decide when to use an extra cache to
150
241
*/
151
242
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
152
243
#define MIN_ROWS_TO_USE_TABLE_CACHE      100
 
244
#define MIN_ROWS_TO_USE_BULK_INSERT      100
153
245
 
154
246
/**
155
247
  The following is used to decide if MySQL should use table scanning
159
251
#define TIME_FOR_COMPARE   5    // 5 compares == one read
160
252
 
161
253
/**
162
 
  Number of comparisons of table rowids equivalent to reading one row from a
 
254
  Number of comparisons of table rowids equivalent to reading one row from a 
163
255
  table.
164
256
*/
165
257
#define TIME_FOR_COMPARE_ROWID  (TIME_FOR_COMPARE*2)
166
258
 
167
259
/*
168
260
  For sequential disk seeks the cost formula is:
169
 
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip
170
 
 
171
 
  The cost of average seek
 
261
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip  
 
262
  
 
263
  The cost of average seek 
172
264
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
173
265
*/
174
266
#define DISK_SEEK_BASE_COST ((double)0.9)
190
282
 
191
283
/** Characters shown for the command in 'show processlist'. */
192
284
#define PROCESS_LIST_WIDTH 100
 
285
/* Characters shown for the command in 'information_schema.processlist' */
 
286
#define PROCESS_LIST_INFO_WIDTH 65535
193
287
 
194
288
#define PRECISION_FOR_DOUBLE 53
195
289
#define PRECISION_FOR_FLOAT  24
196
290
 
 
291
/*
 
292
  Default time to wait before aborting a new client connection
 
293
  that does not respond to "initial server greeting" timely
 
294
*/
 
295
#define CONNECT_TIMEOUT         10
 
296
 
197
297
/* The following can also be changed from the command line */
198
298
#define DEFAULT_CONCURRENCY     10
199
299
#define FLUSH_TIME              0               /**< Don't flush tables */
200
300
#define MAX_CONNECT_ERRORS      10              ///< errors before disabling host
201
301
 
202
 
/* Bits from testflag */
203
 
enum test_flag_bit
204
 
{
205
 
  TEST_PRINT_CACHED_TABLES= 1,
206
 
  TEST_NO_KEY_GROUP,
207
 
  TEST_MIT_THREAD,
208
 
  TEST_KEEP_TMP_TABLES,
209
 
  TEST_READCHECK, /**< Force use of readcheck */
210
 
  TEST_NO_EXTRA,
211
 
  TEST_CORE_ON_SIGNAL, /**< Give core if signal */
212
 
  TEST_NO_STACKTRACE,
213
 
  TEST_SIGINT, /**< Allow sigint on threads */
214
 
  TEST_SYNCHRONIZATION /**< get server to do sleep in some places */
215
 
};
 
302
#define INTERRUPT_PRIOR 10
 
303
#define CONNECT_PRIOR   9
 
304
#define WAIT_PRIOR      8
 
305
#define QUERY_PRIOR     6
 
306
 
 
307
        /* Bits from testflag */
 
308
#define TEST_PRINT_CACHED_TABLES 1
 
309
#define TEST_NO_KEY_GROUP        2
 
310
#define TEST_MIT_THREAD         4
 
311
#define TEST_BLOCKING           8
 
312
#define TEST_KEEP_TMP_TABLES    16
 
313
#define TEST_READCHECK          64      /**< Force use of readcheck */
 
314
#define TEST_NO_EXTRA           128
 
315
#define TEST_CORE_ON_SIGNAL     256     /**< Give core if signal */
 
316
#define TEST_NO_STACKTRACE      512
 
317
#define TEST_SIGINT             1024    /**< Allow sigint on threads */
 
318
#define TEST_SYNCHRONIZATION    2048    /**< get server to do sleep in some places */
 
319
#endif /* End ifndef DRIZZLE_CLIENT */
 
320
 
 
321
/* The rest of the file is included in the server only */
 
322
#ifndef DRIZZLE_CLIENT
216
323
 
217
324
/* Bits for different SQL modes modes (including ANSI mode) */
218
325
#define MODE_NO_ZERO_DATE               (2)
219
326
#define MODE_INVALID_DATES              (MODE_NO_ZERO_DATE*2)
220
327
 
 
328
/* @@optimizer_switch flags */
 
329
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
 
330
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
 
331
 
221
332
#define MY_CHARSET_BIN_MB_MAXLEN 1
222
333
 
223
334
// uncachable cause
224
 
static const uint32_t UNCACHEABLE_DEPENDENT= 1;
225
 
static const uint32_t UNCACHEABLE_RAND= 2;
226
 
static const uint32_t UNCACHEABLE_SIDEEFFECT= 3;
 
335
#define UNCACHEABLE_DEPENDENT   1
 
336
#define UNCACHEABLE_RAND        2
 
337
#define UNCACHEABLE_SIDEEFFECT  4
227
338
/// forcing to save JOIN for explain
228
 
static const uint32_t UNCACHEABLE_EXPLAIN= 4;
 
339
#define UNCACHEABLE_EXPLAIN     8
229
340
/** Don't evaluate subqueries in prepare even if they're not correlated */
230
 
static const uint32_t UNCACHEABLE_PREPARE= 5;
 
341
#define UNCACHEABLE_PREPARE    16
231
342
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
232
 
static const uint32_t UNCACHEABLE_UNITED= 6;
 
343
#define UNCACHEABLE_UNITED     32
233
344
 
234
345
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
235
346
#define UNDEF_POS (-1)
236
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
 
237
356
/* Options to add_table_to_list() */
238
 
static const uint32_t TL_OPTION_UPDATING= 0;
239
 
static const uint32_t TL_OPTION_FORCE_INDEX= 1;
240
 
static const uint32_t TL_OPTION_IGNORE_LEAVES= 2;
241
 
static const uint32_t TL_OPTION_ALIAS= 3;
242
 
static const uint32_t NUM_OF_TABLE_OPTIONS= 4;
 
357
#define TL_OPTION_UPDATING      1
 
358
#define TL_OPTION_FORCE_INDEX   2
 
359
#define TL_OPTION_IGNORE_LEAVES 4
 
360
#define TL_OPTION_ALIAS         8
243
361
 
244
362
/* Some portable defines */
245
363
 
246
364
#define portable_sizeof_char_ptr 8
247
365
 
248
 
#define TMP_FILE_PREFIX "#sql"                  /**< Prefix for tmp tables */
249
 
#define TMP_FILE_PREFIX_LENGTH 4
 
366
#define tmp_file_prefix "#sql"                  /**< Prefix for tmp tables */
 
367
#define tmp_file_prefix_length 4
250
368
 
251
369
/* Flags for calc_week() function.  */
252
370
#define WEEK_MONDAY_FIRST    1
253
371
#define WEEK_YEAR            2
254
372
#define WEEK_FIRST_WEEKDAY   4
255
373
 
256
 
/* used in date and time conversions */
257
 
/* Daynumber from year 0 to 9999-12-31 */
258
 
#define MAX_DAY_NUMBER 3652424L
259
 
 
260
374
#define STRING_BUFFER_USUAL_SIZE 80
261
375
 
262
 
typedef void *range_seq_t;
263
 
 
264
 
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
265
 
// the following is for checking tables
266
 
 
267
 
#define HA_ADMIN_ALREADY_DONE     1
268
 
#define HA_ADMIN_OK               0
269
 
#define HA_ADMIN_NOT_IMPLEMENTED -1
270
 
#define HA_ADMIN_FAILED          -2
271
 
#define HA_ADMIN_CORRUPT         -3
272
 
#define HA_ADMIN_INTERNAL_ERROR  -4
273
 
#define HA_ADMIN_INVALID         -5
274
 
#define HA_ADMIN_REJECT          -6
275
 
 
276
 
/* bits in index_flags(index_number) for what you can do with index */
277
 
#define HA_READ_NEXT            1       /* TODO really use this flag */
278
 
#define HA_READ_PREV            2       /* supports ::index_prev */
279
 
#define HA_READ_ORDER           4       /* index_next/prev follow sort order */
280
 
#define HA_READ_RANGE           8       /* can find all records in a range */
281
 
#define HA_ONLY_WHOLE_INDEX     16      /* Can't use part key searches */
282
 
#define HA_KEYREAD_ONLY         64      /* Support HA_EXTRA_KEYREAD */
283
 
/*
284
 
  Index scan will not return records in rowid order. Not guaranteed to be
285
 
  set for unordered (e.g. HASH) indexes.
286
 
*/
287
 
#define HA_KEY_SCAN_NOT_ROR     128
288
 
 
289
 
/* operations for disable/enable indexes */
290
 
#define HA_KEY_SWITCH_NONUNIQ      0
291
 
#define HA_KEY_SWITCH_ALL          1
292
 
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
293
 
#define HA_KEY_SWITCH_ALL_SAVE     3
294
 
 
295
 
/*
296
 
  Note: the following includes binlog and closing 0.
297
 
  so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
298
 
      example + csv + heap + blackhole + federated + 0
299
 
  (yes, the sum is deliberately inaccurate)
300
 
  TODO remove the limit, use dynarrays
301
 
*/
302
 
#define MAX_HA 15
303
 
 
304
 
/*
305
 
  Parameters for open() (in register form->filestat)
306
 
  HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
307
 
*/
308
 
 
309
 
#define HA_OPEN_KEYFILE         1
310
 
#define HA_OPEN_RNDFILE         2
311
 
#define HA_GET_INDEX            4
312
 
#define HA_GET_INFO             8       /* do a ha_info() after open */
313
 
#define HA_READ_ONLY            16      /* File opened as readonly */
314
 
/* Try readonly if can't open with read and write */
315
 
#define HA_TRY_READ_ONLY        32
316
 
#define HA_WAIT_IF_LOCKED       64      /* Wait if locked on open */
317
 
#define HA_ABORT_IF_LOCKED      128     /* skip if locked on open.*/
318
 
#define HA_BLOCK_LOCK           256     /* unlock when reading some records */
319
 
#define HA_OPEN_TEMPORARY       512
320
 
 
321
 
/* For transactional LOCK Table. handler::lock_table() */
322
 
#define HA_LOCK_IN_SHARE_MODE      F_RDLCK
323
 
#define HA_LOCK_IN_EXCLUSIVE_MODE  F_WRLCK
324
 
 
325
 
/* Some key definitions */
326
 
#define HA_KEY_NULL_LENGTH      1
327
 
#define HA_KEY_BLOB_LENGTH      2
328
 
 
329
 
#define HA_MAX_REC_LENGTH       65535
330
 
 
331
 
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
332
 
enum start_transaction_option_t
333
 
{
334
 
  START_TRANS_NO_OPTIONS,
335
 
  START_TRANS_OPT_WITH_CONS_SNAPSHOT
336
 
};
337
 
 
338
 
/* Flags for method is_fatal_error */
339
 
#define HA_CHECK_DUP_KEY 1
340
 
#define HA_CHECK_DUP_UNIQUE 2
341
 
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
342
 
 
343
 
 
344
 
/* Bits in used_fields */
345
 
#define HA_CREATE_USED_AUTO             (1L << 0)
346
 
#define HA_CREATE_USED_CHARSET          (1L << 8)
347
 
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
348
 
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
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
 
 
413
 
inline static void clear_timestamp_auto_bits(enum timestamp_auto_set_type &_target_, 
414
 
                                             const enum timestamp_auto_set_type _bits_)
415
 
{
416
 
  _target_= (enum timestamp_auto_set_type)((int)(_target_) & ~_bits_);
417
 
}
418
 
 
419
 
/*
420
 
 * The following are for the interface with the .frm file
421
 
 */
422
 
 
423
 
#define FIELDFLAG_PACK_SHIFT    3
424
 
#define FIELDFLAG_MAX_DEC    31
425
 
 
426
 
#ifdef __cplusplus
427
 
// FIXME: T will just be drizzled::Field::utype, but that would
428
 
// require including field.h. Moving the function elsewhere might be a
429
 
// better idea. Leaving it for restructuring.
430
 
template <typename T> 
431
 
T MTYP_TYPENR(const T& type)
432
 
{
433
 
  return static_cast<T>(type & 127);
434
 
}
435
 
#else
436
 
#define MTYP_TYPENR(type) (type & 127)  /* Remove bits from type */
437
 
#endif
438
 
 
439
 
inline static uint32_t f_settype(const enum enum_field_types x)
440
 
{
441
 
  return (uint32_t(x) << FIELDFLAG_PACK_SHIFT);
442
 
}
443
 
 
444
 
#ifdef __cplusplus
445
 
template <class T> void set_if_bigger(T &a, const T &b)
446
 
{
447
 
  if (a < b)
448
 
    a=b;
449
 
}
450
 
 
451
 
template <class T> void set_if_smaller(T &a, const T &b)
452
 
{
453
 
  if (a > b)
454
 
    a=b;
455
 
}
456
 
#else
457
 
#ifdef __GNUC__
458
 
#define set_if_bigger(a,b) do {                 \
459
 
  const typeof(a) _a = (a);                     \
460
 
  const typeof(b) _b = (b);                     \
461
 
  (void) (&_a == &_b);                          \
462
 
  if ((a) < (b)) (a)=(b);                       \
463
 
  } while(0)
464
 
#define set_if_smaller(a,b) do {                \
465
 
  const typeof(a) _a = (a);                     \
466
 
  const typeof(b) _b = (b);                     \
467
 
  (void) (&_a == &_b);                          \
468
 
  if ((a) > (b)) (a)=(b);                       \
469
 
  } while(0)
470
 
 
471
 
#else
472
 
#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
473
 
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
474
 
#endif
475
 
#endif
476
 
 
477
 
 
478
 
#define array_elements(a) \
479
 
  ((sizeof(a) / sizeof(*(a))) / \
480
 
   static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
481
 
 
482
 
 
483
 
/* Some types that is different between systems */
484
 
 
485
 
#ifndef FN_LIBCHAR
486
 
#define FN_LIBCHAR  '/'
487
 
#define FN_ROOTDIR  "/"
488
 
#endif
489
 
#define MY_NFILE  64  /* This is only used to save filenames */
490
 
#ifndef OS_FILE_LIMIT
491
 
#define OS_FILE_LIMIT  65535
492
 
#endif
493
 
 
494
 
/*
495
 
  How much overhead does malloc have. The code often allocates
496
 
  something like 1024-MALLOC_OVERHEAD bytes
497
 
*/
498
 
#define MALLOC_OVERHEAD 8
499
 
 
500
 
/* get memory in huncs */
501
 
static const uint32_t ONCE_ALLOC_INIT= 4096;
502
 
/* Typical record cash */
503
 
static const uint32_t RECORD_CACHE_SIZE= 64*1024;
504
 
 
505
 
 
506
 
/* Some things that this system doesn't have */
507
 
 
508
 
/* Some defines of functions for portability */
509
 
 
510
 
#ifndef uint64_t2double
511
 
#define uint64_t2double(A) ((double) (uint64_t) (A))
512
 
#endif
513
 
 
514
 
#ifndef offsetof
515
 
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
516
 
#endif
517
 
#define ulong_to_double(X) ((double) (ulong) (X))
518
 
 
519
 
/* From limits.h instead */
520
 
#ifndef DBL_MIN
521
 
#define DBL_MIN    4.94065645841246544e-324
522
 
#endif
523
 
#ifndef DBL_MAX
524
 
#define DBL_MAX    1.79769313486231470e+308
525
 
#endif
526
 
 
527
 
 
528
 
/* Define missing math constants. */
529
 
#ifndef M_PI
530
 
#define M_PI 3.14159265358979323846
531
 
#endif
532
 
#ifndef M_E
533
 
#define M_E 2.7182818284590452354
534
 
#endif
535
 
#ifndef M_LN2
536
 
#define M_LN2 0.69314718055994530942
537
 
#endif
538
 
 
539
 
/*
540
 
  Max size that must be added to a so that we know Size to make
541
 
  adressable obj.
542
 
*/
543
 
#define MY_ALIGN(A,L)  (((A) + (L) - 1) & ~((L) - 1))
544
 
#define ALIGN_SIZE(A)  MY_ALIGN((A),sizeof(double))
545
 
/* Size to make adressable obj. */
546
 
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
547
 
/* Offset of field f in structure t */
548
 
#define OFFSET(t, f)  ((size_t)(char *)&((t *)0)->f)
549
 
#ifdef __cplusplus
550
 
#define ADD_TO_PTR(ptr,size,type) (type) (reinterpret_cast<const unsigned char*>(ptr)+size)
551
 
#define PTR_BYTE_DIFF(A,B) (ptrdiff_t) (reinterpret_cast<const unsigned char*>(A) - reinterpret_cast<const unsigned char*>(B))
552
 
#else
553
 
 #define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
554
 
 #define PTR_BYTE_DIFF(A,B) (ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
555
 
#endif
556
 
 
557
 
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
558
 
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
559
 
 
560
 
/* Typdefs for easyier portability */
561
 
 
562
 
 
563
 
#if defined(SIZEOF_OFF_T)
564
 
# if (SIZEOF_OFF_T == 8)
565
 
#  define OFF_T_MAX (INT64_MAX)
566
 
# else
567
 
#  define OFF_T_MAX (INT32_MAX)
568
 
# endif
569
 
#endif
570
 
 
571
 
#define MY_FILEPOS_ERROR  -1
572
 
 
573
 
#define DRIZZLE_SERVER
574
 
 
575
 
/* Length of decimal number represented by INT32. */
576
 
#define MY_INT32_NUM_DECIMAL_DIGITS 11
577
 
 
578
 
/* Length of decimal number represented by INT64. */
579
 
#define MY_INT64_NUM_DECIMAL_DIGITS 21
580
 
 
581
 
/*
582
 
  Io buffer size; Must be a power of 2 and
583
 
  a multiple of 512. May be
584
 
  smaller what the disk page size. This influences the speed of the
585
 
  isam btree library. eg to big to slow.
586
 
*/
587
 
#define IO_SIZE 4096
588
 
/* Max file name len */
589
 
#define FN_LEN 256
590
 
/* Max length of extension (part of FN_LEN) */
591
 
#define FN_EXTLEN 20
592
 
/* Max length of full path-name */
593
 
#define FN_REFLEN 512
594
 
/* File extension character */
595
 
#define FN_EXTCHAR '.'
596
 
/* ~ is used as abbrev for home dir */
597
 
#define FN_HOMELIB '~'
598
 
/* ./ is used as abbrev for current dir */
599
 
#define FN_CURLIB '.'
600
 
/* Parent directory; Must be a string */
601
 
#define FN_PARENTDIR ".."
602
 
 
603
 
/* Quote argument (before cpp) */
604
 
#ifndef QUOTE_ARG
605
 
# define QUOTE_ARG(x) #x
606
 
#endif
607
 
/* Quote argument, (after cpp) */
608
 
#ifndef STRINGIFY_ARG
609
 
# define STRINGIFY_ARG(x) QUOTE_ARG(x)
610
 
#endif
611
 
 
612
 
/*
613
 
 * The macros below are borrowed from include/linux/compiler.h in the
614
 
 * Linux kernel. Use them to indicate the likelyhood of the truthfulness
615
 
 * of a condition. This serves two purposes - newer versions of gcc will be
616
 
 * able to optimize for branch predication, which could yield siginficant
617
 
 * performance gains in frequently executed sections of the code, and the
618
 
 * other reason to use them is for documentation
619
 
 */
620
 
#if !defined(__GNUC__)
621
 
#define __builtin_expect(x, expected_value) (x)
622
 
#endif
623
 
 
624
 
#define likely(x)  __builtin_expect((x),1)
625
 
#define unlikely(x)  __builtin_expect((x),0)
626
 
 
627
 
 
628
 
/*
629
 
  Only Linux is known to need an explicit sync of the directory to make sure a
630
 
  file creation/deletion/renaming in(from,to) this directory durable.
631
 
*/
632
 
#ifdef TARGET_OS_LINUX
633
 
#define NEED_EXPLICIT_SYNC_DIR 1
634
 
#endif
635
 
 
636
 
/* We need to turn off _DTRACE_VERSION if we're not going to use dtrace */
637
 
#if !defined(HAVE_DTRACE)
638
 
# undef _DTRACE_VERSION
639
 
# define _DTRACE_VERSION 0
640
 
#endif
641
 
 
642
 
typedef uint64_t table_map;   /* Used for table bits in join */
643
 
typedef uint32_t nesting_map; /* Used for flags of nesting constructs */
644
 
 
645
 
} /* namespace drizzled */
646
 
 
647
 
#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 */