~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definitions.h

  • Committer: Padraig O'Sullivan
  • Date: 2009-03-21 01:02:23 UTC
  • mto: (960.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 961.
  • Revision ID: osullivan.padraig@gmail.com-20090321010223-j8cph7eeyt1u3xol
Fixed function object to ensure it correctly returns a boolean type since
memcmp returns an integer. Added some more comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
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
 
#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"
 
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
40
#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
 
 
 
41
#define PROGDIR         "bin/"
 
42
 
 
43
#define ER(X) error_message((X))
 
44
 
 
45
#define LIBLEN FN_REFLEN-FN_LEN                 /* Max l{ngd p} dev */
52
46
/* extra 4+4 bytes for slave tmp tables */
53
47
#define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
54
48
#define MAX_ALIAS_NAME 256
55
49
#define MAX_FIELD_NAME 34                       /* Max colum name length +2 */
56
50
#define MAX_SYS_VAR_LENGTH 32
57
 
#define MAX_INDEXES 64
58
51
#define MAX_KEY MAX_INDEXES                     /* Max used keys */
59
52
#define MAX_REF_PARTS 16                        /* Max parts used as ref */
60
53
#define MAX_KEY_LENGTH 4096                     /* max possible key */
74
67
/* Max column width +1 */
75
68
#define MAX_FIELD_WIDTH         (MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
76
69
 
 
70
#define MAX_DATE_WIDTH          10      /* YYYY-MM-DD */
 
71
#define MAX_TIME_WIDTH          23      /* -DDDDDD HH:MM:SS.###### */
 
72
#define MAX_DATETIME_FULL_WIDTH 29      /* YYYY-MM-DD HH:MM:SS.###### AM */
 
73
#define MAX_DATETIME_WIDTH      19      /* YYYY-MM-DD HH:MM:SS */
77
74
#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
78
75
 
79
76
#define MAX_TABLES      (sizeof(table_map)*8-3) /* Max tables in join */
82
79
#define RAND_TABLE_BIT  (((table_map) 1) << (sizeof(table_map)*8-1))
83
80
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
84
81
                           RAND_TABLE_BIT)
85
 
#define MAX_FIELDS      4096      /* Historical limit from MySQL FRM. */
 
82
#define MAX_FIELDS      4096                    /* Limit in the .frm file */
86
83
 
87
84
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
88
85
 
89
86
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
90
87
#define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
91
88
 
 
89
/* Memory allocated when parsing a statement / saving a statement */
 
90
#define MEM_ROOT_BLOCK_SIZE       8192
 
91
#define MEM_ROOT_PREALLOC         8192
 
92
#define TRANS_MEM_ROOT_BLOCK_SIZE 4096
 
93
#define TRANS_MEM_ROOT_PREALLOC   4096
 
94
 
92
95
#define DEFAULT_ERROR_COUNT     64
93
96
#define EXTRA_RECORDS   10                      /* Extra records in sort */
 
97
#define SCROLL_EXTRA    5                       /* Extra scroll-rows. */
 
98
#define FIELD_NAME_USED ((uint32_t) 32768)              /* Bit set if fieldname used */
 
99
#define FIELD_NR_MASK   16383                   /* To get fieldnumber */
 
100
#define FERR            -1                      /* Error from my_functions */
 
101
#define CREATE_MODE     0                       /* Default mode on new files */
94
102
#define NAMES_SEP_CHAR  '\377'                  /* Char to sep. names */
95
103
 
96
104
#define READ_RECORD_BUFFER      (uint32_t) (IO_SIZE*8) /* Pointer_buffer_size */
97
105
#define DISK_BUFFER_SIZE        (uint32_t) (IO_SIZE*16) /* Size of diskbuffer */
98
106
 
 
107
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
99
108
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
100
109
#define MYF_RW MYF(MY_WME+MY_NABP)              /* Vid my_read & my_write */
101
110
 
 
111
        /* Extern defines */
 
112
#define store_record(A,B) memcpy((A)->B,(A)->record[0],(size_t) (A)->s->reclength)
 
113
#define restore_record(A,B) memcpy((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
 
114
#define cmp_record(A,B) memcmp((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
 
115
#define empty_record(A)                                 \
 
116
  do {                                                  \
 
117
    restore_record((A),s->default_values);              \
 
118
    memset((A)->null_flags, 255, (A)->s->null_bytes);   \
 
119
  } while (0)
 
120
 
 
121
        /* Defines for use with openfrm, openprt and openfrd */
 
122
 
 
123
#define READ_ALL                1       /* openfrm: Read all parameters */
 
124
#define CHANGE_FRM              2       /* openfrm: open .frm as O_RDWR */
 
125
#define EXTRA_RECORD            8       /* Reservera plats f|r extra record */
 
126
#define DONT_GIVE_ERROR         256     /* Don't do frm_error on openfrm  */
 
127
#define DELAYED_OPEN            4096    /* Open table later */
 
128
/**
 
129
  This flag is used in function get_all_tables() which fills
 
130
  I_S tables with data which are retrieved from frm files and storage engine
 
131
  The flag means that we need to open FRM file only to get necessary data.
 
132
*/
 
133
#define OPEN_FRM_FILE_ONLY     32768
 
134
/**
 
135
  This flag is used in function get_all_tables() which fills
 
136
  I_S tables with data which are retrieved from frm files and storage engine
 
137
  The flag means that we need to process tables only to get necessary data.
 
138
  Views are not processed.
 
139
*/
 
140
#define OPEN_TABLE_ONLY        OPEN_FRM_FILE_ONLY*2
 
141
/**
 
142
  This flag is used in function get_all_tables() which fills
 
143
  I_S tables with data which are retrieved from frm files and storage engine.
 
144
  The flag means that I_S table uses optimization algorithm.
 
145
*/
 
146
#define OPTIMIZE_I_S_TABLE     OPEN_TABLE_ONLY*2
 
147
 
 
148
#define SC_INFO_LENGTH 4                /* Form format constant */
 
149
#define TE_INFO_LENGTH 3
 
150
 
 
151
#define FRM_VER 6
 
152
#define FRM_VER_TRUE_VARCHAR (FRM_VER+4) /* 10 */
 
153
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_CGE 50120
 
154
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM 50205
 
155
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_STR "50205"
 
156
 
102
157
/*
103
158
  Minimum length pattern before Turbo Boyer-Moore is used
104
159
  for SELECT "text" LIKE "%pattern%", excluding the two
114
169
 
115
170
#define BIN_LOG_HEADER_SIZE    4
116
171
 
 
172
#define DEFAULT_KEY_CACHE_NAME "default"
 
173
 
 
174
#define STORAGE_TYPE_MASK 7
 
175
#define COLUMN_FORMAT_MASK 7
 
176
#define COLUMN_FORMAT_SHIFT 3
 
177
 
117
178
/* Below are #defines that used to be in mysql_priv.h */
118
179
/***************************************************************************
119
180
  Configuration parameters
120
181
****************************************************************************/
 
182
#define MAX_PASSWORD_LENGTH     32
 
183
#define MAX_ACCEPT_RETRY        10      // Test accept this many times
121
184
#define MAX_FIELDS_BEFORE_HASH  32
122
185
#define USER_VARS_HASH_SIZE     16
123
186
#define TABLE_OPEN_CACHE_MIN    64
137
200
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
138
201
#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
139
202
 
 
203
/**
 
204
 * @TODO Move into a drizzled.h since it's only used in drizzled.cc
 
205
 *
 
206
 * @TODO Rename to DRIZZLED_NET_RETRY_COUNT
 
207
 */
 
208
#ifndef MYSQLD_NET_RETRY_COUNT
 
209
#define MYSQLD_NET_RETRY_COUNT  10      ///< Abort read after this many int.
 
210
#endif
 
211
#define TEMP_POOL_SIZE          128
 
212
 
140
213
#define QUERY_ALLOC_BLOCK_SIZE          8192
141
214
#define QUERY_ALLOC_PREALLOC_SIZE       8192
 
215
#define TRANS_ALLOC_BLOCK_SIZE          4096
 
216
#define TRANS_ALLOC_PREALLOC_SIZE       4096
142
217
#define RANGE_ALLOC_BLOCK_SIZE          4096
 
218
#define UDF_ALLOC_BLOCK_SIZE            1024
143
219
#define TABLE_ALLOC_BLOCK_SIZE          1024
144
220
#define WARN_ALLOC_BLOCK_SIZE           2048
145
221
#define WARN_ALLOC_PREALLOC_SIZE        1024
 
222
#define PROFILE_ALLOC_BLOCK_SIZE  2048
 
223
#define PROFILE_ALLOC_PREALLOC_SIZE 1024
146
224
 
147
225
/*
148
226
  The following parameters is to decide when to use an extra cache to
150
228
*/
151
229
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
152
230
#define MIN_ROWS_TO_USE_TABLE_CACHE      100
 
231
#define MIN_ROWS_TO_USE_BULK_INSERT      100
153
232
 
154
233
/**
155
234
  The following is used to decide if MySQL should use table scanning
190
269
 
191
270
/** Characters shown for the command in 'show processlist'. */
192
271
#define PROCESS_LIST_WIDTH 100
 
272
/* Characters shown for the command in 'information_schema.processlist' */
 
273
#define PROCESS_LIST_INFO_WIDTH 65535
193
274
 
194
275
#define PRECISION_FOR_DOUBLE 53
195
276
#define PRECISION_FOR_FLOAT  24
196
277
 
 
278
/*
 
279
  Default time to wait before aborting a new client connection
 
280
  that does not respond to "initial server greeting" timely
 
281
*/
 
282
#define CONNECT_TIMEOUT         10
 
283
 
197
284
/* The following can also be changed from the command line */
198
285
#define DEFAULT_CONCURRENCY     10
199
286
#define FLUSH_TIME              0               /**< Don't flush tables */
200
287
#define MAX_CONNECT_ERRORS      10              ///< errors before disabling host
201
288
 
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
 
};
 
289
#define INTERRUPT_PRIOR 10
 
290
#define CONNECT_PRIOR   9
 
291
#define WAIT_PRIOR      8
 
292
#define QUERY_PRIOR     6
 
293
 
 
294
        /* Bits from testflag */
 
295
#define TEST_PRINT_CACHED_TABLES 1
 
296
#define TEST_NO_KEY_GROUP        2
 
297
#define TEST_MIT_THREAD         4
 
298
#define TEST_KEEP_TMP_TABLES    16
 
299
#define TEST_READCHECK          64      /**< Force use of readcheck */
 
300
#define TEST_NO_EXTRA           128
 
301
#define TEST_CORE_ON_SIGNAL     256     /**< Give core if signal */
 
302
#define TEST_NO_STACKTRACE      512
 
303
#define TEST_SIGINT             1024    /**< Allow sigint on threads */
 
304
#define TEST_SYNCHRONIZATION    2048    /**< get server to do sleep in some places */
216
305
 
217
306
/* Bits for different SQL modes modes (including ANSI mode) */
218
307
#define MODE_NO_ZERO_DATE               (2)
219
308
#define MODE_INVALID_DATES              (MODE_NO_ZERO_DATE*2)
220
309
 
 
310
/* @@optimizer_switch flags */
 
311
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
 
312
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
 
313
 
221
314
#define MY_CHARSET_BIN_MB_MAXLEN 1
222
315
 
223
316
// 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;
 
317
#define UNCACHEABLE_DEPENDENT   1
 
318
#define UNCACHEABLE_RAND        2
 
319
#define UNCACHEABLE_SIDEEFFECT  4
227
320
/// forcing to save JOIN for explain
228
 
static const uint32_t UNCACHEABLE_EXPLAIN= 4;
 
321
#define UNCACHEABLE_EXPLAIN     8
229
322
/** Don't evaluate subqueries in prepare even if they're not correlated */
230
 
static const uint32_t UNCACHEABLE_PREPARE= 5;
 
323
#define UNCACHEABLE_PREPARE    16
231
324
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
232
 
static const uint32_t UNCACHEABLE_UNITED= 6;
 
325
#define UNCACHEABLE_UNITED     32
233
326
 
234
327
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
235
328
#define UNDEF_POS (-1)
236
329
 
 
330
/* BINLOG_DUMP options */
 
331
 
 
332
#define BINLOG_DUMP_NON_BLOCK   1
 
333
 
 
334
/* sql_show.cc:show_log_files() */
 
335
#define SHOW_LOG_STATUS_FREE "FREE"
 
336
#define SHOW_LOG_STATUS_INUSE "IN USE"
 
337
 
237
338
/* 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;
 
339
#define TL_OPTION_UPDATING      1
 
340
#define TL_OPTION_FORCE_INDEX   2
 
341
#define TL_OPTION_IGNORE_LEAVES 4
 
342
#define TL_OPTION_ALIAS         8
243
343
 
244
344
/* Some portable defines */
245
345
 
259
359
 
260
360
#define STRING_BUFFER_USUAL_SIZE 80
261
361
 
 
362
/*
 
363
  Some defines for exit codes for ::is_equal class functions.
 
364
*/
 
365
#define IS_EQUAL_NO 0
 
366
#define IS_EQUAL_YES 1
 
367
#define IS_EQUAL_PACK_LENGTH 2
 
368
 
 
369
 
 
370
/**
 
371
  Query type constants.
 
372
 
 
373
  QT_ORDINARY -- ordinary SQL query.
 
374
  QT_IS -- SQL query to be shown in INFORMATION_SCHEMA (in utf8 and without
 
375
  character set introducers).
 
376
 
 
377
  @TODO
 
378
 
 
379
  Move this out of here once Stew's done with UDF breakout.  The following headers need it:
 
380
 
 
381
    sql_lex.h --> included by session.h
 
382
    item.h
 
383
    table.h
 
384
    item_func.h
 
385
    item_subselect.h
 
386
    item_timefunc.h
 
387
    item_sum.h
 
388
    item_cmpfunc.h
 
389
    item_strfunc.h
 
390
*/
 
391
enum enum_query_type
 
392
{
 
393
  QT_ORDINARY,
 
394
  QT_IS
 
395
};
 
396
 
 
397
 
 
398
/**
 
399
 * @TODO Move to a separate header?
 
400
 *
 
401
 * It's needed by item.h and field.h, which are both inter-dependent
 
402
 * and contain forward declarations of many structs/classes in the
 
403
 * other header file.
 
404
 *
 
405
 * What is needed is a separate header file that is included
 
406
 * by *both* item.h and field.h to resolve inter-dependencies
 
407
 *
 
408
 * But, probably want to hold off on this until Stew finished the UDF cleanup
 
409
 */
 
410
enum Derivation
 
411
{
 
412
  DERIVATION_IGNORABLE= 5,
 
413
  DERIVATION_COERCIBLE= 4,
 
414
  DERIVATION_SYSCONST= 3,
 
415
  DERIVATION_IMPLICIT= 2,
 
416
  DERIVATION_NONE= 1,
 
417
  DERIVATION_EXPLICIT= 0
 
418
};
 
419
 
 
420
/**
 
421
 * Opening modes for open_temporary_table and open_table_from_share
 
422
 *
 
423
 * @TODO Put this into an appropriate header. It is only needed in:
 
424
 *
 
425
 *    table.cc
 
426
 *    sql_base.cc
 
427
 */
 
428
enum open_table_mode
 
429
{
 
430
  OTM_OPEN= 0,
 
431
  OTM_CREATE= 1,
 
432
  OTM_ALTER= 2
 
433
};
 
434
 
 
435
enum enum_parsing_place
 
436
{
 
437
  NO_MATTER
 
438
  , IN_HAVING
 
439
  , SELECT_LIST
 
440
  , IN_WHERE
 
441
  , IN_ON
 
442
};
 
443
 
 
444
enum enum_mysql_completiontype {
 
445
  ROLLBACK_RELEASE= -2
 
446
  , ROLLBACK= 1
 
447
  , ROLLBACK_AND_CHAIN= 7
 
448
  , COMMIT_RELEASE= -1
 
449
  , COMMIT= 0
 
450
  , COMMIT_AND_CHAIN= 6
 
451
};
 
452
 
 
453
enum enum_check_fields
 
454
{
 
455
  CHECK_FIELD_IGNORE
 
456
  , CHECK_FIELD_WARN
 
457
  , CHECK_FIELD_ERROR_FOR_NULL
 
458
};
 
459
 
 
460
enum enum_var_type
 
461
{
 
462
  OPT_DEFAULT= 0
 
463
  , OPT_SESSION
 
464
  , OPT_GLOBAL
 
465
};
 
466
 
 
467
 
 
468
typedef uint64_t query_id_t;
262
469
typedef void *range_seq_t;
263
470
 
264
 
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
 
471
 
 
472
/**
 
473
   The maximum is defined as (ULONG_MAX/1000) with 4 bytes uint32_t
 
474
*/
 
475
static const uint32_t SLAVE_MAX_HEARTBEAT_PERIOD= 4294967;
 
476
 
 
477
#define SLAVE_NET_TIMEOUT  3600
 
478
 
 
479
#define MAX_SLAVE_ERROR    2000
 
480
 
 
481
/* masks for start/stop operations on io and sql slave threads */
 
482
#define SLAVE_IO  1
 
483
#define SLAVE_SQL 2
 
484
 
 
485
#ifndef NO_HASH
 
486
#define NO_HASH                         /* Not yet implemented */
 
487
#endif
 
488
 
265
489
// the following is for checking tables
266
490
 
267
491
#define HA_ADMIN_ALREADY_DONE     1
272
496
#define HA_ADMIN_INTERNAL_ERROR  -4
273
497
#define HA_ADMIN_INVALID         -5
274
498
#define HA_ADMIN_REJECT          -6
 
499
#define HA_ADMIN_TRY_ALTER       -7
 
500
#define HA_ADMIN_NEEDS_UPGRADE  -10
 
501
#define HA_ADMIN_NEEDS_ALTER    -11
 
502
#define HA_ADMIN_NEEDS_CHECK    -12
 
503
 
 
504
 
 
505
#define HA_ADD_INDEX                  (0)
 
506
#define HA_DROP_INDEX                 (1)
 
507
#define HA_ALTER_INDEX                (2)
 
508
#define HA_RENAME_INDEX               (3)
 
509
#define HA_ADD_UNIQUE_INDEX           (4)
 
510
#define HA_DROP_UNIQUE_INDEX          (5)
 
511
#define HA_ALTER_UNIQUE_INDEX         (6)
 
512
#define HA_RENAME_UNIQUE_INDEX        (7)
 
513
#define HA_ADD_PK_INDEX               (8)
 
514
#define HA_DROP_PK_INDEX              (9)
 
515
#define HA_ALTER_PK_INDEX             (10)
 
516
#define HA_ADD_COLUMN                 (11)
 
517
#define HA_DROP_COLUMN                (12)
 
518
#define HA_CHANGE_COLUMN              (13)
 
519
#define HA_ALTER_COLUMN_NAME          (14)
 
520
#define HA_ALTER_COLUMN_TYPE          (15)
 
521
#define HA_ALTER_COLUMN_ORDER         (16)
 
522
#define HA_ALTER_COLUMN_NULLABLE      (17)
 
523
#define HA_COLUMN_DEFAULT_VALUE       (18)
 
524
#define HA_COLUMN_STORAGE             (19)
 
525
#define HA_COLUMN_FORMAT              (20)
 
526
#define HA_ADD_FOREIGN_KEY            (21)
 
527
#define HA_DROP_FOREIGN_KEY           (22)
 
528
#define HA_ALTER_FOREIGN_KEY          (23)
 
529
#define HA_ADD_CONSTRAINT             (24)
 
530
#define HA_CHANGE_CHARACTER_SET       (30)
 
531
#define HA_SET_DEFAULT_CHARACTER_SET  (31)
 
532
#define HA_CHANGE_AUTOINCREMENT_VALUE (32)
 
533
#define HA_ALTER_STORAGE              (33)
 
534
#define HA_ALTER_TABLESPACE           (34)
 
535
#define HA_ALTER_ROW_FORMAT           (35)
 
536
#define HA_RENAME_TABLE               (36)
 
537
#define HA_ALTER_STORAGE_ENGINE       (37)
 
538
#define HA_RECREATE                   (38)
 
539
#define HA_ALTER_STORED_VCOL          (39)
 
540
/* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
 
541
 
 
542
/* Return values for check_if_supported_alter */
 
543
 
 
544
#define HA_ALTER_ERROR               -1
 
545
#define HA_ALTER_SUPPORTED_WAIT_LOCK  0
 
546
#define HA_ALTER_SUPPORTED_NO_LOCK    1
 
547
#define HA_ALTER_NOT_SUPPORTED        2
 
548
 
 
549
/* Bits in table_flags() to show what database can do */
 
550
 
 
551
#define HA_NO_TRANSACTIONS     (1 << 0) /* Doesn't support transactions */
 
552
#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */
 
553
#define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */
 
554
/*
 
555
  The following should be set if the following is not true when scanning
 
556
  a table with rnd_next()
 
557
  - We will see all rows (including deleted ones)
 
558
  - Row positions are 'table->s->db_record_offset' apart
 
559
  If this flag is not set, filesort will do a postion() call for each matched
 
560
  row to be able to find the row later.
 
561
*/
 
562
#define HA_REC_NOT_IN_SEQ      (1 << 3)
 
563
 
 
564
/*
 
565
  Reading keys in random order is as fast as reading keys in sort order
 
566
  (Used in records.cc to decide if we should use a record cache and by
 
567
  filesort to decide if we should sort key + data or key + pointer-to-row
 
568
*/
 
569
#define HA_FAST_KEY_READ       (1 << 5)
 
570
/*
 
571
  Set the following flag if we on delete should force all key to be read
 
572
  and on update read all keys that changes
 
573
*/
 
574
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6)
 
575
#define HA_NULL_IN_KEY         (1 << 7) /* One can have keys with NULL */
 
576
#define HA_DUPLICATE_POS       (1 << 8)    /* ha_position() gives dup row */
 
577
#define HA_NO_BLOBS            (1 << 9) /* Doesn't support blobs */
 
578
#define HA_CAN_INDEX_BLOBS     (1 << 10)
 
579
#define HA_AUTO_PART_KEY       (1 << 11) /* auto-increment in multi-part key */
 
580
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */
 
581
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */
 
582
/*
 
583
  If we get the primary key columns for free when we do an index read
 
584
  It also implies that we have to retrive the primary key when using
 
585
  position() and rnd_pos().
 
586
*/
 
587
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
 
588
/*
 
589
  If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
 
590
  uses a primary key. Without primary key, we can't call position().
 
591
*/
 
592
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16)
 
593
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
 
594
/*
 
595
  The following is we need to a primary key to delete (and update) a row.
 
596
  If there is no primary key, all columns needs to be read on update and delete
 
597
*/
 
598
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
 
599
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
 
600
#define HA_NO_AUTO_INCREMENT   (1 << 23)
 
601
#define HA_HAS_CHECKSUM        (1 << 24)
 
602
/* Table data are stored in separate files (for lower_case_table_names) */
 
603
#define HA_FILE_BASED          (1 << 26)
 
604
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
 
605
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
 
606
#define HA_NO_COPY_ON_ALTER    (INT64_C(1) << 31)
 
607
#define HA_HAS_RECORDS         (INT64_C(1) << 32) /* records() gives exact count*/
 
608
#define HA_MRR_CANT_SORT       (INT64_C(1) << 34)
 
609
 
 
610
/*
 
611
  Engine is capable of row-format and statement-format logging,
 
612
  respectively
 
613
*/
 
614
#define HA_BINLOG_ROW_CAPABLE  (INT64_C(1) << 35)
 
615
#define HA_BINLOG_STMT_CAPABLE (INT64_C(1) << 36)
 
616
 
 
617
#define HA_ONLINE_ALTER        (INT64_C(1) << 37)
 
618
 
 
619
/*
 
620
  Set of all binlog flags. Currently only contain the capabilities
 
621
  flags.
 
622
 */
 
623
#define HA_BINLOG_FLAGS (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE)
275
624
 
276
625
/* bits in index_flags(index_number) for what you can do with index */
277
626
#define HA_READ_NEXT            1       /* TODO really use this flag */
285
634
  set for unordered (e.g. HASH) indexes.
286
635
*/
287
636
#define HA_KEY_SCAN_NOT_ROR     128
 
637
#define HA_DO_INDEX_COND_PUSHDOWN  256 /* Supports Index Condition Pushdown */
288
638
 
289
639
/* operations for disable/enable indexes */
290
640
#define HA_KEY_SWITCH_NONUNIQ      0
326
676
#define HA_KEY_NULL_LENGTH      1
327
677
#define HA_KEY_BLOB_LENGTH      2
328
678
 
 
679
#define HA_LEX_CREATE_TMP_TABLE 1
 
680
#define HA_LEX_CREATE_IF_NOT_EXISTS 2
 
681
#define HA_LEX_CREATE_TABLE_LIKE 4
 
682
#define HA_OPTION_NO_CHECKSUM   (1L << 17)
 
683
#define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18)
329
684
#define HA_MAX_REC_LENGTH       65535
330
685
 
 
686
/* Table caching type */
 
687
#define HA_CACHE_TBL_NONTRANSACT 0
 
688
#define HA_CACHE_TBL_NOCACHE     1
 
689
#define HA_CACHE_TBL_ASKTRANSACT 2
 
690
#define HA_CACHE_TBL_TRANSACT    4
 
691
 
331
692
/* 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
 
};
 
693
#define DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
337
694
 
338
695
/* Flags for method is_fatal_error */
339
696
#define HA_CHECK_DUP_KEY 1
340
697
#define HA_CHECK_DUP_UNIQUE 2
341
698
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
342
699
 
 
700
enum legacy_db_type
 
701
{
 
702
  DB_TYPE_UNKNOWN=0,
 
703
  DB_TYPE_FIRST_DYNAMIC=42,
 
704
  DB_TYPE_DEFAULT=127 // Must be last
 
705
};
 
706
 
 
707
enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED,
 
708
                ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED,
 
709
                ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGE };
 
710
 
 
711
enum column_format_type { COLUMN_FORMAT_TYPE_NOT_USED= -1,
 
712
                          COLUMN_FORMAT_TYPE_DEFAULT=   0,
 
713
                          COLUMN_FORMAT_TYPE_FIXED=     1,
 
714
                          COLUMN_FORMAT_TYPE_DYNAMIC=   2 };
 
715
 
 
716
enum enum_binlog_func {
 
717
  BFN_RESET_LOGS=        1,
 
718
  BFN_RESET_SLAVE=       2,
 
719
  BFN_BINLOG_WAIT=       3,
 
720
  BFN_BINLOG_END=        4,
 
721
  BFN_BINLOG_PURGE_FILE= 5
 
722
};
 
723
 
 
724
enum enum_binlog_command {
 
725
  LOGCOM_CREATE_TABLE,
 
726
  LOGCOM_ALTER_TABLE,
 
727
  LOGCOM_RENAME_TABLE,
 
728
  LOGCOM_DROP_TABLE,
 
729
  LOGCOM_CREATE_DB,
 
730
  LOGCOM_ALTER_DB,
 
731
  LOGCOM_DROP_DB
 
732
};
 
733
 
 
734
/* struct to hold information about the table that should be created */
343
735
 
344
736
/* Bits in used_fields */
345
737
#define HA_CREATE_USED_AUTO             (1L << 0)
 
738
#ifdef DEAD_OPTIONS
 
739
#define HA_CREATE_USED_UNION            (1L << 2)
 
740
#define HA_CREATE_USED_PASSWORD         (1L << 17)
 
741
#endif
 
742
#define HA_CREATE_USED_INSERT_METHOD    (1L << 3)
 
743
#define HA_CREATE_USED_MIN_ROWS         (1L << 4)
 
744
#define HA_CREATE_USED_MAX_ROWS         (1L << 5)
 
745
#define HA_CREATE_USED_AVG_ROW_LENGTH   (1L << 6)
 
746
#define HA_CREATE_USED_PACK_KEYS        (1L << 7)
346
747
#define HA_CREATE_USED_CHARSET          (1L << 8)
347
748
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
 
749
#define HA_CREATE_USED_DATADIR          (1L << 10)
 
750
#define HA_CREATE_USED_INDEXDIR         (1L << 11)
 
751
#define HA_CREATE_USED_ENGINE           (1L << 12)
 
752
#define HA_CREATE_USED_CHECKSUM         (1L << 13)
 
753
#define HA_CREATE_USED_DELAY_KEY_WRITE  (1L << 14)
348
754
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
 
755
#define HA_CREATE_USED_COMMENT          (1L << 16)
 
756
#define HA_CREATE_USED_CONNECTION       (1L << 18)
 
757
#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)
 
758
#define HA_CREATE_USED_PAGE_CHECKSUM    (1L << 21)
 
759
#define HA_CREATE_USED_BLOCK_SIZE       (1L << 22)
 
760
 
 
761
#define MAXGTRIDSIZE 64
 
762
#define MAXBQUALSIZE 64
 
763
 
 
764
#define COMPATIBLE_DATA_YES 0
 
765
#define COMPATIBLE_DATA_NO  1
 
766
 
 
767
#define UNDEF_NODEGROUP 65535
 
768
#define NOT_A_PARTITION_ID ((uint32_t)-1)
 
769
 
 
770
enum ha_choice { HA_CHOICE_UNDEF, HA_CHOICE_NO, HA_CHOICE_YES };
349
771
 
350
772
/*
351
773
  The below two are not used (and not handled) in this milestone of this WL
385
807
*/
386
808
#define HA_MRR_USE_DEFAULT_IMPL 64
387
809
 
 
810
/*
 
811
  Used only as parameter to multi_range_read_info():
 
812
  Flag set <=> the caller guarantees that the bounds of the scanned ranges
 
813
  will not have NULL values.
 
814
*/
 
815
#define HA_MRR_NO_NULL_ENDPOINTS 128
 
816
 
 
817
enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY, RNEXT_SAME };
 
818
 
 
819
enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED,
 
820
                         ISO_REPEATABLE_READ, ISO_SERIALIZABLE};
 
821
 
 
822
 
 
823
enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
 
824
 
388
825
typedef int myf;
389
 
#define MYF(v)          (static_cast<drizzled::myf>(v))
 
826
#define MYF(v)          (myf) (v)
 
827
 
 
828
/*
 
829
  When a command is added here, be sure it's also added in mysqld.cc
 
830
  in "struct show_var_st status_vars[]= {" ...
 
831
 
 
832
  If the command returns a result set or is not allowed in stored
 
833
  functions or triggers, please also make sure that
 
834
  sp_get_flags_for_command (sp_head.cc) returns proper flags for the
 
835
  added SQLCOM_.
 
836
*/
 
837
 
 
838
enum enum_sql_command {
 
839
  SQLCOM_SELECT, SQLCOM_CREATE_TABLE, SQLCOM_CREATE_INDEX, SQLCOM_ALTER_TABLE,
 
840
  SQLCOM_UPDATE, SQLCOM_INSERT, SQLCOM_INSERT_SELECT,
 
841
  SQLCOM_DELETE, SQLCOM_TRUNCATE, SQLCOM_DROP_TABLE, SQLCOM_DROP_INDEX,
 
842
  SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS,
 
843
  SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_STATUS,
 
844
  SQLCOM_SHOW_ENGINE_LOGS, SQLCOM_SHOW_ENGINE_STATUS, SQLCOM_SHOW_ENGINE_MUTEX,
 
845
  SQLCOM_SHOW_PROCESSLIST,
 
846
  SQLCOM_SHOW_CREATE,
 
847
  SQLCOM_SHOW_CREATE_DB,
 
848
  SQLCOM_SHOW_TABLE_STATUS,
 
849
  SQLCOM_LOAD,SQLCOM_SET_OPTION,SQLCOM_LOCK_TABLES,SQLCOM_UNLOCK_TABLES,
 
850
  SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB, SQLCOM_ALTER_DB,
 
851
  SQLCOM_REPAIR, SQLCOM_REPLACE, SQLCOM_REPLACE_SELECT,
 
852
  SQLCOM_OPTIMIZE, SQLCOM_CHECK,
 
853
  SQLCOM_ASSIGN_TO_KEYCACHE,
 
854
  SQLCOM_FLUSH, SQLCOM_KILL, SQLCOM_ANALYZE,
 
855
  SQLCOM_ROLLBACK, SQLCOM_ROLLBACK_TO_SAVEPOINT,
 
856
  SQLCOM_COMMIT, SQLCOM_SAVEPOINT, SQLCOM_RELEASE_SAVEPOINT,
 
857
  SQLCOM_SLAVE_START, SQLCOM_SLAVE_STOP,
 
858
  SQLCOM_BEGIN,
 
859
  SQLCOM_RENAME_TABLE,
 
860
  SQLCOM_SHOW_OPEN_TABLES,
 
861
  SQLCOM_DELETE_MULTI, SQLCOM_UPDATE_MULTI,
 
862
  SQLCOM_SHOW_WARNS,
 
863
  SQLCOM_EMPTY_QUERY,
 
864
  SQLCOM_SHOW_ERRORS,
 
865
  SQLCOM_CHECKSUM,
 
866
  SQLCOM_SHOW_PLUGINS,
 
867
  /*
 
868
    When a command is added here, be sure it's also added in mysqld.cc
 
869
    in "struct show_var_st status_vars[]= {" ...
 
870
  */
 
871
  /* This should be the last !!! */
 
872
  SQLCOM_END
 
873
};
 
874
 
 
875
enum enum_duplicates { DUP_ERROR, DUP_REPLACE, DUP_UPDATE };
 
876
 
 
877
enum release_type { RELEASE_NORMAL, RELEASE_WAIT_FOR_DROP };
 
878
 
 
879
/*
 
880
  Make sure that the order of schema_tables and enum_schema_tables are the same.
 
881
*/
 
882
 
 
883
enum enum_schema_tables
 
884
{
 
885
  SCH_CHARSETS= 0,
 
886
  SCH_COLLATIONS,
 
887
  SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
 
888
  SCH_COLUMNS,
 
889
  SCH_GLOBAL_STATUS,
 
890
  SCH_GLOBAL_VARIABLES,
 
891
  SCH_KEY_COLUMN_USAGE,
 
892
  SCH_OPEN_TABLES,
 
893
  SCH_PLUGINS,
 
894
  SCH_PROCESSLIST,
 
895
  SCH_REFERENTIAL_CONSTRAINTS,
 
896
  SCH_SCHEMATA,
 
897
  SCH_SESSION_STATUS,
 
898
  SCH_SESSION_VARIABLES,
 
899
  SCH_STATISTICS,
 
900
  SCH_STATUS,
 
901
  SCH_TABLES,
 
902
  SCH_TABLE_CONSTRAINTS,
 
903
  SCH_TABLE_NAMES,
 
904
  SCH_VARIABLES
 
905
};
 
906
 
 
907
 
 
908
#define MY_I_S_MAYBE_NULL 1
 
909
#define MY_I_S_UNSIGNED   2
 
910
 
 
911
 
 
912
#define SKIP_OPEN_TABLE 0                // do not open table
 
913
#define OPEN_FRM_ONLY   1                // open FRM file only
 
914
#define OPEN_FULL_TABLE 2                // open FRM,MYD, MYI files
390
915
 
391
916
/*
392
917
   "Declared Type Collation"
410
935
#define MY_COLL_DISALLOW_NONE         4
411
936
#define MY_COLL_CMP_CONV              7
412
937
 
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
 
}
 
938
 
 
939
/*
 
940
  This enum is used to report information about monotonicity of function
 
941
  represented by Item* tree.
 
942
  Monotonicity is defined only for Item* trees that represent table
 
943
  partitioning expressions (i.e. have no subselects/user vars/PS parameters
 
944
  etc etc). An Item* tree is assumed to have the same monotonicity properties
 
945
  as its correspoinding function F:
 
946
 
 
947
  [signed] int64_t F(field1, field2, ...) {
 
948
    put values of field_i into table record buffer;
 
949
    return item->val_int();
 
950
  }
 
951
 
 
952
  NOTE
 
953
  At the moment function monotonicity is not well defined (and so may be
 
954
  incorrect) for Item trees with parameters/return types that are different
 
955
  from INT_RESULT, may be NULL, or are unsigned.
 
956
  It will be possible to address this issue once the related partitioning bugs
 
957
  (BUG#16002, BUG#15447, BUG#13436) are fixed.
 
958
*/
 
959
 
 
960
typedef enum monotonicity_info
 
961
{
 
962
   NON_MONOTONIC,              /* none of the below holds */
 
963
   MONOTONIC_INCREASING,       /* F() is unary and (x < y) => (F(x) <= F(y)) */
 
964
   MONOTONIC_STRICT_INCREASING /* F() is unary and (x < y) => (F(x) <  F(y)) */
 
965
} enum_monotonicity_info;
 
966
 
 
967
enum tmp_table_type
 
968
{
 
969
  NO_TMP_TABLE, NON_TRANSACTIONAL_TMP_TABLE, TRANSACTIONAL_TMP_TABLE,
 
970
  INTERNAL_TMP_TABLE, SYSTEM_TMP_TABLE, TMP_TABLE_FRM_FILE_ONLY
 
971
};
 
972
 
 
973
/*
 
974
  Values in this enum are used to indicate how a tables TIMESTAMP field
 
975
  should be treated. It can be set to the current timestamp on insert or
 
976
  update or both.
 
977
  WARNING: The values are used for bit operations. If you change the
 
978
  enum, you must keep the bitwise relation of the values. For example:
 
979
  (int) TIMESTAMP_AUTO_SET_ON_BOTH must be equal to
 
980
  (int) TIMESTAMP_AUTO_SET_ON_INSERT | (int) TIMESTAMP_AUTO_SET_ON_UPDATE.
 
981
  We use an enum here so that the debugger can display the value names.
 
982
*/
 
983
enum timestamp_auto_set_type
 
984
{
 
985
  TIMESTAMP_NO_AUTO_SET= 0, TIMESTAMP_AUTO_SET_ON_INSERT= 1,
 
986
  TIMESTAMP_AUTO_SET_ON_UPDATE= 2, TIMESTAMP_AUTO_SET_ON_BOTH= 3
 
987
};
 
988
#define clear_timestamp_auto_bits(_target_, _bits_) \
 
989
  (_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
 
990
 
 
991
/**
 
992
  Category of table found in the table share.
 
993
*/
 
994
enum enum_table_category
 
995
{
 
996
  /**
 
997
    Unknown value.
 
998
  */
 
999
  TABLE_UNKNOWN_CATEGORY=0,
 
1000
 
 
1001
  /**
 
1002
    Temporary table.
 
1003
    The table is visible only in the session.
 
1004
    Therefore,
 
1005
    - FLUSH TABLES WITH READ LOCK
 
1006
    - SET GLOBAL READ_ONLY = ON
 
1007
    do not apply to this table.
 
1008
    Note that LOCK Table t FOR READ/WRITE
 
1009
    can be used on temporary tables.
 
1010
    Temporary tables are not part of the table cache.
 
1011
  */
 
1012
  TABLE_CATEGORY_TEMPORARY=1,
 
1013
 
 
1014
  /**
 
1015
    User table.
 
1016
    These tables do honor:
 
1017
    - LOCK Table t FOR READ/WRITE
 
1018
    - FLUSH TABLES WITH READ LOCK
 
1019
    - SET GLOBAL READ_ONLY = ON
 
1020
    User tables are cached in the table cache.
 
1021
  */
 
1022
  TABLE_CATEGORY_USER=2,
 
1023
 
 
1024
  /**
 
1025
    Information schema tables.
 
1026
    These tables are an interface provided by the system
 
1027
    to inspect the system metadata.
 
1028
    These tables do *not* honor:
 
1029
    - LOCK Table t FOR READ/WRITE
 
1030
    - FLUSH TABLES WITH READ LOCK
 
1031
    - SET GLOBAL READ_ONLY = ON
 
1032
    as there is no point in locking explicitely
 
1033
    an INFORMATION_SCHEMA table.
 
1034
    Nothing is directly written to information schema tables.
 
1035
    Note that this value is not used currently,
 
1036
    since information schema tables are not shared,
 
1037
    but implemented as session specific temporary tables.
 
1038
  */
 
1039
  /*
 
1040
    TODO: Fixing the performance issues of I_S will lead
 
1041
    to I_S tables in the table cache, which should use
 
1042
    this table type.
 
1043
  */
 
1044
  TABLE_CATEGORY_INFORMATION
 
1045
};
 
1046
 
 
1047
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
 
1048
enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON,
 
1049
                            DELAY_KEY_WRITE_ALL };
 
1050
enum enum_slave_exec_mode { SLAVE_EXEC_MODE_STRICT,
 
1051
                            SLAVE_EXEC_MODE_IDEMPOTENT,
 
1052
                            SLAVE_EXEC_MODE_LAST_BIT};
 
1053
enum enum_mark_columns
 
1054
{ MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE};
 
1055
 
 
1056
enum enum_filetype { FILETYPE_CSV, FILETYPE_XML };
 
1057
 
 
1058
enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND,
 
1059
                                  IGNORE_ERRORS, REPORT_EXCEPT_NON_UNIQUE,
 
1060
                                  IGNORE_EXCEPT_NON_UNIQUE};
 
1061
 
 
1062
enum enum_schema_table_state
 
1063
{
 
1064
  NOT_PROCESSED= 0,
 
1065
  PROCESSED_BY_CREATE_SORT_INDEX,
 
1066
  PROCESSED_BY_JOIN_EXEC
 
1067
};
418
1068
 
419
1069
/*
420
1070
 * The following are for the interface with the .frm file
421
1071
 */
422
1072
 
 
1073
#define FIELDFLAG_DECIMAL    1
 
1074
#define FIELDFLAG_BINARY    1  // Shares same flag
 
1075
#define FIELDFLAG_NUMBER    2
 
1076
#define FIELDFLAG_DECIMAL_POSITION      4
 
1077
#define FIELDFLAG_PACK      120  // Bits used for packing
 
1078
#define FIELDFLAG_INTERVAL    256     // mangled with decimals!
 
1079
#define FIELDFLAG_BLOB      1024  // mangled with decimals!
 
1080
 
 
1081
#define FIELDFLAG_NO_DEFAULT    16384   /* sql */
 
1082
#define FIELDFLAG_SUM      ((uint32_t) 32768)// predit: +#fieldflag
 
1083
#define FIELDFLAG_MAYBE_NULL    ((uint32_t) 32768)// sql
 
1084
#define FIELDFLAG_HEX_ESCAPE    ((uint32_t) 0x10000)
423
1085
#define FIELDFLAG_PACK_SHIFT    3
 
1086
#define FIELDFLAG_DEC_SHIFT    8
424
1087
#define FIELDFLAG_MAX_DEC    31
425
1088
 
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
1089
#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 */
 
1090
 
 
1091
#define f_is_dec(x)     ((x) & FIELDFLAG_DECIMAL)
 
1092
#define f_is_num(x)     ((x) & FIELDFLAG_NUMBER)
 
1093
#define f_is_decimal_precision(x)  ((x) & FIELDFLAG_DECIMAL_POSITION)
 
1094
#define f_is_packed(x)  ((x) & FIELDFLAG_PACK)
 
1095
#define f_packtype(x)   (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
 
1096
#define f_decimals(x)   ((uint8_t) (((x) >> FIELDFLAG_DEC_SHIFT) & \
 
1097
                                     FIELDFLAG_MAX_DEC))
 
1098
#define f_is_alpha(x)   (!f_is_num(x))
 
1099
#define f_is_binary(x)  ((x) & FIELDFLAG_BINARY) // 4.0- compatibility
 
1100
#define f_is_enum(x)    (((x) & (FIELDFLAG_INTERVAL | FIELDFLAG_NUMBER)) == \
 
1101
                         FIELDFLAG_INTERVAL)
 
1102
#define f_is_blob(x)    (((x) & (FIELDFLAG_BLOB | FIELDFLAG_NUMBER)) == \
 
1103
                         FIELDFLAG_BLOB)
 
1104
#define f_is_equ(x)     ((x) & (1+2+FIELDFLAG_PACK+31*256))
 
1105
#define f_settype(x)    (((int) x) << FIELDFLAG_PACK_SHIFT)
 
1106
#define f_maybe_null(x) (x & FIELDFLAG_MAYBE_NULL)
 
1107
#define f_no_default(x) (x & FIELDFLAG_NO_DEFAULT)
 
1108
#define f_is_hex_escape(x) ((x) & FIELDFLAG_HEX_ESCAPE)
 
1109
 
 
1110
#endif /* DRIZZLE_SERVER_DEFINITIONS_H */
 
1111