~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definitions.h

Moved my_alloc.h to mysys.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
/**
21
 
 * @file
22
 
 *
23
 
 * Mostly constants and some macros/functions used by the server
24
 
 */
25
 
 
26
 
#ifndef DRIZZLE_SERVER_DEFINITIONS_H
27
 
#define DRIZZLE_SERVER_DEFINITIONS_H
28
 
 
29
 
#include <stdint.h>
30
 
 
31
 
#ifndef NO_ALARM_LOOP
32
 
#define NO_ALARM_LOOP           /* lib5 and popen can't use alarm */
33
 
#endif
34
 
 
35
 
/* These paths are converted to other systems (WIN95) before use */
36
 
 
37
 
#define LANGUAGE        "english/"
38
 
#define ERRMSG_FILE     "errmsg.sys"
39
 
#define TEMP_PREFIX     "MY"
40
 
#define LOG_PREFIX      "ML"
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 */
46
 
/* extra 4+4 bytes for slave tmp tables */
47
 
#define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
48
 
#define MAX_ALIAS_NAME 256
49
 
#define MAX_FIELD_NAME 34                       /* Max colum name length +2 */
50
 
#define MAX_SYS_VAR_LENGTH 32
51
 
#define MAX_KEY MAX_INDEXES                     /* Max used keys */
52
 
#define MAX_REF_PARTS 16                        /* Max parts used as ref */
53
 
#define MAX_KEY_LENGTH 4096                     /* max possible key */
54
 
#define MAX_KEY_LENGTH_DECIMAL_WIDTH 4          /* strlen("4096") */
55
 
#if SIZEOF_OFF_T > 4
56
 
#define MAX_REFLENGTH 8                         /* Max length for record ref */
57
 
#else
58
 
#define MAX_REFLENGTH 4                         /* Max length for record ref */
59
 
#endif
60
 
#define MAX_HOSTNAME  61                        /* len+1 in mysql.user */
61
 
 
62
 
#define MAX_MBWIDTH             4               /* Max multibyte sequence */
63
 
#define MAX_FIELD_CHARLENGTH    255
64
 
#define MAX_FIELD_VARCHARLENGTH 65535
65
 
#define CONVERT_IF_BIGGER_TO_BLOB 512           /* Used for CREATE ... SELECT */
66
 
 
67
 
/* Max column width +1 */
68
 
#define MAX_FIELD_WIDTH         (MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
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 */
74
 
#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
75
 
 
76
 
#define MAX_TABLES      (sizeof(table_map)*8-3) /* Max tables in join */
77
 
#define PARAM_TABLE_BIT (((table_map) 1) << (sizeof(table_map)*8-3))
78
 
#define OUTER_REF_TABLE_BIT     (((table_map) 1) << (sizeof(table_map)*8-2))
79
 
#define RAND_TABLE_BIT  (((table_map) 1) << (sizeof(table_map)*8-1))
80
 
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
81
 
                           RAND_TABLE_BIT)
82
 
#define MAX_FIELDS      4096                    /* Limit in the .frm file */
83
 
 
84
 
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
85
 
 
86
 
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
87
 
#define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
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
 
 
95
 
#define DEFAULT_ERROR_COUNT     64
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 */
102
 
#define NAMES_SEP_CHAR  '\377'                  /* Char to sep. names */
103
 
 
104
 
#define READ_RECORD_BUFFER      (uint32_t) (IO_SIZE*8) /* Pointer_buffer_size */
105
 
#define DISK_BUFFER_SIZE        (uint32_t) (IO_SIZE*16) /* Size of diskbuffer */
106
 
 
107
 
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
108
 
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
109
 
#define MYF_RW MYF(MY_WME+MY_NABP)              /* Vid my_read & my_write */
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
 
 
157
 
/*
158
 
  Minimum length pattern before Turbo Boyer-Moore is used
159
 
  for SELECT "text" LIKE "%pattern%", excluding the two
160
 
  wildcards in class Item_func_like.
161
 
*/
162
 
#define MIN_TURBOBM_PATTERN_LEN 3
163
 
 
164
 
/*
165
 
   Defines for binary logging.
166
 
   Do not decrease the value of BIN_LOG_HEADER_SIZE.
167
 
   Do not even increase it before checking code.
168
 
*/
169
 
 
170
 
#define BIN_LOG_HEADER_SIZE    4
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
 
 
178
 
/* Below are #defines that used to be in mysql_priv.h */
179
 
/***************************************************************************
180
 
  Configuration parameters
181
 
****************************************************************************/
182
 
#define MAX_PASSWORD_LENGTH     32
183
 
#define MAX_ACCEPT_RETRY        10      // Test accept this many times
184
 
#define MAX_FIELDS_BEFORE_HASH  32
185
 
#define USER_VARS_HASH_SIZE     16
186
 
#define TABLE_OPEN_CACHE_MIN    64
187
 
#define TABLE_OPEN_CACHE_DEFAULT 1024
188
 
 
189
 
/*
190
 
 Value of 9236 discovered through binary search 2006-09-26 on Ubuntu Dapper
191
 
 Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added
192
 
 100 bytes as reasonable buffer against growth and other environments'
193
 
 requirements.)
194
 
 
195
 
 Feel free to raise this by the smallest amount you can to get the
196
 
 "execution_constants" test to pass.
197
 
 */
198
 
#define STACK_MIN_SIZE          12000   ///< Abort if less stack during eval.
199
 
 
200
 
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
201
 
#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
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
 
 
213
 
#define QUERY_ALLOC_BLOCK_SIZE          8192
214
 
#define QUERY_ALLOC_PREALLOC_SIZE       8192
215
 
#define TRANS_ALLOC_BLOCK_SIZE          4096
216
 
#define TRANS_ALLOC_PREALLOC_SIZE       4096
217
 
#define RANGE_ALLOC_BLOCK_SIZE          4096
218
 
#define UDF_ALLOC_BLOCK_SIZE            1024
219
 
#define TABLE_ALLOC_BLOCK_SIZE          1024
220
 
#define WARN_ALLOC_BLOCK_SIZE           2048
221
 
#define WARN_ALLOC_PREALLOC_SIZE        1024
222
 
#define PROFILE_ALLOC_BLOCK_SIZE  2048
223
 
#define PROFILE_ALLOC_PREALLOC_SIZE 1024
224
 
 
225
 
/*
226
 
  The following parameters is to decide when to use an extra cache to
227
 
  optimise seeks when reading a big table in sorted order
228
 
*/
229
 
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
230
 
#define MIN_ROWS_TO_USE_TABLE_CACHE      100
231
 
#define MIN_ROWS_TO_USE_BULK_INSERT      100
232
 
 
233
 
/**
234
 
  The following is used to decide if MySQL should use table scanning
235
 
  instead of reading with keys.  The number says how many evaluation of the
236
 
  WHERE clause is comparable to reading one extra row from a table.
237
 
*/
238
 
#define TIME_FOR_COMPARE   5    // 5 compares == one read
239
 
 
240
 
/**
241
 
  Number of comparisons of table rowids equivalent to reading one row from a
242
 
  table.
243
 
*/
244
 
#define TIME_FOR_COMPARE_ROWID  (TIME_FOR_COMPARE*2)
245
 
 
246
 
/*
247
 
  For sequential disk seeks the cost formula is:
248
 
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip
249
 
 
250
 
  The cost of average seek
251
 
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
252
 
*/
253
 
#define DISK_SEEK_BASE_COST ((double)0.9)
254
 
 
255
 
#define BLOCKS_IN_AVG_SEEK  128
256
 
 
257
 
#define DISK_SEEK_PROP_COST ((double)0.1/BLOCKS_IN_AVG_SEEK)
258
 
 
259
 
 
260
 
/**
261
 
  Number of rows in a reference table when refereed through a not unique key.
262
 
  This value is only used when we don't know anything about the key
263
 
  distribution.
264
 
*/
265
 
#define MATCHING_ROWS_IN_OTHER_TABLE 10
266
 
 
267
 
/** Don't pack string keys shorter than this (if PACK_KEYS=1 isn't used). */
268
 
#define KEY_DEFAULT_PACK_LENGTH 8
269
 
 
270
 
/** Characters shown for the command in 'show processlist'. */
271
 
#define PROCESS_LIST_WIDTH 100
272
 
/* Characters shown for the command in 'information_schema.processlist' */
273
 
#define PROCESS_LIST_INFO_WIDTH 65535
274
 
 
275
 
#define PRECISION_FOR_DOUBLE 53
276
 
#define PRECISION_FOR_FLOAT  24
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
 
 
284
 
/* The following can also be changed from the command line */
285
 
#define DEFAULT_CONCURRENCY     10
286
 
#define FLUSH_TIME              0               /**< Don't flush tables */
287
 
#define MAX_CONNECT_ERRORS      10              ///< errors before disabling host
288
 
 
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 */
305
 
 
306
 
/* Bits for different SQL modes modes (including ANSI mode) */
307
 
#define MODE_NO_ZERO_DATE               (2)
308
 
#define MODE_INVALID_DATES              (MODE_NO_ZERO_DATE*2)
309
 
 
310
 
/* @@optimizer_switch flags */
311
 
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
312
 
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
313
 
 
314
 
#define MY_CHARSET_BIN_MB_MAXLEN 1
315
 
 
316
 
// uncachable cause
317
 
#define UNCACHEABLE_DEPENDENT   1
318
 
#define UNCACHEABLE_RAND        2
319
 
#define UNCACHEABLE_SIDEEFFECT  4
320
 
/// forcing to save JOIN for explain
321
 
#define UNCACHEABLE_EXPLAIN     8
322
 
/** Don't evaluate subqueries in prepare even if they're not correlated */
323
 
#define UNCACHEABLE_PREPARE    16
324
 
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
325
 
#define UNCACHEABLE_UNITED     32
326
 
 
327
 
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
328
 
#define UNDEF_POS (-1)
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
 
 
338
 
/* Options to add_table_to_list() */
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
343
 
 
344
 
/* Some portable defines */
345
 
 
346
 
#define portable_sizeof_char_ptr 8
347
 
 
348
 
#define TMP_FILE_PREFIX "#sql"                  /**< Prefix for tmp tables */
349
 
#define TMP_FILE_PREFIX_LENGTH 4
350
 
 
351
 
/* Flags for calc_week() function.  */
352
 
#define WEEK_MONDAY_FIRST    1
353
 
#define WEEK_YEAR            2
354
 
#define WEEK_FIRST_WEEKDAY   4
355
 
 
356
 
/* used in date and time conversions */
357
 
/* Daynumber from year 0 to 9999-12-31 */
358
 
#define MAX_DAY_NUMBER 3652424L
359
 
 
360
 
#define STRING_BUFFER_USUAL_SIZE 80
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;
469
 
typedef void *range_seq_t;
470
 
 
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
 
 
489
 
// the following is for checking tables
490
 
 
491
 
#define HA_ADMIN_ALREADY_DONE     1
492
 
#define HA_ADMIN_OK               0
493
 
#define HA_ADMIN_NOT_IMPLEMENTED -1
494
 
#define HA_ADMIN_FAILED          -2
495
 
#define HA_ADMIN_CORRUPT         -3
496
 
#define HA_ADMIN_INTERNAL_ERROR  -4
497
 
#define HA_ADMIN_INVALID         -5
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)
624
 
 
625
 
/* bits in index_flags(index_number) for what you can do with index */
626
 
#define HA_READ_NEXT            1       /* TODO really use this flag */
627
 
#define HA_READ_PREV            2       /* supports ::index_prev */
628
 
#define HA_READ_ORDER           4       /* index_next/prev follow sort order */
629
 
#define HA_READ_RANGE           8       /* can find all records in a range */
630
 
#define HA_ONLY_WHOLE_INDEX     16      /* Can't use part key searches */
631
 
#define HA_KEYREAD_ONLY         64      /* Support HA_EXTRA_KEYREAD */
632
 
/*
633
 
  Index scan will not return records in rowid order. Not guaranteed to be
634
 
  set for unordered (e.g. HASH) indexes.
635
 
*/
636
 
#define HA_KEY_SCAN_NOT_ROR     128
637
 
#define HA_DO_INDEX_COND_PUSHDOWN  256 /* Supports Index Condition Pushdown */
638
 
 
639
 
/* operations for disable/enable indexes */
640
 
#define HA_KEY_SWITCH_NONUNIQ      0
641
 
#define HA_KEY_SWITCH_ALL          1
642
 
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
643
 
#define HA_KEY_SWITCH_ALL_SAVE     3
644
 
 
645
 
/*
646
 
  Note: the following includes binlog and closing 0.
647
 
  so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
648
 
      example + csv + heap + blackhole + federated + 0
649
 
  (yes, the sum is deliberately inaccurate)
650
 
  TODO remove the limit, use dynarrays
651
 
*/
652
 
#define MAX_HA 15
653
 
 
654
 
/*
655
 
  Parameters for open() (in register form->filestat)
656
 
  HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
657
 
*/
658
 
 
659
 
#define HA_OPEN_KEYFILE         1
660
 
#define HA_OPEN_RNDFILE         2
661
 
#define HA_GET_INDEX            4
662
 
#define HA_GET_INFO             8       /* do a ha_info() after open */
663
 
#define HA_READ_ONLY            16      /* File opened as readonly */
664
 
/* Try readonly if can't open with read and write */
665
 
#define HA_TRY_READ_ONLY        32
666
 
#define HA_WAIT_IF_LOCKED       64      /* Wait if locked on open */
667
 
#define HA_ABORT_IF_LOCKED      128     /* skip if locked on open.*/
668
 
#define HA_BLOCK_LOCK           256     /* unlock when reading some records */
669
 
#define HA_OPEN_TEMPORARY       512
670
 
 
671
 
/* For transactional LOCK Table. handler::lock_table() */
672
 
#define HA_LOCK_IN_SHARE_MODE      F_RDLCK
673
 
#define HA_LOCK_IN_EXCLUSIVE_MODE  F_WRLCK
674
 
 
675
 
/* Some key definitions */
676
 
#define HA_KEY_NULL_LENGTH      1
677
 
#define HA_KEY_BLOB_LENGTH      2
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)
684
 
#define HA_MAX_REC_LENGTH       65535
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
 
 
692
 
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
693
 
#define DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
694
 
 
695
 
/* Flags for method is_fatal_error */
696
 
#define HA_CHECK_DUP_KEY 1
697
 
#define HA_CHECK_DUP_UNIQUE 2
698
 
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
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 */
735
 
 
736
 
/* Bits in used_fields */
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)
747
 
#define HA_CREATE_USED_CHARSET          (1L << 8)
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)
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 };
771
 
 
772
 
/*
773
 
  The below two are not used (and not handled) in this milestone of this WL
774
 
  entry because there seems to be no use for them at this stage of
775
 
  implementation.
776
 
*/
777
 
#define HA_MRR_SINGLE_POINT 1
778
 
#define HA_MRR_FIXED_KEY  2
779
 
 
780
 
/*
781
 
  Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
782
 
  'range' parameter.
783
 
*/
784
 
#define HA_MRR_NO_ASSOCIATION 4
785
 
 
786
 
/*
787
 
  The MRR user will provide ranges in key order, and MRR implementation
788
 
  must return rows in key order.
789
 
*/
790
 
#define HA_MRR_SORTED 8
791
 
 
792
 
/* MRR implementation doesn't have to retrieve full records */
793
 
#define HA_MRR_INDEX_ONLY 16
794
 
 
795
 
/*
796
 
  The passed memory buffer is of maximum possible size, the caller can't
797
 
  assume larger buffer.
798
 
*/
799
 
#define HA_MRR_LIMITS 32
800
 
 
801
 
 
802
 
/*
803
 
  Flag set <=> default MRR implementation is used
804
 
  (The choice is made by **_info[_const]() function which may set this
805
 
   flag. SQL layer remembers the flag value and then passes it to
806
 
   multi_read_range_init().
807
 
*/
808
 
#define HA_MRR_USE_DEFAULT_IMPL 64
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
 
 
825
 
typedef int myf;
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
915
 
 
916
 
/*
917
 
   "Declared Type Collation"
918
 
   A combination of collation and its derivation.
919
 
 
920
 
  Flags for collation aggregation modes:
921
 
  MY_COLL_ALLOW_SUPERSET_CONV  - allow conversion to a superset
922
 
  MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
923
 
                                 (i.e. constant).
924
 
  MY_COLL_ALLOW_CONV           - allow any kind of conversion
925
 
                                 (combination of the above two)
926
 
  MY_COLL_DISALLOW_NONE        - don't allow return DERIVATION_NONE
927
 
                                 (e.g. when aggregating for comparison)
928
 
  MY_COLL_CMP_CONV             - combination of MY_COLL_ALLOW_CONV
929
 
                                 and MY_COLL_DISALLOW_NONE
930
 
*/
931
 
 
932
 
#define MY_COLL_ALLOW_SUPERSET_CONV   1
933
 
#define MY_COLL_ALLOW_COERCIBLE_CONV  2
934
 
#define MY_COLL_ALLOW_CONV            3
935
 
#define MY_COLL_DISALLOW_NONE         4
936
 
#define MY_COLL_CMP_CONV              7
937
 
 
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
 
/* Information for one open table */
1048
 
enum index_hint_type
1049
 
{
1050
 
  INDEX_HINT_IGNORE,
1051
 
  INDEX_HINT_USE,
1052
 
  INDEX_HINT_FORCE
1053
 
};
1054
 
 
1055
 
 
1056
 
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
1057
 
enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON,
1058
 
                            DELAY_KEY_WRITE_ALL };
1059
 
enum enum_slave_exec_mode { SLAVE_EXEC_MODE_STRICT,
1060
 
                            SLAVE_EXEC_MODE_IDEMPOTENT,
1061
 
                            SLAVE_EXEC_MODE_LAST_BIT};
1062
 
enum enum_mark_columns
1063
 
{ MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE};
1064
 
 
1065
 
enum enum_filetype { FILETYPE_CSV, FILETYPE_XML };
1066
 
 
1067
 
enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND,
1068
 
                                  IGNORE_ERRORS, REPORT_EXCEPT_NON_UNIQUE,
1069
 
                                  IGNORE_EXCEPT_NON_UNIQUE};
1070
 
 
1071
 
enum enum_schema_table_state
1072
 
{
1073
 
  NOT_PROCESSED= 0,
1074
 
  PROCESSED_BY_CREATE_SORT_INDEX,
1075
 
  PROCESSED_BY_JOIN_EXEC
1076
 
};
1077
 
 
1078
 
/*
1079
 
 * The following are for the interface with the .frm file
1080
 
 */
1081
 
 
1082
 
#define FIELDFLAG_DECIMAL    1
1083
 
#define FIELDFLAG_BINARY    1  // Shares same flag
1084
 
#define FIELDFLAG_NUMBER    2
1085
 
#define FIELDFLAG_DECIMAL_POSITION      4
1086
 
#define FIELDFLAG_PACK      120  // Bits used for packing
1087
 
#define FIELDFLAG_INTERVAL    256     // mangled with decimals!
1088
 
#define FIELDFLAG_BLOB      1024  // mangled with decimals!
1089
 
 
1090
 
#define FIELDFLAG_NO_DEFAULT    16384   /* sql */
1091
 
#define FIELDFLAG_SUM      ((uint32_t) 32768)// predit: +#fieldflag
1092
 
#define FIELDFLAG_MAYBE_NULL    ((uint32_t) 32768)// sql
1093
 
#define FIELDFLAG_HEX_ESCAPE    ((uint32_t) 0x10000)
1094
 
#define FIELDFLAG_PACK_SHIFT    3
1095
 
#define FIELDFLAG_DEC_SHIFT    8
1096
 
#define FIELDFLAG_MAX_DEC    31
1097
 
 
1098
 
#define MTYP_TYPENR(type) (type & 127)  /* Remove bits from type */
1099
 
 
1100
 
#define f_is_dec(x)     ((x) & FIELDFLAG_DECIMAL)
1101
 
#define f_is_num(x)     ((x) & FIELDFLAG_NUMBER)
1102
 
#define f_is_decimal_precision(x)  ((x) & FIELDFLAG_DECIMAL_POSITION)
1103
 
#define f_is_packed(x)  ((x) & FIELDFLAG_PACK)
1104
 
#define f_packtype(x)   (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
1105
 
#define f_decimals(x)   ((uint8_t) (((x) >> FIELDFLAG_DEC_SHIFT) & \
1106
 
                                     FIELDFLAG_MAX_DEC))
1107
 
#define f_is_alpha(x)   (!f_is_num(x))
1108
 
#define f_is_binary(x)  ((x) & FIELDFLAG_BINARY) // 4.0- compatibility
1109
 
#define f_is_enum(x)    (((x) & (FIELDFLAG_INTERVAL | FIELDFLAG_NUMBER)) == \
1110
 
                         FIELDFLAG_INTERVAL)
1111
 
#define f_is_blob(x)    (((x) & (FIELDFLAG_BLOB | FIELDFLAG_NUMBER)) == \
1112
 
                         FIELDFLAG_BLOB)
1113
 
#define f_is_equ(x)     ((x) & (1+2+FIELDFLAG_PACK+31*256))
1114
 
#define f_settype(x)    (((int) x) << FIELDFLAG_PACK_SHIFT)
1115
 
#define f_maybe_null(x) (x & FIELDFLAG_MAYBE_NULL)
1116
 
#define f_no_default(x) (x & FIELDFLAG_NO_DEFAULT)
1117
 
#define f_is_hex_escape(x) ((x) & FIELDFLAG_HEX_ESCAPE)
1118
 
 
1119
 
#endif /* DRIZZLE_SERVER_DEFINITIONS_H */
1120