~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definitions.h

  • Committer: Eric Herman
  • Date: 2008-12-07 15:29:44 UTC
  • mto: (656.1.14 devel)
  • mto: This revision was merged to the branch mainline in revision 670.
  • Revision ID: eric@mysql.com-20081207152944-cq1nx1cyi0huqj0f
Added pointer to online version of the FAQ

Show diffs side-by-side

added added

removed removed

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