~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definitions.h

  • Committer: Brian Aker
  • Date: 2009-10-01 22:56:26 UTC
  • mto: (1154.1.1 staging)
  • mto: This revision was merged to the branch mainline in revision 1155.
  • Revision ID: brian@gaz-20091001225626-sb1pdykpxlnkheaj
Remove Factory/make scheduler work like everything else.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2006 MySQL AB
2
 
 
3
 
   This program is free software; you can redistribute it and/or modify
4
 
   it under the terms of the GNU General Public License as published by
5
 
   the Free Software Foundation; version 2 of the License.
6
 
 
7
 
   This program is distributed in the hope that it will be useful,
8
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 
   GNU General Public License for more details.
11
 
 
12
 
   You should have received a copy of the GNU General Public License
13
 
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
 
 
 
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
 */
16
19
 
17
20
/**
18
21
 * @file
19
22
 *
20
 
 * Mostly constants and some macros/functions used by the server  
 
23
 * Mostly constants and some macros/functions used by the server
21
24
 */
22
25
 
23
 
#ifndef DRIZZLE_SERVER_DEFINITIONS_H
24
 
#define DRIZZLE_SERVER_DEFINITIONS_H
25
 
 
26
 
#ifndef NO_ALARM_LOOP
27
 
#define NO_ALARM_LOOP           /* lib5 and popen can't use alarm */
28
 
#endif
 
26
#ifndef DRIZZLED_DEFINITIONS_H
 
27
#define DRIZZLED_DEFINITIONS_H
 
28
 
 
29
#include <drizzled/enum.h>
 
30
 
 
31
#include <stdint.h>
29
32
 
30
33
/* These paths are converted to other systems (WIN95) before use */
31
34
 
32
35
#define LANGUAGE        "english/"
33
 
#define ERRMSG_FILE     "errmsg.sys"
34
36
#define TEMP_PREFIX     "MY"
35
37
#define LOG_PREFIX      "ML"
36
38
#define PROGDIR         "bin/"
37
 
#ifndef DATADIR
38
 
#define DATADIR         "data/"
39
 
#endif
40
 
#ifndef SHAREDIR
41
 
#define SHAREDIR        "share/"
42
 
#endif
43
 
#ifndef PLUGINDIR
44
 
#define PLUGINDIR       "lib/plugin"
45
 
#endif
46
 
 
47
 
#define ER(X) _(drizzled_error_messages[(X) - ER_ERROR_FIRST])
48
 
#define ER_SAFE(X) (((X) >= ER_ERROR_FIRST && (X) <= ER_ERROR_LAST) ? ER(X) : _("Invalid error code"))
49
 
 
50
 
#define ERRMAPP 1                               /* Errormap f|r my_error */
 
39
 
 
40
#define ER(X) error_message((X))
 
41
 
51
42
#define LIBLEN FN_REFLEN-FN_LEN                 /* Max l{ngd p} dev */
52
43
/* extra 4+4 bytes for slave tmp tables */
53
44
#define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
73
64
/* Max column width +1 */
74
65
#define MAX_FIELD_WIDTH         (MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
75
66
 
76
 
#define MAX_BIT_FIELD_LENGTH    64      /* Max length in bits for bit fields */
77
 
 
78
 
#define MAX_DATE_WIDTH          10      /* YYYY-MM-DD */
79
 
#define MAX_TIME_WIDTH          23      /* -DDDDDD HH:MM:SS.###### */
80
 
#define MAX_DATETIME_FULL_WIDTH 29      /* YYYY-MM-DD HH:MM:SS.###### AM */
81
 
#define MAX_DATETIME_WIDTH      19      /* YYYY-MM-DD HH:MM:SS */
82
67
#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
83
68
 
84
69
#define MAX_TABLES      (sizeof(table_map)*8-3) /* Max tables in join */
103
88
#define DEFAULT_ERROR_COUNT     64
104
89
#define EXTRA_RECORDS   10                      /* Extra records in sort */
105
90
#define SCROLL_EXTRA    5                       /* Extra scroll-rows. */
106
 
#define FIELD_NAME_USED ((uint) 32768)          /* Bit set if fieldname used */
107
 
#define FORM_NAME_USED  ((uint) 16384)          /* Bit set if formname used */
 
91
#define FIELD_NAME_USED ((uint32_t) 32768)              /* Bit set if fieldname used */
108
92
#define FIELD_NR_MASK   16383                   /* To get fieldnumber */
109
93
#define FERR            -1                      /* Error from my_functions */
110
94
#define CREATE_MODE     0                       /* Default mode on new files */
111
95
#define NAMES_SEP_CHAR  '\377'                  /* Char to sep. names */
112
96
 
113
 
#define READ_RECORD_BUFFER      (uint) (IO_SIZE*8) /* Pointer_buffer_size */
114
 
#define DISK_BUFFER_SIZE        (uint) (IO_SIZE*16) /* Size of diskbuffer */
 
97
#define READ_RECORD_BUFFER      (uint32_t) (IO_SIZE*8) /* Pointer_buffer_size */
 
98
#define DISK_BUFFER_SIZE        (uint32_t) (IO_SIZE*16) /* Size of diskbuffer */
115
99
 
116
100
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
117
101
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
118
102
#define MYF_RW MYF(MY_WME+MY_NABP)              /* Vid my_read & my_write */
119
103
 
120
 
#define SPECIAL_USE_LOCKS       1               /* Lock used databases */
121
 
#define SPECIAL_NO_NEW_FUNC     2               /* Skip new functions */
122
 
#define SPECIAL_SKIP_SHOW_DB    4               /* Don't allow 'show db' */
123
 
#define SPECIAL_WAIT_IF_LOCKED  8               /* Wait if locked database */
124
 
#define SPECIAL_SAME_DB_NAME   16               /* form name = file name */
125
 
#define SPECIAL_ENGLISH        32               /* English error messages */
126
 
#define SPECIAL_NO_RESOLVE     64               /* Don't use gethostname */
127
 
#define SPECIAL_NO_PRIOR        128             /* Don't prioritize threads */
128
 
#define SPECIAL_BIG_SELECTS     256             /* Don't use heap tables */
129
 
#define SPECIAL_NO_HOST_CACHE   512             /* Don't cache hosts */
130
 
#define SPECIAL_SHORT_LOG_FORMAT 1024
131
 
#define SPECIAL_SAFE_MODE       2048
132
 
#define SPECIAL_LOG_QUERIES_NOT_USING_INDEXES 4096 /* Obsolete */
133
 
 
134
 
        /* Extern defines */
135
 
#define store_record(A,B) memcpy((A)->B,(A)->record[0],(size_t) (A)->s->reclength)
136
 
#define restore_record(A,B) memcpy((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
137
 
#define cmp_record(A,B) memcmp((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
138
 
#define empty_record(A)                                 \
139
 
  do {                                                  \
140
 
    restore_record((A),s->default_values);              \
141
 
    memset((A)->null_flags, 255, (A)->s->null_bytes);   \
142
 
  } while (0)
143
 
 
144
104
        /* Defines for use with openfrm, openprt and openfrd */
145
105
 
146
106
#define READ_ALL                1       /* openfrm: Read all parameters */
147
107
#define CHANGE_FRM              2       /* openfrm: open .frm as O_RDWR */
148
 
#define READ_KEYINFO            4       /* L{s nyckeldata fr}n filen */
149
108
#define EXTRA_RECORD            8       /* Reservera plats f|r extra record */
150
 
#define DONT_OPEN_TABLES        8       /* Don't open database-files (frd) */
151
 
#define DONT_OPEN_MASTER_REG    16      /* Don't open first reg-file (prt) */
152
 
#define EXTRA_LONG_RECORD       16      /* Plats f|r dubbel s|k-record */
153
 
#define COMPUTE_TYPES           32      /* Kontrollera type f|r f{ltena */
154
 
#define SEARCH_PRG              64      /* S|k efter registret i 'prg_dev' */
155
 
#define READ_USED_NAMES         128     /* L{s anv{nda formul{rnamn */
156
109
#define DONT_GIVE_ERROR         256     /* Don't do frm_error on openfrm  */
157
 
#define READ_SCREENS            1024    /* Read screens, info and helpfile */
158
110
#define DELAYED_OPEN            4096    /* Open table later */
159
 
#define OPEN_VIEW               8192    /* Allow open on view */
160
 
#define OPEN_VIEW_NO_PARSE     16384    /* Open frm only if it's a view,
161
 
                                           but do not parse view itself */
162
111
/**
163
112
  This flag is used in function get_all_tables() which fills
164
113
  I_S tables with data which are retrieved from frm files and storage engine
174
123
#define OPEN_TABLE_ONLY        OPEN_FRM_FILE_ONLY*2
175
124
/**
176
125
  This flag is used in function get_all_tables() which fills
177
 
  I_S tables with data which are retrieved from frm files and storage engine
178
 
  The flag means that we need to process views only to get necessary data.
179
 
  Tables are not processed.
180
 
*/
181
 
#define OPEN_VIEW_ONLY         OPEN_TABLE_ONLY*2
182
 
/**
183
 
  This flag is used in function get_all_tables() which fills
184
 
  I_S tables with data which are retrieved from frm files and storage engine.
185
 
  The flag means that we need to open a view using
186
 
  open_normal_and_derived_tables() function.
187
 
*/
188
 
#define OPEN_VIEW_FULL         OPEN_VIEW_ONLY*2
189
 
/**
190
 
  This flag is used in function get_all_tables() which fills
191
126
  I_S tables with data which are retrieved from frm files and storage engine.
192
127
  The flag means that I_S table uses optimization algorithm.
193
128
*/
194
 
#define OPTIMIZE_I_S_TABLE     OPEN_VIEW_FULL*2
195
 
 
196
 
#define SC_INFO_LENGTH 4                /* Form format constant */
197
 
#define TE_INFO_LENGTH 3
198
 
#define MTYP_NOEMPTY_BIT 128
199
 
 
200
 
#define FRM_VER_TRUE_VARCHAR (FRM_VER+4) /* 10 */
201
 
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_CGE 50120
202
 
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM 50205
203
 
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_STR "50205"
 
129
#define OPTIMIZE_I_S_TABLE     OPEN_TABLE_ONLY*2
204
130
 
205
131
/*
206
132
  Minimum length pattern before Turbo Boyer-Moore is used
209
135
*/
210
136
#define MIN_TURBOBM_PATTERN_LEN 3
211
137
 
212
 
/* 
 
138
/*
213
139
   Defines for binary logging.
214
140
   Do not decrease the value of BIN_LOG_HEADER_SIZE.
215
141
   Do not even increase it before checking code.
216
142
*/
217
143
 
218
 
#define BIN_LOG_HEADER_SIZE    4 
 
144
#define BIN_LOG_HEADER_SIZE    4
219
145
 
220
146
#define DEFAULT_KEY_CACHE_NAME "default"
221
147
 
227
153
/***************************************************************************
228
154
  Configuration parameters
229
155
****************************************************************************/
230
 
#define ACL_CACHE_SIZE          256
231
156
#define MAX_PASSWORD_LENGTH     32
232
 
#define HOST_CACHE_SIZE         128
233
157
#define MAX_ACCEPT_RETRY        10      // Test accept this many times
234
158
#define MAX_FIELDS_BEFORE_HASH  32
235
159
#define USER_VARS_HASH_SIZE     16
236
160
#define TABLE_OPEN_CACHE_MIN    64
237
 
#define TABLE_OPEN_CACHE_DEFAULT 64
 
161
#define TABLE_OPEN_CACHE_DEFAULT 1024
238
162
 
239
 
/* 
 
163
/*
240
164
 Value of 9236 discovered through binary search 2006-09-26 on Ubuntu Dapper
241
 
 Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added 
 
165
 Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added
242
166
 100 bytes as reasonable buffer against growth and other environments'
243
167
 requirements.)
244
168
 
250
174
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
251
175
#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
252
176
 
253
 
/** 
254
 
 * @TODO Move into a drizzled.h since it's only used in drizzled.cc
255
 
 *
256
 
 * @TODO Rename to DRIZZLED_NET_RETRY_COUNT
257
 
 */
258
 
#ifndef MYSQLD_NET_RETRY_COUNT
259
 
#define MYSQLD_NET_RETRY_COUNT  10      ///< Abort read after this many int.
260
 
#endif
261
177
#define TEMP_POOL_SIZE          128
262
178
 
263
179
#define QUERY_ALLOC_BLOCK_SIZE          8192
265
181
#define TRANS_ALLOC_BLOCK_SIZE          4096
266
182
#define TRANS_ALLOC_PREALLOC_SIZE       4096
267
183
#define RANGE_ALLOC_BLOCK_SIZE          4096
268
 
#define ACL_ALLOC_BLOCK_SIZE            1024
269
184
#define UDF_ALLOC_BLOCK_SIZE            1024
270
185
#define TABLE_ALLOC_BLOCK_SIZE          1024
271
 
#define BDB_LOG_ALLOC_BLOCK_SIZE        1024
272
186
#define WARN_ALLOC_BLOCK_SIZE           2048
273
187
#define WARN_ALLOC_PREALLOC_SIZE        1024
274
188
#define PROFILE_ALLOC_BLOCK_SIZE  2048
290
204
#define TIME_FOR_COMPARE   5    // 5 compares == one read
291
205
 
292
206
/**
293
 
  Number of comparisons of table rowids equivalent to reading one row from a 
 
207
  Number of comparisons of table rowids equivalent to reading one row from a
294
208
  table.
295
209
*/
296
210
#define TIME_FOR_COMPARE_ROWID  (TIME_FOR_COMPARE*2)
297
211
 
298
212
/*
299
213
  For sequential disk seeks the cost formula is:
300
 
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip  
301
 
  
302
 
  The cost of average seek 
 
214
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip
 
215
 
 
216
  The cost of average seek
303
217
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
304
218
*/
305
219
#define DISK_SEEK_BASE_COST ((double)0.9)
327
241
#define PRECISION_FOR_DOUBLE 53
328
242
#define PRECISION_FOR_FLOAT  24
329
243
 
330
 
/*
331
 
  Default time to wait before aborting a new client connection
332
 
  that does not respond to "initial server greeting" timely
333
 
*/
334
 
#define CONNECT_TIMEOUT         10
335
 
 
336
244
/* The following can also be changed from the command line */
337
245
#define DEFAULT_CONCURRENCY     10
338
246
#define FLUSH_TIME              0               /**< Don't flush tables */
343
251
#define WAIT_PRIOR      8
344
252
#define QUERY_PRIOR     6
345
253
 
346
 
        /* Bits from testflag */
347
 
#define TEST_PRINT_CACHED_TABLES 1
348
 
#define TEST_NO_KEY_GROUP        2
349
 
#define TEST_MIT_THREAD         4
350
 
#define TEST_BLOCKING           8
351
 
#define TEST_KEEP_TMP_TABLES    16
352
 
#define TEST_READCHECK          64      /**< Force use of readcheck */
353
 
#define TEST_NO_EXTRA           128
354
 
#define TEST_CORE_ON_SIGNAL     256     /**< Give core if signal */
355
 
#define TEST_NO_STACKTRACE      512
356
 
#define TEST_SIGINT             1024    /**< Allow sigint on threads */
357
 
#define TEST_SYNCHRONIZATION    2048    /**< get server to do sleep in some places */
358
 
#endif /* End ifndef DRIZZLE_CLIENT */
359
 
 
360
 
/* The rest of the file is included in the server only */
361
 
#ifndef DRIZZLE_CLIENT
 
254
/* Bits from testflag */
 
255
enum test_flag_bit
 
256
{
 
257
  TEST_PRINT_CACHED_TABLES= 1,
 
258
  TEST_NO_KEY_GROUP,
 
259
  TEST_MIT_THREAD,
 
260
  TEST_KEEP_TMP_TABLES,
 
261
  TEST_READCHECK, /**< Force use of readcheck */
 
262
  TEST_NO_EXTRA,
 
263
  TEST_CORE_ON_SIGNAL, /**< Give core if signal */
 
264
  TEST_NO_STACKTRACE,
 
265
  TEST_SIGINT, /**< Allow sigint on threads */
 
266
  TEST_SYNCHRONIZATION /**< get server to do sleep in some places */
 
267
};
362
268
 
363
269
/* Bits for different SQL modes modes (including ANSI mode) */
364
 
#define MODE_REAL_AS_FLOAT              1
365
 
#define MODE_PIPES_AS_CONCAT            2
366
 
#define MODE_ANSI_QUOTES                4
367
 
#define MODE_IGNORE_SPACE               8
368
 
#define MODE_NOT_USED                   16
369
 
#define MODE_ONLY_FULL_GROUP_BY         32
370
 
#define MODE_NO_UNSIGNED_SUBTRACTION    64
371
 
#define MODE_NO_DIR_IN_CREATE           128
372
 
#define MODE_POSTGRESQL                 256
373
 
#define MODE_ORACLE                     512
374
 
#define MODE_MSSQL                      1024
375
 
#define MODE_DB2                        2048
376
 
#define MODE_MAXDB                      4096
377
 
#define MODE_NO_KEY_OPTIONS             8192
378
 
#define MODE_NO_TABLE_OPTIONS           16384
379
 
#define MODE_NO_FIELD_OPTIONS           32768
380
 
#define MODE_MYSQL323                   65536L
381
 
#define MODE_MYSQL40                    (MODE_MYSQL323*2)
382
 
#define MODE_ANSI                       (MODE_MYSQL40*2)
383
 
#define MODE_NO_AUTO_VALUE_ON_ZERO      (MODE_ANSI*2)
384
 
#define MODE_NO_BACKSLASH_ESCAPES       (MODE_NO_AUTO_VALUE_ON_ZERO*2)
385
 
#define MODE_STRICT_TRANS_TABLES        (MODE_NO_BACKSLASH_ESCAPES*2)
386
 
#define MODE_STRICT_ALL_TABLES          (MODE_STRICT_TRANS_TABLES*2)
387
 
#define MODE_NO_ZERO_IN_DATE            (MODE_STRICT_ALL_TABLES*2)
388
 
#define MODE_NO_ZERO_DATE               (MODE_NO_ZERO_IN_DATE*2)
 
270
#define MODE_NO_ZERO_DATE               (2)
389
271
#define MODE_INVALID_DATES              (MODE_NO_ZERO_DATE*2)
390
 
#define MODE_ERROR_FOR_DIVISION_BY_ZERO (MODE_INVALID_DATES*2)
391
 
#define MODE_TRADITIONAL                (MODE_ERROR_FOR_DIVISION_BY_ZERO*2)
392
 
#define MODE_NO_AUTO_CREATE_USER        (MODE_TRADITIONAL*2)
393
 
#define MODE_HIGH_NOT_PRECEDENCE        (MODE_NO_AUTO_CREATE_USER*2)
394
 
#define MODE_NO_ENGINE_SUBSTITUTION     (MODE_HIGH_NOT_PRECEDENCE*2)
395
 
#define MODE_PAD_CHAR_TO_FULL_LENGTH    (1ULL << 31)
396
272
 
397
273
/* @@optimizer_switch flags */
398
274
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
399
275
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
400
276
 
401
 
/*
402
 
  Replication uses 8 bytes to store SQL_MODE in the binary log. The day you
403
 
  use strictly more than 64 bits by adding one more define above, you should
404
 
  contact the replication team because the replication code should then be
405
 
  updated (to store more bytes on disk).
406
 
 
407
 
  NOTE: When adding new SQL_MODE types, make sure to also add them to
408
 
  the scripts used for creating the MySQL system tables
409
 
  in scripts/mysql_system_tables.sql and scripts/mysql_system_tables_fix.sql
410
 
 
411
 
*/
412
 
#define RAID_BLOCK_SIZE 1024
413
 
 
414
277
#define MY_CHARSET_BIN_MB_MAXLEN 1
415
278
 
416
279
// uncachable cause
427
290
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
428
291
#define UNDEF_POS (-1)
429
292
 
430
 
/* BINLOG_DUMP options */
431
 
 
432
 
#define BINLOG_DUMP_NON_BLOCK   1
433
 
 
434
293
/* sql_show.cc:show_log_files() */
435
294
#define SHOW_LOG_STATUS_FREE "FREE"
436
295
#define SHOW_LOG_STATUS_INUSE "IN USE"
445
304
 
446
305
#define portable_sizeof_char_ptr 8
447
306
 
448
 
#define tmp_file_prefix "#sql"                  /**< Prefix for tmp tables */
449
 
#define tmp_file_prefix_length 4
 
307
#define TMP_FILE_PREFIX "#sql"                  /**< Prefix for tmp tables */
 
308
#define TMP_FILE_PREFIX_LENGTH 4
450
309
 
451
310
/* Flags for calc_week() function.  */
452
311
#define WEEK_MONDAY_FIRST    1
453
312
#define WEEK_YEAR            2
454
313
#define WEEK_FIRST_WEEKDAY   4
455
314
 
 
315
/* used in date and time conversions */
 
316
/* Daynumber from year 0 to 9999-12-31 */
 
317
#define MAX_DAY_NUMBER 3652424L
 
318
 
456
319
#define STRING_BUFFER_USUAL_SIZE 80
457
320
 
458
321
/*
463
326
#define IS_EQUAL_PACK_LENGTH 2
464
327
 
465
328
 
466
 
#endif /* DRIZZLE_SERVER_DEFINITIONS_H */
 
329
typedef uint64_t query_id_t;
 
330
typedef void *range_seq_t;
 
331
 
 
332
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
 
333
// the following is for checking tables
 
334
 
 
335
#define HA_ADMIN_ALREADY_DONE     1
 
336
#define HA_ADMIN_OK               0
 
337
#define HA_ADMIN_NOT_IMPLEMENTED -1
 
338
#define HA_ADMIN_FAILED          -2
 
339
#define HA_ADMIN_CORRUPT         -3
 
340
#define HA_ADMIN_INTERNAL_ERROR  -4
 
341
#define HA_ADMIN_INVALID         -5
 
342
#define HA_ADMIN_REJECT          -6
 
343
#define HA_ADMIN_TRY_ALTER       -7
 
344
#define HA_ADMIN_NEEDS_UPGRADE  -10
 
345
#define HA_ADMIN_NEEDS_ALTER    -11
 
346
#define HA_ADMIN_NEEDS_CHECK    -12
 
347
 
 
348
 
 
349
/* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
 
350
 
 
351
/* Return values for check_if_supported_alter */
 
352
 
 
353
#define HA_ALTER_ERROR               -1
 
354
#define HA_ALTER_SUPPORTED_WAIT_LOCK  0
 
355
#define HA_ALTER_SUPPORTED_NO_LOCK    1
 
356
#define HA_ALTER_NOT_SUPPORTED        2
 
357
 
 
358
/* Bits in table_flags() to show what database can do */
 
359
 
 
360
#define HA_NO_TRANSACTIONS     (1 << 0) /* Doesn't support transactions */
 
361
#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */
 
362
#define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */
 
363
/*
 
364
  The following should be set if the following is not true when scanning
 
365
  a table with rnd_next()
 
366
  - We will see all rows (including deleted ones)
 
367
  - Row positions are 'table->s->db_record_offset' apart
 
368
  If this flag is not set, filesort will do a postion() call for each matched
 
369
  row to be able to find the row later.
 
370
*/
 
371
#define HA_REC_NOT_IN_SEQ      (1 << 3)
 
372
 
 
373
/*
 
374
  Reading keys in random order is as fast as reading keys in sort order
 
375
  (Used in records.cc to decide if we should use a record cache and by
 
376
  filesort to decide if we should sort key + data or key + pointer-to-row
 
377
*/
 
378
#define HA_FAST_KEY_READ       (1 << 5)
 
379
/*
 
380
  Set the following flag if we on delete should force all key to be read
 
381
  and on update read all keys that changes
 
382
*/
 
383
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6)
 
384
#define HA_NULL_IN_KEY         (1 << 7) /* One can have keys with NULL */
 
385
#define HA_DUPLICATE_POS       (1 << 8)    /* ha_position() gives dup row */
 
386
#define HA_NO_BLOBS            (1 << 9) /* Doesn't support blobs */
 
387
#define HA_CAN_INDEX_BLOBS     (1 << 10)
 
388
#define HA_AUTO_PART_KEY       (1 << 11) /* auto-increment in multi-part key */
 
389
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */
 
390
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */
 
391
/*
 
392
  If we get the primary key columns for free when we do an index read
 
393
  It also implies that we have to retrive the primary key when using
 
394
  position() and rnd_pos().
 
395
*/
 
396
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
 
397
/*
 
398
  If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
 
399
  uses a primary key. Without primary key, we can't call position().
 
400
*/
 
401
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16)
 
402
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
 
403
/*
 
404
  The following is we need to a primary key to delete (and update) a row.
 
405
  If there is no primary key, all columns needs to be read on update and delete
 
406
*/
 
407
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
 
408
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
 
409
#define HA_NO_AUTO_INCREMENT   (1 << 23)
 
410
#define HA_HAS_CHECKSUM        (1 << 24)
 
411
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
 
412
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
 
413
#define HA_HAS_RECORDS         (INT64_C(1) << 32) /* records() gives exact count*/
 
414
#define HA_MRR_CANT_SORT       (INT64_C(1) << 34)
 
415
 
 
416
/* bits in index_flags(index_number) for what you can do with index */
 
417
#define HA_READ_NEXT            1       /* TODO really use this flag */
 
418
#define HA_READ_PREV            2       /* supports ::index_prev */
 
419
#define HA_READ_ORDER           4       /* index_next/prev follow sort order */
 
420
#define HA_READ_RANGE           8       /* can find all records in a range */
 
421
#define HA_ONLY_WHOLE_INDEX     16      /* Can't use part key searches */
 
422
#define HA_KEYREAD_ONLY         64      /* Support HA_EXTRA_KEYREAD */
 
423
/*
 
424
  Index scan will not return records in rowid order. Not guaranteed to be
 
425
  set for unordered (e.g. HASH) indexes.
 
426
*/
 
427
#define HA_KEY_SCAN_NOT_ROR     128
 
428
#define HA_DO_INDEX_COND_PUSHDOWN  256 /* Supports Index Condition Pushdown */
 
429
 
 
430
/* operations for disable/enable indexes */
 
431
#define HA_KEY_SWITCH_NONUNIQ      0
 
432
#define HA_KEY_SWITCH_ALL          1
 
433
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
 
434
#define HA_KEY_SWITCH_ALL_SAVE     3
 
435
 
 
436
/*
 
437
  Note: the following includes binlog and closing 0.
 
438
  so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
 
439
      example + csv + heap + blackhole + federated + 0
 
440
  (yes, the sum is deliberately inaccurate)
 
441
  TODO remove the limit, use dynarrays
 
442
*/
 
443
#define MAX_HA 15
 
444
 
 
445
/*
 
446
  Parameters for open() (in register form->filestat)
 
447
  HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
 
448
*/
 
449
 
 
450
#define HA_OPEN_KEYFILE         1
 
451
#define HA_OPEN_RNDFILE         2
 
452
#define HA_GET_INDEX            4
 
453
#define HA_GET_INFO             8       /* do a ha_info() after open */
 
454
#define HA_READ_ONLY            16      /* File opened as readonly */
 
455
/* Try readonly if can't open with read and write */
 
456
#define HA_TRY_READ_ONLY        32
 
457
#define HA_WAIT_IF_LOCKED       64      /* Wait if locked on open */
 
458
#define HA_ABORT_IF_LOCKED      128     /* skip if locked on open.*/
 
459
#define HA_BLOCK_LOCK           256     /* unlock when reading some records */
 
460
#define HA_OPEN_TEMPORARY       512
 
461
 
 
462
/* For transactional LOCK Table. handler::lock_table() */
 
463
#define HA_LOCK_IN_SHARE_MODE      F_RDLCK
 
464
#define HA_LOCK_IN_EXCLUSIVE_MODE  F_WRLCK
 
465
 
 
466
/* Some key definitions */
 
467
#define HA_KEY_NULL_LENGTH      1
 
468
#define HA_KEY_BLOB_LENGTH      2
 
469
 
 
470
#define HA_LEX_CREATE_TMP_TABLE 1
 
471
#define HA_LEX_CREATE_IF_NOT_EXISTS 2
 
472
#define HA_LEX_CREATE_TABLE_LIKE 4
 
473
#define HA_OPTION_NO_CHECKSUM   (1L << 17)
 
474
#define HA_MAX_REC_LENGTH       65535
 
475
 
 
476
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
 
477
#define DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
 
478
 
 
479
/* Flags for method is_fatal_error */
 
480
#define HA_CHECK_DUP_KEY 1
 
481
#define HA_CHECK_DUP_UNIQUE 2
 
482
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
 
483
 
 
484
 
 
485
/* Bits in used_fields */
 
486
#define HA_CREATE_USED_AUTO             (1L << 0)
 
487
#define HA_CREATE_USED_CHARSET          (1L << 8)
 
488
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
 
489
#define HA_CREATE_USED_ENGINE           (1L << 12)
 
490
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
 
491
#define HA_CREATE_USED_COMMENT          (1L << 16)
 
492
#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)
 
493
#define HA_CREATE_USED_BLOCK_SIZE       (1L << 22)
 
494
 
 
495
#define MAXGTRIDSIZE 64
 
496
#define MAXBQUALSIZE 64
 
497
 
 
498
/*
 
499
  The below two are not used (and not handled) in this milestone of this WL
 
500
  entry because there seems to be no use for them at this stage of
 
501
  implementation.
 
502
*/
 
503
#define HA_MRR_SINGLE_POINT 1
 
504
#define HA_MRR_FIXED_KEY  2
 
505
 
 
506
/*
 
507
  Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
 
508
  'range' parameter.
 
509
*/
 
510
#define HA_MRR_NO_ASSOCIATION 4
 
511
 
 
512
/*
 
513
  The MRR user will provide ranges in key order, and MRR implementation
 
514
  must return rows in key order.
 
515
*/
 
516
#define HA_MRR_SORTED 8
 
517
 
 
518
/* MRR implementation doesn't have to retrieve full records */
 
519
#define HA_MRR_INDEX_ONLY 16
 
520
 
 
521
/*
 
522
  The passed memory buffer is of maximum possible size, the caller can't
 
523
  assume larger buffer.
 
524
*/
 
525
#define HA_MRR_LIMITS 32
 
526
 
 
527
 
 
528
/*
 
529
  Flag set <=> default MRR implementation is used
 
530
  (The choice is made by **_info[_const]() function which may set this
 
531
   flag. SQL layer remembers the flag value and then passes it to
 
532
   multi_read_range_init().
 
533
*/
 
534
#define HA_MRR_USE_DEFAULT_IMPL 64
 
535
 
 
536
/*
 
537
  Used only as parameter to multi_range_read_info():
 
538
  Flag set <=> the caller guarantees that the bounds of the scanned ranges
 
539
  will not have NULL values.
 
540
*/
 
541
#define HA_MRR_NO_NULL_ENDPOINTS 128
 
542
 
 
543
typedef int myf;
 
544
#define MYF(v)          (myf) (v)
 
545
 
 
546
#define MY_I_S_MAYBE_NULL 1
 
547
#define MY_I_S_UNSIGNED   2
 
548
 
 
549
 
 
550
#define SKIP_OPEN_TABLE 0                // do not open table
 
551
#define OPEN_FRM_ONLY   1                // open FRM file only
 
552
#define OPEN_FULL_TABLE 2                // open FRM,MYD, MYI files
 
553
 
 
554
/*
 
555
   "Declared Type Collation"
 
556
   A combination of collation and its derivation.
 
557
 
 
558
  Flags for collation aggregation modes:
 
559
  MY_COLL_ALLOW_SUPERSET_CONV  - allow conversion to a superset
 
560
  MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
 
561
                                 (i.e. constant).
 
562
  MY_COLL_ALLOW_CONV           - allow any kind of conversion
 
563
                                 (combination of the above two)
 
564
  MY_COLL_DISALLOW_NONE        - don't allow return DERIVATION_NONE
 
565
                                 (e.g. when aggregating for comparison)
 
566
  MY_COLL_CMP_CONV             - combination of MY_COLL_ALLOW_CONV
 
567
                                 and MY_COLL_DISALLOW_NONE
 
568
*/
 
569
 
 
570
#define MY_COLL_ALLOW_SUPERSET_CONV   1
 
571
#define MY_COLL_ALLOW_COERCIBLE_CONV  2
 
572
#define MY_COLL_ALLOW_CONV            3
 
573
#define MY_COLL_DISALLOW_NONE         4
 
574
#define MY_COLL_CMP_CONV              7
 
575
#define clear_timestamp_auto_bits(_target_, _bits_) \
 
576
  (_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
 
577
 
 
578
/*
 
579
 * The following are for the interface with the .frm file
 
580
 */
 
581
 
 
582
#define FIELDFLAG_PACK_SHIFT    3
 
583
#define FIELDFLAG_MAX_DEC    31
 
584
 
 
585
#define MTYP_TYPENR(type) (type & 127)  /* Remove bits from type */
 
586
 
 
587
#define f_packtype(x)   (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
 
588
#define f_settype(x)    (((int) x) << FIELDFLAG_PACK_SHIFT)
 
589
 
 
590
#endif /* DRIZZLED_DEFINITIONS_H */