~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definitions.h

  • Committer: Monty Taylor
  • Date: 2008-11-16 23:47:43 UTC
  • mto: (584.1.10 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081116234743-c38gmv0pa2kdefaj
BrokeĀ outĀ cached_item.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
/**
21
21
 * @file
22
22
 *
23
 
 * Mostly constants and some macros/functions used by the server
 
23
 * Mostly constants and some macros/functions used by the server  
24
24
 */
25
25
 
26
 
#ifndef DRIZZLED_DEFINITIONS_H
27
 
#define DRIZZLED_DEFINITIONS_H
28
 
 
29
 
#include <drizzled/enum.h>
 
26
#ifndef DRIZZLE_SERVER_DEFINITIONS_H
 
27
#define DRIZZLE_SERVER_DEFINITIONS_H
30
28
 
31
29
#include <stdint.h>
32
30
 
33
 
namespace drizzled
34
 
{
 
31
#ifndef NO_ALARM_LOOP
 
32
#define NO_ALARM_LOOP           /* lib5 and popen can't use alarm */
 
33
#endif
35
34
 
36
35
/* These paths are converted to other systems (WIN95) before use */
37
36
 
38
37
#define LANGUAGE        "english/"
 
38
#define ERRMSG_FILE     "errmsg.sys"
39
39
#define TEMP_PREFIX     "MY"
40
40
#define LOG_PREFIX      "ML"
41
 
 
42
 
#define ER(X) ::drizzled::error_message((X))
43
 
 
 
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 */
44
55
/* extra 4+4 bytes for slave tmp tables */
45
56
#define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
46
57
#define MAX_ALIAS_NAME 256
47
58
#define MAX_FIELD_NAME 34                       /* Max colum name length +2 */
48
59
#define MAX_SYS_VAR_LENGTH 32
49
 
#define MAX_INDEXES 64
50
60
#define MAX_KEY MAX_INDEXES                     /* Max used keys */
51
61
#define MAX_REF_PARTS 16                        /* Max parts used as ref */
52
62
#define MAX_KEY_LENGTH 4096                     /* max possible key */
66
76
/* Max column width +1 */
67
77
#define MAX_FIELD_WIDTH         (MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
68
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 */
69
85
#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
70
86
 
71
87
#define MAX_TABLES      (sizeof(table_map)*8-3) /* Max tables in join */
74
90
#define RAND_TABLE_BIT  (((table_map) 1) << (sizeof(table_map)*8-1))
75
91
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
76
92
                           RAND_TABLE_BIT)
77
 
#define MAX_FIELDS      4096      /* Historical limit from MySQL FRM. */
 
93
#define MAX_FIELDS      4096                    /* Limit in the .frm file */
78
94
 
79
95
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
80
96
 
81
97
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
82
98
#define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
83
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
 
84
106
#define DEFAULT_ERROR_COUNT     64
85
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 */
86
114
#define NAMES_SEP_CHAR  '\377'                  /* Char to sep. names */
87
115
 
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 */
 
116
#define READ_RECORD_BUFFER      (uint) (IO_SIZE*8) /* Pointer_buffer_size */
 
117
#define DISK_BUFFER_SIZE        (uint) (IO_SIZE*16) /* Size of diskbuffer */
90
118
 
 
119
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
91
120
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
92
121
#define MYF_RW MYF(MY_WME+MY_NABP)              /* Vid my_read & my_write */
93
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
 
94
169
/*
95
170
  Minimum length pattern before Turbo Boyer-Moore is used
96
171
  for SELECT "text" LIKE "%pattern%", excluding the two
98
173
*/
99
174
#define MIN_TURBOBM_PATTERN_LEN 3
100
175
 
101
 
/*
 
176
/* 
102
177
   Defines for binary logging.
103
178
   Do not decrease the value of BIN_LOG_HEADER_SIZE.
104
179
   Do not even increase it before checking code.
105
180
*/
106
181
 
107
 
#define BIN_LOG_HEADER_SIZE    4
 
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
108
189
 
109
190
/* Below are #defines that used to be in mysql_priv.h */
110
191
/***************************************************************************
111
192
  Configuration parameters
112
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
113
198
#define MAX_FIELDS_BEFORE_HASH  32
114
199
#define USER_VARS_HASH_SIZE     16
115
200
#define TABLE_OPEN_CACHE_MIN    64
116
 
#define TABLE_OPEN_CACHE_DEFAULT 1024
 
201
#define TABLE_OPEN_CACHE_DEFAULT 64
117
202
 
118
 
/*
 
203
/* 
119
204
 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
 
205
 Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added 
121
206
 100 bytes as reasonable buffer against growth and other environments'
122
207
 requirements.)
123
208
 
129
214
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
130
215
#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
131
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
 
132
227
#define QUERY_ALLOC_BLOCK_SIZE          8192
133
228
#define QUERY_ALLOC_PREALLOC_SIZE       8192
 
229
#define TRANS_ALLOC_BLOCK_SIZE          4096
 
230
#define TRANS_ALLOC_PREALLOC_SIZE       4096
134
231
#define RANGE_ALLOC_BLOCK_SIZE          4096
 
232
#define ACL_ALLOC_BLOCK_SIZE            1024
 
233
#define UDF_ALLOC_BLOCK_SIZE            1024
135
234
#define TABLE_ALLOC_BLOCK_SIZE          1024
 
235
#define BDB_LOG_ALLOC_BLOCK_SIZE        1024
136
236
#define WARN_ALLOC_BLOCK_SIZE           2048
137
237
#define WARN_ALLOC_PREALLOC_SIZE        1024
 
238
#define PROFILE_ALLOC_BLOCK_SIZE  2048
 
239
#define PROFILE_ALLOC_PREALLOC_SIZE 1024
138
240
 
139
241
/*
140
242
  The following parameters is to decide when to use an extra cache to
142
244
*/
143
245
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
144
246
#define MIN_ROWS_TO_USE_TABLE_CACHE      100
 
247
#define MIN_ROWS_TO_USE_BULK_INSERT      100
145
248
 
146
249
/**
147
250
  The following is used to decide if MySQL should use table scanning
151
254
#define TIME_FOR_COMPARE   5    // 5 compares == one read
152
255
 
153
256
/**
154
 
  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 
155
258
  table.
156
259
*/
157
260
#define TIME_FOR_COMPARE_ROWID  (TIME_FOR_COMPARE*2)
158
261
 
159
262
/*
160
263
  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
 
264
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip  
 
265
  
 
266
  The cost of average seek 
164
267
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
165
268
*/
166
269
#define DISK_SEEK_BASE_COST ((double)0.9)
188
291
#define PRECISION_FOR_DOUBLE 53
189
292
#define PRECISION_FOR_FLOAT  24
190
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
 
191
300
/* The following can also be changed from the command line */
192
301
#define DEFAULT_CONCURRENCY     10
193
302
#define FLUSH_TIME              0               /**< Don't flush tables */
198
307
#define WAIT_PRIOR      8
199
308
#define QUERY_PRIOR     6
200
309
 
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
 
};
 
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 */
215
321
 
216
322
/* Bits for different SQL modes modes (including ANSI mode) */
217
323
#define MODE_NO_ZERO_DATE               (2)
218
324
#define MODE_INVALID_DATES              (MODE_NO_ZERO_DATE*2)
219
325
 
 
326
/* @@optimizer_switch flags */
 
327
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
 
328
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
 
329
 
220
330
#define MY_CHARSET_BIN_MB_MAXLEN 1
221
331
 
222
332
// uncachable cause
233
343
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
234
344
#define UNDEF_POS (-1)
235
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
 
236
354
/* Options to add_table_to_list() */
237
355
#define TL_OPTION_UPDATING      1
238
356
#define TL_OPTION_FORCE_INDEX   2
243
361
 
244
362
#define portable_sizeof_char_ptr 8
245
363
 
246
 
#define TMP_FILE_PREFIX "#sql"                  /**< Prefix for tmp tables */
247
 
#define TMP_FILE_PREFIX_LENGTH 4
 
364
#define tmp_file_prefix "#sql"                  /**< Prefix for tmp tables */
 
365
#define tmp_file_prefix_length 4
248
366
 
249
367
/* Flags for calc_week() function.  */
250
368
#define WEEK_MONDAY_FIRST    1
251
369
#define WEEK_YEAR            2
252
370
#define WEEK_FIRST_WEEKDAY   4
253
371
 
254
 
/* used in date and time conversions */
255
 
/* Daynumber from year 0 to 9999-12-31 */
256
 
#define MAX_DAY_NUMBER 3652424L
257
 
 
258
372
#define STRING_BUFFER_USUAL_SIZE 80
259
373
 
 
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
 
 
480
typedef uint64_t query_id_t;
260
481
typedef void *range_seq_t;
261
482
 
262
 
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
 
483
 
 
484
/**
 
485
   The maximum is defined as (ULONG_MAX/1000) with 4 bytes uint32_t
 
486
*/
 
487
static const uint32_t SLAVE_MAX_HEARTBEAT_PERIOD= 4294967;
 
488
 
 
489
#define SLAVE_NET_TIMEOUT  3600
 
490
 
 
491
#define MAX_SLAVE_ERROR    2000
 
492
 
 
493
/* masks for start/stop operations on io and sql slave threads */
 
494
#define SLAVE_IO  1
 
495
#define SLAVE_SQL 2
 
496
 
 
497
#ifndef NO_HASH
 
498
#define NO_HASH                         /* Not yet implemented */
 
499
#endif
 
500
 
263
501
// the following is for checking tables
264
502
 
265
503
#define HA_ADMIN_ALREADY_DONE     1
270
508
#define HA_ADMIN_INTERNAL_ERROR  -4
271
509
#define HA_ADMIN_INVALID         -5
272
510
#define HA_ADMIN_REJECT          -6
 
511
#define HA_ADMIN_TRY_ALTER       -7
 
512
#define HA_ADMIN_WRONG_CHECKSUM  -8
 
513
#define HA_ADMIN_NOT_BASE_TABLE  -9
 
514
#define HA_ADMIN_NEEDS_UPGRADE  -10
 
515
#define HA_ADMIN_NEEDS_ALTER    -11
 
516
#define HA_ADMIN_NEEDS_CHECK    -12
 
517
 
 
518
 
 
519
#define HA_ADD_INDEX                  (0)
 
520
#define HA_DROP_INDEX                 (1)
 
521
#define HA_ALTER_INDEX                (2)
 
522
#define HA_RENAME_INDEX               (3)
 
523
#define HA_ADD_UNIQUE_INDEX           (4)
 
524
#define HA_DROP_UNIQUE_INDEX          (5)
 
525
#define HA_ALTER_UNIQUE_INDEX         (6)
 
526
#define HA_RENAME_UNIQUE_INDEX        (7)
 
527
#define HA_ADD_PK_INDEX               (8)
 
528
#define HA_DROP_PK_INDEX              (9)
 
529
#define HA_ALTER_PK_INDEX             (10)
 
530
#define HA_ADD_COLUMN                 (11)
 
531
#define HA_DROP_COLUMN                (12)
 
532
#define HA_CHANGE_COLUMN              (13)
 
533
#define HA_ALTER_COLUMN_NAME          (14)
 
534
#define HA_ALTER_COLUMN_TYPE          (15)
 
535
#define HA_ALTER_COLUMN_ORDER         (16)
 
536
#define HA_ALTER_COLUMN_NULLABLE      (17)
 
537
#define HA_COLUMN_DEFAULT_VALUE       (18)
 
538
#define HA_COLUMN_STORAGE             (19)
 
539
#define HA_COLUMN_FORMAT              (20)
 
540
#define HA_ADD_FOREIGN_KEY            (21)
 
541
#define HA_DROP_FOREIGN_KEY           (22)
 
542
#define HA_ALTER_FOREIGN_KEY          (23)
 
543
#define HA_ADD_CONSTRAINT             (24)
 
544
#define HA_CHANGE_CHARACTER_SET       (30)
 
545
#define HA_SET_DEFAULT_CHARACTER_SET  (31)
 
546
#define HA_CHANGE_AUTOINCREMENT_VALUE (32)
 
547
#define HA_ALTER_STORAGE              (33)
 
548
#define HA_ALTER_TABLESPACE           (34)
 
549
#define HA_ALTER_ROW_FORMAT           (35)
 
550
#define HA_RENAME_TABLE               (36)
 
551
#define HA_ALTER_STORAGE_ENGINE       (37)
 
552
#define HA_RECREATE                   (38)
 
553
#define HA_ALTER_STORED_VCOL          (39)
 
554
/* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
 
555
 
 
556
/* Return values for check_if_supported_alter */
 
557
 
 
558
#define HA_ALTER_ERROR               -1
 
559
#define HA_ALTER_SUPPORTED_WAIT_LOCK  0
 
560
#define HA_ALTER_SUPPORTED_NO_LOCK    1
 
561
#define HA_ALTER_NOT_SUPPORTED        2
 
562
 
 
563
/* Bits in table_flags() to show what database can do */
 
564
 
 
565
#define HA_NO_TRANSACTIONS     (1 << 0) /* Doesn't support transactions */
 
566
#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */
 
567
#define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */
 
568
/*
 
569
  The following should be set if the following is not true when scanning
 
570
  a table with rnd_next()
 
571
  - We will see all rows (including deleted ones)
 
572
  - Row positions are 'table->s->db_record_offset' apart
 
573
  If this flag is not set, filesort will do a postion() call for each matched
 
574
  row to be able to find the row later.
 
575
*/
 
576
#define HA_REC_NOT_IN_SEQ      (1 << 3)
 
577
 
 
578
/*
 
579
  Reading keys in random order is as fast as reading keys in sort order
 
580
  (Used in records.cc to decide if we should use a record cache and by
 
581
  filesort to decide if we should sort key + data or key + pointer-to-row
 
582
*/
 
583
#define HA_FAST_KEY_READ       (1 << 5)
 
584
/*
 
585
  Set the following flag if we on delete should force all key to be read
 
586
  and on update read all keys that changes
 
587
*/
 
588
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6)
 
589
#define HA_NULL_IN_KEY         (1 << 7) /* One can have keys with NULL */
 
590
#define HA_DUPLICATE_POS       (1 << 8)    /* ha_position() gives dup row */
 
591
#define HA_NO_BLOBS            (1 << 9) /* Doesn't support blobs */
 
592
#define HA_CAN_INDEX_BLOBS     (1 << 10)
 
593
#define HA_AUTO_PART_KEY       (1 << 11) /* auto-increment in multi-part key */
 
594
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */
 
595
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */
 
596
/*
 
597
  If we get the primary key columns for free when we do an index read
 
598
  It also implies that we have to retrive the primary key when using
 
599
  position() and rnd_pos().
 
600
*/
 
601
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
 
602
/*
 
603
  If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
 
604
  uses a primary key. Without primary key, we can't call position().
 
605
*/ 
 
606
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16) 
 
607
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
 
608
/*
 
609
  The following is we need to a primary key to delete (and update) a row.
 
610
  If there is no primary key, all columns needs to be read on update and delete
 
611
*/
 
612
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
 
613
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
 
614
#define HA_NO_AUTO_INCREMENT   (1 << 23)
 
615
#define HA_HAS_CHECKSUM        (1 << 24)
 
616
/* Table data are stored in separate files (for lower_case_table_names) */
 
617
#define HA_FILE_BASED          (1 << 26)
 
618
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
 
619
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
 
620
#define HA_NO_COPY_ON_ALTER    (INT64_C(1) << 31)
 
621
#define HA_HAS_RECORDS         (INT64_C(1) << 32) /* records() gives exact count*/
 
622
#define HA_MRR_CANT_SORT       (INT64_C(1) << 34)
 
623
 
 
624
/*
 
625
  Engine is capable of row-format and statement-format logging,
 
626
  respectively
 
627
*/
 
628
#define HA_BINLOG_ROW_CAPABLE  (INT64_C(1) << 35)
 
629
#define HA_BINLOG_STMT_CAPABLE (INT64_C(1) << 36)
 
630
 
 
631
#define HA_ONLINE_ALTER        (INT64_C(1) << 37)
 
632
 
 
633
/*
 
634
  Set of all binlog flags. Currently only contain the capabilities
 
635
  flags.
 
636
 */
 
637
#define HA_BINLOG_FLAGS (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE)
273
638
 
274
639
/* bits in index_flags(index_number) for what you can do with index */
275
640
#define HA_READ_NEXT            1       /* TODO really use this flag */
282
647
  Index scan will not return records in rowid order. Not guaranteed to be
283
648
  set for unordered (e.g. HASH) indexes.
284
649
*/
285
 
#define HA_KEY_SCAN_NOT_ROR     128
 
650
#define HA_KEY_SCAN_NOT_ROR     128 
 
651
#define HA_DO_INDEX_COND_PUSHDOWN  256 /* Supports Index Condition Pushdown */
 
652
 
 
653
 
 
654
 
 
655
/*
 
656
  HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is
 
657
  supported at all.
 
658
  HA_FAST_CHANGE_PARTITION means that optimised variants of the changes
 
659
  exists but they are not necessarily done online.
 
660
 
 
661
  HA_ONLINE_DOUBLE_WRITE means that the handler supports writing to both
 
662
  the new partition and to the old partitions when updating through the
 
663
  old partitioning schema while performing a change of the partitioning.
 
664
  This means that we can support updating of the table while performing
 
665
  the copy phase of the change. For no lock at all also a double write
 
666
  from new to old must exist and this is not required when this flag is
 
667
  set.
 
668
  This is actually removed even before it was introduced the first time.
 
669
  The new idea is that handlers will handle the lock level already in
 
670
  store_lock for ALTER Table partitions.
 
671
 
 
672
  HA_PARTITION_ONE_PHASE is a flag that can be set by handlers that take
 
673
  care of changing the partitions online and in one phase. Thus all phases
 
674
  needed to handle the change are implemented inside the storage engine.
 
675
  The storage engine must also support auto-discovery since the frm file
 
676
  is changed as part of the change and this change must be controlled by
 
677
  the storage engine. A typical engine to support this is NDB (through
 
678
  WL #2498).
 
679
*/
 
680
#define HA_PARTITION_FUNCTION_SUPPORTED         (1L << 1)
 
681
#define HA_FAST_CHANGE_PARTITION                (1L << 2)
 
682
#define HA_PARTITION_ONE_PHASE                  (1L << 3)
286
683
 
287
684
/* operations for disable/enable indexes */
288
685
#define HA_KEY_SWITCH_NONUNIQ      0
324
721
#define HA_KEY_NULL_LENGTH      1
325
722
#define HA_KEY_BLOB_LENGTH      2
326
723
 
 
724
#define HA_LEX_CREATE_TMP_TABLE 1
 
725
#define HA_LEX_CREATE_IF_NOT_EXISTS 2
 
726
#define HA_LEX_CREATE_TABLE_LIKE 4
 
727
#define HA_OPTION_NO_CHECKSUM   (1L << 17)
 
728
#define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18)
327
729
#define HA_MAX_REC_LENGTH       65535
328
730
 
 
731
/* Table caching type */
 
732
#define HA_CACHE_TBL_NONTRANSACT 0
 
733
#define HA_CACHE_TBL_NOCACHE     1
 
734
#define HA_CACHE_TBL_ASKTRANSACT 2
 
735
#define HA_CACHE_TBL_TRANSACT    4
 
736
 
329
737
/* 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
 
};
 
738
#define DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
335
739
 
336
740
/* Flags for method is_fatal_error */
337
741
#define HA_CHECK_DUP_KEY 1
338
742
#define HA_CHECK_DUP_UNIQUE 2
339
743
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
340
744
 
 
745
enum legacy_db_type
 
746
{
 
747
  DB_TYPE_UNKNOWN=0,
 
748
  DB_TYPE_FIRST_DYNAMIC=42,
 
749
  DB_TYPE_DEFAULT=127 // Must be last
 
750
};
 
751
 
 
752
enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED,
 
753
                ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED,
 
754
                ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGE };
 
755
 
 
756
enum column_format_type { COLUMN_FORMAT_TYPE_NOT_USED= -1,
 
757
                          COLUMN_FORMAT_TYPE_DEFAULT=   0,
 
758
                          COLUMN_FORMAT_TYPE_FIXED=     1,
 
759
                          COLUMN_FORMAT_TYPE_DYNAMIC=   2 };
 
760
 
 
761
enum enum_binlog_func {
 
762
  BFN_RESET_LOGS=        1,
 
763
  BFN_RESET_SLAVE=       2,
 
764
  BFN_BINLOG_WAIT=       3,
 
765
  BFN_BINLOG_END=        4,
 
766
  BFN_BINLOG_PURGE_FILE= 5
 
767
};
 
768
 
 
769
enum enum_binlog_command {
 
770
  LOGCOM_CREATE_TABLE,
 
771
  LOGCOM_ALTER_TABLE,
 
772
  LOGCOM_RENAME_TABLE,
 
773
  LOGCOM_DROP_TABLE,
 
774
  LOGCOM_CREATE_DB,
 
775
  LOGCOM_ALTER_DB,
 
776
  LOGCOM_DROP_DB
 
777
};
 
778
 
 
779
/* struct to hold information about the table that should be created */
341
780
 
342
781
/* Bits in used_fields */
343
782
#define HA_CREATE_USED_AUTO             (1L << 0)
 
783
#ifdef DEAD_OPTIONS
 
784
#define HA_CREATE_USED_UNION            (1L << 2)
 
785
#define HA_CREATE_USED_PASSWORD         (1L << 17)
 
786
#endif
 
787
#define HA_CREATE_USED_INSERT_METHOD    (1L << 3)
 
788
#define HA_CREATE_USED_MIN_ROWS         (1L << 4)
 
789
#define HA_CREATE_USED_MAX_ROWS         (1L << 5)
 
790
#define HA_CREATE_USED_AVG_ROW_LENGTH   (1L << 6)
 
791
#define HA_CREATE_USED_PACK_KEYS        (1L << 7)
344
792
#define HA_CREATE_USED_CHARSET          (1L << 8)
345
793
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
 
794
#define HA_CREATE_USED_DATADIR          (1L << 10)
 
795
#define HA_CREATE_USED_INDEXDIR         (1L << 11)
 
796
#define HA_CREATE_USED_ENGINE           (1L << 12)
 
797
#define HA_CREATE_USED_CHECKSUM         (1L << 13)
 
798
#define HA_CREATE_USED_DELAY_KEY_WRITE  (1L << 14)
346
799
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
 
800
#define HA_CREATE_USED_COMMENT          (1L << 16)
 
801
#define HA_CREATE_USED_CONNECTION       (1L << 18)
347
802
#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)
 
803
#define HA_CREATE_USED_PAGE_CHECKSUM    (1L << 21)
348
804
#define HA_CREATE_USED_BLOCK_SIZE       (1L << 22)
349
805
 
 
806
#define MAXGTRIDSIZE 64
 
807
#define MAXBQUALSIZE 64
 
808
 
 
809
#define COMPATIBLE_DATA_YES 0
 
810
#define COMPATIBLE_DATA_NO  1
 
811
 
 
812
#define UNDEF_NODEGROUP 65535
 
813
#define NOT_A_PARTITION_ID ((uint32_t)-1)
 
814
 
 
815
enum ha_choice { HA_CHOICE_UNDEF, HA_CHOICE_NO, HA_CHOICE_YES };
 
816
 
 
817
/* Possible flags of a handlerton (there can be 32 of them) */
 
818
#define HTON_NO_FLAGS                 0
 
819
#define HTON_CLOSE_CURSORS_AT_COMMIT (1 << 0)
 
820
#define HTON_ALTER_NOT_SUPPORTED     (1 << 1) //Engine does not support alter
 
821
#define HTON_CAN_RECREATE            (1 << 2) //Delete all is used fro truncate
 
822
#define HTON_HIDDEN                  (1 << 3) //Engine does not appear in lists
 
823
#define HTON_FLUSH_AFTER_RENAME      (1 << 4)
 
824
#define HTON_NOT_USER_SELECTABLE     (1 << 5)
 
825
#define HTON_TEMPORARY_NOT_SUPPORTED (1 << 6) //Having temporary tables not supported
 
826
#define HTON_SUPPORT_LOG_TABLES      (1 << 7) //Engine supports log tables
 
827
#define HTON_NO_PARTITION            (1 << 8) //You can not partition these tables
350
828
/*
351
829
  The below two are not used (and not handled) in this milestone of this WL
352
830
  entry because there seems to be no use for them at this stage of
355
833
#define HA_MRR_SINGLE_POINT 1
356
834
#define HA_MRR_FIXED_KEY  2
357
835
 
358
 
/*
 
836
/* 
359
837
  Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
360
838
  'range' parameter.
361
839
*/
362
840
#define HA_MRR_NO_ASSOCIATION 4
363
841
 
364
 
/*
 
842
/* 
365
843
  The MRR user will provide ranges in key order, and MRR implementation
366
844
  must return rows in key order.
367
845
*/
370
848
/* MRR implementation doesn't have to retrieve full records */
371
849
#define HA_MRR_INDEX_ONLY 16
372
850
 
373
 
/*
 
851
/* 
374
852
  The passed memory buffer is of maximum possible size, the caller can't
375
853
  assume larger buffer.
376
854
*/
385
863
*/
386
864
#define HA_MRR_USE_DEFAULT_IMPL 64
387
865
 
 
866
/*
 
867
  Used only as parameter to multi_range_read_info():
 
868
  Flag set <=> the caller guarantees that the bounds of the scanned ranges
 
869
  will not have NULL values.
 
870
*/
 
871
#define HA_MRR_NO_NULL_ENDPOINTS 128
 
872
 
 
873
enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY, RNEXT_SAME };
 
874
 
 
875
enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED,
 
876
                         ISO_REPEATABLE_READ, ISO_SERIALIZABLE};
 
877
 
 
878
 
 
879
enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
 
880
 
388
881
typedef int myf;
389
 
#define MYF(v)          (static_cast<drizzled::myf>(v))
 
882
#define MYF(v)          (myf) (v)
 
883
 
 
884
/*
 
885
  When a command is added here, be sure it's also added in mysqld.cc
 
886
  in "struct show_var_st status_vars[]= {" ...
 
887
 
 
888
  If the command returns a result set or is not allowed in stored
 
889
  functions or triggers, please also make sure that
 
890
  sp_get_flags_for_command (sp_head.cc) returns proper flags for the
 
891
  added SQLCOM_.
 
892
*/
 
893
 
 
894
enum enum_sql_command {
 
895
  SQLCOM_SELECT, SQLCOM_CREATE_TABLE, SQLCOM_CREATE_INDEX, SQLCOM_ALTER_TABLE,
 
896
  SQLCOM_UPDATE, SQLCOM_INSERT, SQLCOM_INSERT_SELECT,
 
897
  SQLCOM_DELETE, SQLCOM_TRUNCATE, SQLCOM_DROP_TABLE, SQLCOM_DROP_INDEX,
 
898
  SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS,
 
899
  SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_STATUS,
 
900
  SQLCOM_SHOW_ENGINE_LOGS, SQLCOM_SHOW_ENGINE_STATUS, SQLCOM_SHOW_ENGINE_MUTEX,
 
901
  SQLCOM_SHOW_PROCESSLIST, SQLCOM_SHOW_MASTER_STAT, SQLCOM_SHOW_SLAVE_STAT,
 
902
  SQLCOM_SHOW_CREATE,
 
903
  SQLCOM_SHOW_CREATE_DB,
 
904
  SQLCOM_SHOW_TABLE_STATUS,
 
905
  SQLCOM_LOAD,SQLCOM_SET_OPTION,SQLCOM_LOCK_TABLES,SQLCOM_UNLOCK_TABLES,
 
906
  SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB, SQLCOM_ALTER_DB,
 
907
  SQLCOM_REPAIR, SQLCOM_REPLACE, SQLCOM_REPLACE_SELECT,
 
908
  SQLCOM_OPTIMIZE, SQLCOM_CHECK,
 
909
  SQLCOM_ASSIGN_TO_KEYCACHE,
 
910
  SQLCOM_FLUSH, SQLCOM_KILL, SQLCOM_ANALYZE,
 
911
  SQLCOM_ROLLBACK, SQLCOM_ROLLBACK_TO_SAVEPOINT,
 
912
  SQLCOM_COMMIT, SQLCOM_SAVEPOINT, SQLCOM_RELEASE_SAVEPOINT,
 
913
  SQLCOM_SLAVE_START, SQLCOM_SLAVE_STOP,
 
914
  SQLCOM_BEGIN, SQLCOM_CHANGE_MASTER,
 
915
  SQLCOM_RENAME_TABLE,  
 
916
  SQLCOM_RESET, SQLCOM_PURGE, SQLCOM_PURGE_BEFORE, SQLCOM_SHOW_BINLOGS,
 
917
  SQLCOM_SHOW_OPEN_TABLES,
 
918
  SQLCOM_DELETE_MULTI, SQLCOM_UPDATE_MULTI,
 
919
  SQLCOM_SHOW_WARNS,
 
920
  SQLCOM_EMPTY_QUERY,
 
921
  SQLCOM_SHOW_ERRORS,
 
922
  SQLCOM_CHECKSUM,
 
923
  SQLCOM_BINLOG_BASE64_EVENT,
 
924
  SQLCOM_SHOW_PLUGINS,
 
925
  /*
 
926
    When a command is added here, be sure it's also added in mysqld.cc
 
927
    in "struct show_var_st status_vars[]= {" ...
 
928
  */
 
929
  /* This should be the last !!! */
 
930
  SQLCOM_END
 
931
};
 
932
 
 
933
enum enum_duplicates { DUP_ERROR, DUP_REPLACE, DUP_UPDATE };
 
934
 
 
935
enum release_type { RELEASE_NORMAL, RELEASE_WAIT_FOR_DROP };
 
936
 
 
937
/*
 
938
  Make sure that the order of schema_tables and enum_schema_tables are the same.
 
939
*/
 
940
 
 
941
enum enum_schema_tables
 
942
{
 
943
  SCH_CHARSETS= 0,
 
944
  SCH_COLLATIONS,
 
945
  SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
 
946
  SCH_COLUMNS,
 
947
  SCH_GLOBAL_STATUS,
 
948
  SCH_GLOBAL_VARIABLES,
 
949
  SCH_KEY_COLUMN_USAGE,
 
950
  SCH_OPEN_TABLES,
 
951
  SCH_PLUGINS,
 
952
  SCH_PROCESSLIST,
 
953
  SCH_REFERENTIAL_CONSTRAINTS,
 
954
  SCH_SCHEMATA,
 
955
  SCH_SESSION_STATUS,
 
956
  SCH_SESSION_VARIABLES,
 
957
  SCH_STATISTICS,
 
958
  SCH_STATUS,
 
959
  SCH_TABLES,
 
960
  SCH_TABLE_CONSTRAINTS,
 
961
  SCH_TABLE_NAMES,
 
962
  SCH_VARIABLES
 
963
};
 
964
 
 
965
 
 
966
#define MY_I_S_MAYBE_NULL 1
 
967
#define MY_I_S_UNSIGNED   2
 
968
 
 
969
 
 
970
#define SKIP_OPEN_TABLE 0                // do not open table
 
971
#define OPEN_FRM_ONLY   1                // open FRM file only
 
972
#define OPEN_FULL_TABLE 2                // open FRM,MYD, MYI files
390
973
 
391
974
/*
392
975
   "Declared Type Collation"
409
992
#define MY_COLL_ALLOW_CONV            3
410
993
#define MY_COLL_DISALLOW_NONE         4
411
994
#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 */
 
995
 
 
996
 
 
997
/*
 
998
  This enum is used to report information about monotonicity of function
 
999
  represented by Item* tree.
 
1000
  Monotonicity is defined only for Item* trees that represent table
 
1001
  partitioning expressions (i.e. have no subselects/user vars/PS parameters
 
1002
  etc etc). An Item* tree is assumed to have the same monotonicity properties
 
1003
  as its correspoinding function F:
 
1004
 
 
1005
  [signed] int64_t F(field1, field2, ...) {
 
1006
    put values of field_i into table record buffer;
 
1007
    return item->val_int(); 
 
1008
  }
 
1009
 
 
1010
  NOTE
 
1011
  At the moment function monotonicity is not well defined (and so may be
 
1012
  incorrect) for Item trees with parameters/return types that are different
 
1013
  from INT_RESULT, may be NULL, or are unsigned.
 
1014
  It will be possible to address this issue once the related partitioning bugs
 
1015
  (BUG#16002, BUG#15447, BUG#13436) are fixed.
 
1016
*/
 
1017
 
 
1018
typedef enum monotonicity_info 
 
1019
{
 
1020
   NON_MONOTONIC,              /* none of the below holds */
 
1021
   MONOTONIC_INCREASING,       /* F() is unary and (x < y) => (F(x) <= F(y)) */
 
1022
   MONOTONIC_STRICT_INCREASING /* F() is unary and (x < y) => (F(x) <  F(y)) */
 
1023
} enum_monotonicity_info;
 
1024
 
 
1025
 
 
1026
#endif /* DRIZZLE_SERVER_DEFINITIONS_H */
 
1027