~drizzle-trunk/drizzle/development

390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
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
 */
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
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
575.1.6 by Monty Taylor
Cleaned up some headers for PCH.
29
#if defined(__cplusplus)
30
#include CSTDINT_H
31
#else
32
#include <stdint.h>
33
#endif
34
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
35
#ifndef NO_ALARM_LOOP
36
#define NO_ALARM_LOOP		/* lib5 and popen can't use alarm */
37
#endif
38
39
/* These paths are converted to other systems (WIN95) before use */
40
41
#define LANGUAGE	"english/"
42
#define ERRMSG_FILE	"errmsg.sys"
43
#define TEMP_PREFIX	"MY"
44
#define LOG_PREFIX	"ML"
45
#define PROGDIR		"bin/"
46
#ifndef DATADIR
47
#define DATADIR		"data/"
48
#endif
49
#ifndef SHAREDIR
50
#define SHAREDIR	"share/"
51
#endif
52
#ifndef PLUGINDIR
53
#define PLUGINDIR	"lib/plugin"
54
#endif
55
549 by Monty Taylor
Took gettext.h out of header files.
56
#define ER(X) error_message((X))
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
57
58
#define LIBLEN FN_REFLEN-FN_LEN			/* Max l{ngd p} dev */
59
/* extra 4+4 bytes for slave tmp tables */
60
#define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
61
#define MAX_ALIAS_NAME 256
62
#define MAX_FIELD_NAME 34			/* Max colum name length +2 */
63
#define MAX_SYS_VAR_LENGTH 32
64
#define MAX_KEY MAX_INDEXES                     /* Max used keys */
65
#define MAX_REF_PARTS 16			/* Max parts used as ref */
66
#define MAX_KEY_LENGTH 4096			/* max possible key */
67
#define MAX_KEY_LENGTH_DECIMAL_WIDTH 4          /* strlen("4096") */
68
#if SIZEOF_OFF_T > 4
69
#define MAX_REFLENGTH 8				/* Max length for record ref */
70
#else
71
#define MAX_REFLENGTH 4				/* Max length for record ref */
72
#endif
73
#define MAX_HOSTNAME  61			/* len+1 in mysql.user */
74
75
#define MAX_MBWIDTH		4		/* Max multibyte sequence */
76
#define MAX_FIELD_CHARLENGTH	255
77
#define MAX_FIELD_VARCHARLENGTH	65535
78
#define CONVERT_IF_BIGGER_TO_BLOB 512		/* Used for CREATE ... SELECT */
79
80
/* Max column width +1 */
81
#define MAX_FIELD_WIDTH		(MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
82
83
#define MAX_BIT_FIELD_LENGTH    64      /* Max length in bits for bit fields */
84
85
#define MAX_DATE_WIDTH		10	/* YYYY-MM-DD */
86
#define MAX_TIME_WIDTH		23	/* -DDDDDD HH:MM:SS.###### */
87
#define MAX_DATETIME_FULL_WIDTH 29	/* YYYY-MM-DD HH:MM:SS.###### AM */
88
#define MAX_DATETIME_WIDTH	19	/* YYYY-MM-DD HH:MM:SS */
89
#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
90
91
#define MAX_TABLES	(sizeof(table_map)*8-3)	/* Max tables in join */
92
#define PARAM_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-3))
93
#define OUTER_REF_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-2))
94
#define RAND_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-1))
95
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
96
                           RAND_TABLE_BIT)
97
#define MAX_FIELDS	4096			/* Limit in the .frm file */
98
99
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
100
101
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
102
#define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
103
104
/* Memory allocated when parsing a statement / saving a statement */
105
#define MEM_ROOT_BLOCK_SIZE       8192
106
#define MEM_ROOT_PREALLOC         8192
107
#define TRANS_MEM_ROOT_BLOCK_SIZE 4096
108
#define TRANS_MEM_ROOT_PREALLOC   4096
109
110
#define DEFAULT_ERROR_COUNT	64
111
#define EXTRA_RECORDS	10			/* Extra records in sort */
112
#define SCROLL_EXTRA	5			/* Extra scroll-rows. */
113
#define FIELD_NAME_USED ((uint) 32768)		/* Bit set if fieldname used */
114
#define FORM_NAME_USED	((uint) 16384)		/* Bit set if formname used */
115
#define FIELD_NR_MASK	16383			/* To get fieldnumber */
116
#define FERR		-1			/* Error from my_functions */
117
#define CREATE_MODE	0			/* Default mode on new files */
118
#define NAMES_SEP_CHAR	'\377'			/* Char to sep. names */
119
120
#define READ_RECORD_BUFFER	(uint) (IO_SIZE*8) /* Pointer_buffer_size */
121
#define DISK_BUFFER_SIZE	(uint) (IO_SIZE*16) /* Size of diskbuffer */
122
123
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
124
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
125
#define MYF_RW MYF(MY_WME+MY_NABP)		/* Vid my_read & my_write */
126
127
	/* Extern defines */
128
#define store_record(A,B) memcpy((A)->B,(A)->record[0],(size_t) (A)->s->reclength)
129
#define restore_record(A,B) memcpy((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
130
#define cmp_record(A,B) memcmp((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
131
#define empty_record(A)                                 \
132
  do {                                                  \
133
    restore_record((A),s->default_values);              \
134
    memset((A)->null_flags, 255, (A)->s->null_bytes);   \
135
  } while (0)
136
137
	/* Defines for use with openfrm, openprt and openfrd */
138
139
#define READ_ALL		1	/* openfrm: Read all parameters */
140
#define CHANGE_FRM		2	/* openfrm: open .frm as O_RDWR */
141
#define EXTRA_RECORD		8	/* Reservera plats f|r extra record */
142
#define DONT_GIVE_ERROR		256	/* Don't do frm_error on openfrm  */
143
#define DELAYED_OPEN		4096	/* Open table later */
144
/**
145
  This flag is used in function get_all_tables() which fills
146
  I_S tables with data which are retrieved from frm files and storage engine
147
  The flag means that we need to open FRM file only to get necessary data.
148
*/
149
#define OPEN_FRM_FILE_ONLY     32768
150
/**
151
  This flag is used in function get_all_tables() which fills
152
  I_S tables with data which are retrieved from frm files and storage engine
153
  The flag means that we need to process tables only to get necessary data.
154
  Views are not processed.
155
*/
156
#define OPEN_TABLE_ONLY        OPEN_FRM_FILE_ONLY*2
157
/**
158
  This flag is used in function get_all_tables() which fills
159
  I_S tables with data which are retrieved from frm files and storage engine.
160
  The flag means that I_S table uses optimization algorithm.
161
*/
357 by Brian Aker
flag cleanup
162
#define OPTIMIZE_I_S_TABLE     OPEN_TABLE_ONLY*2
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
163
164
#define SC_INFO_LENGTH 4		/* Form format constant */
165
#define TE_INFO_LENGTH 3
166
#define MTYP_NOEMPTY_BIT 128
167
168
#define FRM_VER_TRUE_VARCHAR (FRM_VER+4) /* 10 */
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
169
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_CGE 50120
170
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM 50205
171
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_STR "50205"
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
172
173
/*
174
  Minimum length pattern before Turbo Boyer-Moore is used
175
  for SELECT "text" LIKE "%pattern%", excluding the two
176
  wildcards in class Item_func_like.
177
*/
178
#define MIN_TURBOBM_PATTERN_LEN 3
179
180
/* 
181
   Defines for binary logging.
182
   Do not decrease the value of BIN_LOG_HEADER_SIZE.
183
   Do not even increase it before checking code.
184
*/
185
186
#define BIN_LOG_HEADER_SIZE    4 
187
188
#define DEFAULT_KEY_CACHE_NAME "default"
189
190
#define STORAGE_TYPE_MASK 7
191
#define COLUMN_FORMAT_MASK 7
192
#define COLUMN_FORMAT_SHIFT 3
193
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
194
/* Below are #defines that used to be in mysql_priv.h */
195
/***************************************************************************
196
  Configuration parameters
197
****************************************************************************/
198
#define ACL_CACHE_SIZE		256
199
#define MAX_PASSWORD_LENGTH	32
200
#define HOST_CACHE_SIZE		128
201
#define MAX_ACCEPT_RETRY	10	// Test accept this many times
202
#define MAX_FIELDS_BEFORE_HASH	32
203
#define USER_VARS_HASH_SIZE     16
204
#define TABLE_OPEN_CACHE_MIN    64
205
#define TABLE_OPEN_CACHE_DEFAULT 64
206
207
/* 
208
 Value of 9236 discovered through binary search 2006-09-26 on Ubuntu Dapper
209
 Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added 
210
 100 bytes as reasonable buffer against growth and other environments'
211
 requirements.)
212
213
 Feel free to raise this by the smallest amount you can to get the
214
 "execution_constants" test to pass.
215
 */
216
#define STACK_MIN_SIZE          12000   ///< Abort if less stack during eval.
217
218
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
219
#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
220
221
/** 
222
 * @TODO Move into a drizzled.h since it's only used in drizzled.cc
223
 *
224
 * @TODO Rename to DRIZZLED_NET_RETRY_COUNT
225
 */
226
#ifndef MYSQLD_NET_RETRY_COUNT
227
#define MYSQLD_NET_RETRY_COUNT  10	///< Abort read after this many int.
228
#endif
229
#define TEMP_POOL_SIZE          128
230
231
#define QUERY_ALLOC_BLOCK_SIZE		8192
232
#define QUERY_ALLOC_PREALLOC_SIZE   	8192
233
#define TRANS_ALLOC_BLOCK_SIZE		4096
234
#define TRANS_ALLOC_PREALLOC_SIZE	4096
235
#define RANGE_ALLOC_BLOCK_SIZE		4096
236
#define ACL_ALLOC_BLOCK_SIZE		1024
237
#define UDF_ALLOC_BLOCK_SIZE		1024
238
#define TABLE_ALLOC_BLOCK_SIZE		1024
239
#define BDB_LOG_ALLOC_BLOCK_SIZE	1024
240
#define WARN_ALLOC_BLOCK_SIZE		2048
241
#define WARN_ALLOC_PREALLOC_SIZE	1024
242
#define PROFILE_ALLOC_BLOCK_SIZE  2048
243
#define PROFILE_ALLOC_PREALLOC_SIZE 1024
244
245
/*
246
  The following parameters is to decide when to use an extra cache to
247
  optimise seeks when reading a big table in sorted order
248
*/
249
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
250
#define MIN_ROWS_TO_USE_TABLE_CACHE	 100
251
#define MIN_ROWS_TO_USE_BULK_INSERT	 100
252
253
/**
254
  The following is used to decide if MySQL should use table scanning
255
  instead of reading with keys.  The number says how many evaluation of the
256
  WHERE clause is comparable to reading one extra row from a table.
257
*/
258
#define TIME_FOR_COMPARE   5	// 5 compares == one read
259
260
/**
261
  Number of comparisons of table rowids equivalent to reading one row from a 
262
  table.
263
*/
264
#define TIME_FOR_COMPARE_ROWID  (TIME_FOR_COMPARE*2)
265
266
/*
267
  For sequential disk seeks the cost formula is:
268
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip  
269
  
270
  The cost of average seek 
271
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
272
*/
273
#define DISK_SEEK_BASE_COST ((double)0.9)
274
275
#define BLOCKS_IN_AVG_SEEK  128
276
277
#define DISK_SEEK_PROP_COST ((double)0.1/BLOCKS_IN_AVG_SEEK)
278
279
280
/**
281
  Number of rows in a reference table when refereed through a not unique key.
282
  This value is only used when we don't know anything about the key
283
  distribution.
284
*/
285
#define MATCHING_ROWS_IN_OTHER_TABLE 10
286
287
/** Don't pack string keys shorter than this (if PACK_KEYS=1 isn't used). */
288
#define KEY_DEFAULT_PACK_LENGTH 8
289
290
/** Characters shown for the command in 'show processlist'. */
291
#define PROCESS_LIST_WIDTH 100
292
/* Characters shown for the command in 'information_schema.processlist' */
293
#define PROCESS_LIST_INFO_WIDTH 65535
294
295
#define PRECISION_FOR_DOUBLE 53
296
#define PRECISION_FOR_FLOAT  24
297
298
/*
299
  Default time to wait before aborting a new client connection
300
  that does not respond to "initial server greeting" timely
301
*/
302
#define CONNECT_TIMEOUT		10
303
304
/* The following can also be changed from the command line */
305
#define DEFAULT_CONCURRENCY	10
306
#define FLUSH_TIME		0		/**< Don't flush tables */
307
#define MAX_CONNECT_ERRORS	10		///< errors before disabling host
308
309
#define INTERRUPT_PRIOR 10
310
#define CONNECT_PRIOR	9
311
#define WAIT_PRIOR	8
312
#define QUERY_PRIOR	6
313
314
	/* Bits from testflag */
315
#define TEST_PRINT_CACHED_TABLES 1
316
#define TEST_NO_KEY_GROUP	 2
317
#define TEST_MIT_THREAD		4
318
#define TEST_KEEP_TMP_TABLES	16
319
#define TEST_READCHECK		64	/**< Force use of readcheck */
320
#define TEST_NO_EXTRA		128
321
#define TEST_CORE_ON_SIGNAL	256	/**< Give core if signal */
322
#define TEST_NO_STACKTRACE	512
323
#define TEST_SIGINT		1024	/**< Allow sigint on threads */
324
#define TEST_SYNCHRONIZATION    2048    /**< get server to do sleep in some places */
325
326
/* Bits for different SQL modes modes (including ANSI mode) */
361 by Brian Aker
One more mode down, two more left to go!
327
#define MODE_NO_ZERO_DATE		(2)
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
328
#define MODE_INVALID_DATES		(MODE_NO_ZERO_DATE*2)
329
330
/* @@optimizer_switch flags */
331
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
332
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
333
334
#define MY_CHARSET_BIN_MB_MAXLEN 1
335
336
// uncachable cause
337
#define UNCACHEABLE_DEPENDENT   1
338
#define UNCACHEABLE_RAND        2
339
#define UNCACHEABLE_SIDEEFFECT	4
340
/// forcing to save JOIN for explain
341
#define UNCACHEABLE_EXPLAIN     8
342
/** Don't evaluate subqueries in prepare even if they're not correlated */
343
#define UNCACHEABLE_PREPARE    16
344
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
345
#define UNCACHEABLE_UNITED     32
346
347
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
348
#define UNDEF_POS (-1)
349
350
/* BINLOG_DUMP options */
351
352
#define BINLOG_DUMP_NON_BLOCK   1
353
354
/* sql_show.cc:show_log_files() */
355
#define SHOW_LOG_STATUS_FREE "FREE"
356
#define SHOW_LOG_STATUS_INUSE "IN USE"
357
358
/* Options to add_table_to_list() */
359
#define TL_OPTION_UPDATING	1
360
#define TL_OPTION_FORCE_INDEX	2
361
#define TL_OPTION_IGNORE_LEAVES 4
362
#define TL_OPTION_ALIAS         8
363
364
/* Some portable defines */
365
366
#define portable_sizeof_char_ptr 8
367
368
#define tmp_file_prefix "#sql"			/**< Prefix for tmp tables */
369
#define tmp_file_prefix_length 4
370
371
/* Flags for calc_week() function.  */
372
#define WEEK_MONDAY_FIRST    1
373
#define WEEK_YEAR            2
374
#define WEEK_FIRST_WEEKDAY   4
375
376
#define STRING_BUFFER_USUAL_SIZE 80
377
378
/*
379
  Some defines for exit codes for ::is_equal class functions.
380
*/
381
#define IS_EQUAL_NO 0
382
#define IS_EQUAL_YES 1
383
#define IS_EQUAL_PACK_LENGTH 2
384
561.1.3 by Monty Taylor
Split some more things out of common_includes.h.
385
386
/**
387
  Query type constants.
388
389
  QT_ORDINARY -- ordinary SQL query.
390
  QT_IS -- SQL query to be shown in INFORMATION_SCHEMA (in utf8 and without
391
  character set introducers).
392
393
  @TODO
394
395
  Move this out of here once Stew's done with UDF breakout.  The following headers need it:
396
397
    sql_lex.h --> included by sql_class.h
398
    item.h
399
    table.h
400
    item_func.h
401
    item_subselect.h
402
    item_timefunc.h
403
    item_sum.h
404
    item_cmpfunc.h
405
    item_strfunc.h
406
*/
407
enum enum_query_type
408
{
409
  QT_ORDINARY,
410
  QT_IS
411
};
412
413
414
/**
415
 * @TODO Move to a separate header?
416
 *
417
 * It's needed by item.h and field.h, which are both inter-dependent
418
 * and contain forward declarations of many structs/classes in the
419
 * other header file.
420
 *
421
 * What is needed is a separate header file that is included
422
 * by *both* item.h and field.h to resolve inter-dependencies
423
 *
424
 * But, probably want to hold off on this until Stew finished the UDF cleanup
425
 */
426
enum Derivation
427
{
428
  DERIVATION_IGNORABLE= 5,
429
  DERIVATION_COERCIBLE= 4,
430
  DERIVATION_SYSCONST= 3,
431
  DERIVATION_IMPLICIT= 2,
432
  DERIVATION_NONE= 1,
433
  DERIVATION_EXPLICIT= 0
434
};
435
436
/**
437
 * Opening modes for open_temporary_table and open_table_from_share
438
 *
439
 * @TODO Put this into an appropriate header. It is only needed in:
440
 *
441
 *    table.cc
442
 *    sql_base.cc
443
 */
444
enum open_table_mode
445
{
446
  OTM_OPEN= 0,
447
  OTM_CREATE= 1,
448
  OTM_ALTER= 2
449
};
450
451
enum enum_parsing_place
452
{
453
  NO_MATTER
454
  , IN_HAVING
455
  , SELECT_LIST
456
  , IN_WHERE
457
  , IN_ON
458
};
459
460
enum enum_mysql_completiontype {
461
  ROLLBACK_RELEASE= -2
462
  , ROLLBACK= 1
463
  , ROLLBACK_AND_CHAIN= 7
464
  , COMMIT_RELEASE= -1
465
  , COMMIT= 0
466
  , COMMIT_AND_CHAIN= 6
467
};
468
469
enum enum_check_fields
470
{
471
  CHECK_FIELD_IGNORE
472
  , CHECK_FIELD_WARN
473
  , CHECK_FIELD_ERROR_FOR_NULL
474
};
475
476
enum enum_var_type
477
{
478
  OPT_DEFAULT= 0
479
  , OPT_SESSION
480
  , OPT_GLOBAL
481
};
482
520.6.4 by Monty Taylor
Moved thr_lock.h out of common_includes.
483
553.1.2 by Monty Taylor
Moved some bitmap defines into bitmap.
484
typedef uint64_t query_id_t;
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
485
typedef void *range_seq_t;
486
553.1.2 by Monty Taylor
Moved some bitmap defines into bitmap.
487
520.6.7 by Monty Taylor
Moved a bunch of crap out of common_includes.
488
/**
489
   The maximum is defined as (ULONG_MAX/1000) with 4 bytes uint32_t
490
*/
575.1.6 by Monty Taylor
Cleaned up some headers for PCH.
491
static const uint32_t SLAVE_MAX_HEARTBEAT_PERIOD= 4294967;
520.6.7 by Monty Taylor
Moved a bunch of crap out of common_includes.
492
493
#define SLAVE_NET_TIMEOUT  3600
494
495
#define MAX_SLAVE_ERROR    2000
496
497
/* masks for start/stop operations on io and sql slave threads */
498
#define SLAVE_IO  1
499
#define SLAVE_SQL 2
500
520.8.6 by Monty Taylor
Removed handler from common_includes.
501
#ifndef NO_HASH
502
#define NO_HASH				/* Not yet implemented */
503
#endif
504
505
// the following is for checking tables
506
507
#define HA_ADMIN_ALREADY_DONE	  1
508
#define HA_ADMIN_OK               0
509
#define HA_ADMIN_NOT_IMPLEMENTED -1
510
#define HA_ADMIN_FAILED		 -2
511
#define HA_ADMIN_CORRUPT         -3
512
#define HA_ADMIN_INTERNAL_ERROR  -4
513
#define HA_ADMIN_INVALID         -5
514
#define HA_ADMIN_REJECT          -6
515
#define HA_ADMIN_TRY_ALTER       -7
516
#define HA_ADMIN_WRONG_CHECKSUM  -8
517
#define HA_ADMIN_NOT_BASE_TABLE  -9
518
#define HA_ADMIN_NEEDS_UPGRADE  -10
519
#define HA_ADMIN_NEEDS_ALTER    -11
520
#define HA_ADMIN_NEEDS_CHECK    -12
521
522
523
#define HA_ADD_INDEX                  (0)
524
#define HA_DROP_INDEX                 (1)
525
#define HA_ALTER_INDEX                (2)
526
#define HA_RENAME_INDEX               (3)
527
#define HA_ADD_UNIQUE_INDEX           (4)
528
#define HA_DROP_UNIQUE_INDEX          (5)
529
#define HA_ALTER_UNIQUE_INDEX         (6)
530
#define HA_RENAME_UNIQUE_INDEX        (7)
531
#define HA_ADD_PK_INDEX               (8)
532
#define HA_DROP_PK_INDEX              (9)
533
#define HA_ALTER_PK_INDEX             (10)
534
#define HA_ADD_COLUMN                 (11)
535
#define HA_DROP_COLUMN                (12)
536
#define HA_CHANGE_COLUMN              (13)
537
#define HA_ALTER_COLUMN_NAME          (14)
538
#define HA_ALTER_COLUMN_TYPE          (15)
539
#define HA_ALTER_COLUMN_ORDER         (16)
540
#define HA_ALTER_COLUMN_NULLABLE      (17)
541
#define HA_COLUMN_DEFAULT_VALUE       (18)
542
#define HA_COLUMN_STORAGE             (19)
543
#define HA_COLUMN_FORMAT              (20)
544
#define HA_ADD_FOREIGN_KEY            (21)
545
#define HA_DROP_FOREIGN_KEY           (22)
546
#define HA_ALTER_FOREIGN_KEY          (23)
547
#define HA_ADD_CONSTRAINT             (24)
548
#define HA_CHANGE_CHARACTER_SET       (30)
549
#define HA_SET_DEFAULT_CHARACTER_SET  (31)
550
#define HA_CHANGE_AUTOINCREMENT_VALUE (32)
551
#define HA_ALTER_STORAGE              (33)
552
#define HA_ALTER_TABLESPACE           (34)
553
#define HA_ALTER_ROW_FORMAT           (35)
554
#define HA_RENAME_TABLE               (36)
555
#define HA_ALTER_STORAGE_ENGINE       (37)
556
#define HA_RECREATE                   (38)
557
#define HA_ALTER_STORED_VCOL          (39)
558
/* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
559
560
/* Return values for check_if_supported_alter */
561
562
#define HA_ALTER_ERROR               -1
563
#define HA_ALTER_SUPPORTED_WAIT_LOCK  0
564
#define HA_ALTER_SUPPORTED_NO_LOCK    1
565
#define HA_ALTER_NOT_SUPPORTED        2
566
567
/* Bits in table_flags() to show what database can do */
568
569
#define HA_NO_TRANSACTIONS     (1 << 0) /* Doesn't support transactions */
570
#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */
571
#define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */
572
/*
573
  The following should be set if the following is not true when scanning
574
  a table with rnd_next()
575
  - We will see all rows (including deleted ones)
576
  - Row positions are 'table->s->db_record_offset' apart
577
  If this flag is not set, filesort will do a postion() call for each matched
578
  row to be able to find the row later.
579
*/
580
#define HA_REC_NOT_IN_SEQ      (1 << 3)
581
582
/*
583
  Reading keys in random order is as fast as reading keys in sort order
584
  (Used in records.cc to decide if we should use a record cache and by
585
  filesort to decide if we should sort key + data or key + pointer-to-row
586
*/
587
#define HA_FAST_KEY_READ       (1 << 5)
588
/*
589
  Set the following flag if we on delete should force all key to be read
590
  and on update read all keys that changes
591
*/
592
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6)
593
#define HA_NULL_IN_KEY         (1 << 7) /* One can have keys with NULL */
594
#define HA_DUPLICATE_POS       (1 << 8)    /* ha_position() gives dup row */
595
#define HA_NO_BLOBS            (1 << 9) /* Doesn't support blobs */
596
#define HA_CAN_INDEX_BLOBS     (1 << 10)
597
#define HA_AUTO_PART_KEY       (1 << 11) /* auto-increment in multi-part key */
598
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */
599
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */
600
/*
601
  If we get the primary key columns for free when we do an index read
602
  It also implies that we have to retrive the primary key when using
603
  position() and rnd_pos().
604
*/
605
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
606
/*
607
  If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
608
  uses a primary key. Without primary key, we can't call position().
609
*/ 
610
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16) 
611
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
612
/*
613
  The following is we need to a primary key to delete (and update) a row.
614
  If there is no primary key, all columns needs to be read on update and delete
615
*/
616
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
617
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
618
#define HA_NO_AUTO_INCREMENT   (1 << 23)
619
#define HA_HAS_CHECKSUM        (1 << 24)
620
/* Table data are stored in separate files (for lower_case_table_names) */
621
#define HA_FILE_BASED	       (1 << 26)
622
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
623
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
624
#define HA_NO_COPY_ON_ALTER    (INT64_C(1) << 31)
625
#define HA_HAS_RECORDS	       (INT64_C(1) << 32) /* records() gives exact count*/
626
#define HA_MRR_CANT_SORT       (INT64_C(1) << 34)
627
628
/*
629
  Engine is capable of row-format and statement-format logging,
630
  respectively
631
*/
632
#define HA_BINLOG_ROW_CAPABLE  (INT64_C(1) << 35)
633
#define HA_BINLOG_STMT_CAPABLE (INT64_C(1) << 36)
634
635
#define HA_ONLINE_ALTER        (INT64_C(1) << 37)
636
637
/*
638
  Set of all binlog flags. Currently only contain the capabilities
639
  flags.
640
 */
641
#define HA_BINLOG_FLAGS (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE)
642
643
/* bits in index_flags(index_number) for what you can do with index */
644
#define HA_READ_NEXT            1       /* TODO really use this flag */
645
#define HA_READ_PREV            2       /* supports ::index_prev */
646
#define HA_READ_ORDER           4       /* index_next/prev follow sort order */
647
#define HA_READ_RANGE           8       /* can find all records in a range */
648
#define HA_ONLY_WHOLE_INDEX	16	/* Can't use part key searches */
649
#define HA_KEYREAD_ONLY         64	/* Support HA_EXTRA_KEYREAD */
650
/*
651
  Index scan will not return records in rowid order. Not guaranteed to be
652
  set for unordered (e.g. HASH) indexes.
653
*/
654
#define HA_KEY_SCAN_NOT_ROR     128 
655
#define HA_DO_INDEX_COND_PUSHDOWN  256 /* Supports Index Condition Pushdown */
656
657
658
659
/*
660
  HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is
661
  supported at all.
662
  HA_FAST_CHANGE_PARTITION means that optimised variants of the changes
663
  exists but they are not necessarily done online.
664
665
  HA_ONLINE_DOUBLE_WRITE means that the handler supports writing to both
666
  the new partition and to the old partitions when updating through the
667
  old partitioning schema while performing a change of the partitioning.
668
  This means that we can support updating of the table while performing
669
  the copy phase of the change. For no lock at all also a double write
670
  from new to old must exist and this is not required when this flag is
671
  set.
672
  This is actually removed even before it was introduced the first time.
673
  The new idea is that handlers will handle the lock level already in
674
  store_lock for ALTER Table partitions.
675
676
  HA_PARTITION_ONE_PHASE is a flag that can be set by handlers that take
677
  care of changing the partitions online and in one phase. Thus all phases
678
  needed to handle the change are implemented inside the storage engine.
679
  The storage engine must also support auto-discovery since the frm file
680
  is changed as part of the change and this change must be controlled by
681
  the storage engine. A typical engine to support this is NDB (through
682
  WL #2498).
683
*/
684
#define HA_PARTITION_FUNCTION_SUPPORTED         (1L << 1)
685
#define HA_FAST_CHANGE_PARTITION                (1L << 2)
686
#define HA_PARTITION_ONE_PHASE                  (1L << 3)
687
688
/* operations for disable/enable indexes */
689
#define HA_KEY_SWITCH_NONUNIQ      0
690
#define HA_KEY_SWITCH_ALL          1
691
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
692
#define HA_KEY_SWITCH_ALL_SAVE     3
693
694
/*
695
  Note: the following includes binlog and closing 0.
696
  so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
697
      example + csv + heap + blackhole + federated + 0
698
  (yes, the sum is deliberately inaccurate)
699
  TODO remove the limit, use dynarrays
700
*/
701
#define MAX_HA 15
702
703
/*
704
  Parameters for open() (in register form->filestat)
705
  HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
706
*/
707
708
#define HA_OPEN_KEYFILE		1
709
#define HA_OPEN_RNDFILE		2
710
#define HA_GET_INDEX		4
711
#define HA_GET_INFO		8	/* do a ha_info() after open */
712
#define HA_READ_ONLY		16	/* File opened as readonly */
713
/* Try readonly if can't open with read and write */
714
#define HA_TRY_READ_ONLY	32
715
#define HA_WAIT_IF_LOCKED	64	/* Wait if locked on open */
716
#define HA_ABORT_IF_LOCKED	128	/* skip if locked on open.*/
717
#define HA_BLOCK_LOCK		256	/* unlock when reading some records */
718
#define HA_OPEN_TEMPORARY	512
719
720
/* For transactional LOCK Table. handler::lock_table() */
721
#define HA_LOCK_IN_SHARE_MODE      F_RDLCK
722
#define HA_LOCK_IN_EXCLUSIVE_MODE  F_WRLCK
723
724
/* Some key definitions */
725
#define HA_KEY_NULL_LENGTH	1
726
#define HA_KEY_BLOB_LENGTH	2
727
728
#define HA_LEX_CREATE_TMP_TABLE	1
729
#define HA_LEX_CREATE_IF_NOT_EXISTS 2
730
#define HA_LEX_CREATE_TABLE_LIKE 4
731
#define HA_OPTION_NO_CHECKSUM	(1L << 17)
732
#define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18)
733
#define HA_MAX_REC_LENGTH	65535
734
735
/* Table caching type */
736
#define HA_CACHE_TBL_NONTRANSACT 0
737
#define HA_CACHE_TBL_NOCACHE     1
738
#define HA_CACHE_TBL_ASKTRANSACT 2
739
#define HA_CACHE_TBL_TRANSACT    4
740
741
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
742
#define DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
743
744
/* Flags for method is_fatal_error */
745
#define HA_CHECK_DUP_KEY 1
746
#define HA_CHECK_DUP_UNIQUE 2
747
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
748
749
enum legacy_db_type
750
{
751
  DB_TYPE_UNKNOWN=0,
752
  DB_TYPE_FIRST_DYNAMIC=42,
753
  DB_TYPE_DEFAULT=127 // Must be last
754
};
755
756
enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED,
757
		ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED,
758
		ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGE };
759
760
enum column_format_type { COLUMN_FORMAT_TYPE_NOT_USED= -1,
761
                          COLUMN_FORMAT_TYPE_DEFAULT=   0,
762
                          COLUMN_FORMAT_TYPE_FIXED=     1,
763
                          COLUMN_FORMAT_TYPE_DYNAMIC=   2 };
764
765
enum enum_binlog_func {
766
  BFN_RESET_LOGS=        1,
767
  BFN_RESET_SLAVE=       2,
768
  BFN_BINLOG_WAIT=       3,
769
  BFN_BINLOG_END=        4,
770
  BFN_BINLOG_PURGE_FILE= 5
771
};
772
773
enum enum_binlog_command {
774
  LOGCOM_CREATE_TABLE,
775
  LOGCOM_ALTER_TABLE,
776
  LOGCOM_RENAME_TABLE,
777
  LOGCOM_DROP_TABLE,
778
  LOGCOM_CREATE_DB,
779
  LOGCOM_ALTER_DB,
780
  LOGCOM_DROP_DB
781
};
782
783
/* struct to hold information about the table that should be created */
784
785
/* Bits in used_fields */
786
#define HA_CREATE_USED_AUTO             (1L << 0)
787
#ifdef DEAD_OPTIONS
788
#define HA_CREATE_USED_UNION            (1L << 2)
789
#define HA_CREATE_USED_PASSWORD         (1L << 17)
790
#endif
791
#define HA_CREATE_USED_INSERT_METHOD    (1L << 3)
792
#define HA_CREATE_USED_MIN_ROWS         (1L << 4)
793
#define HA_CREATE_USED_MAX_ROWS         (1L << 5)
794
#define HA_CREATE_USED_AVG_ROW_LENGTH   (1L << 6)
795
#define HA_CREATE_USED_PACK_KEYS        (1L << 7)
796
#define HA_CREATE_USED_CHARSET          (1L << 8)
797
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
798
#define HA_CREATE_USED_DATADIR          (1L << 10)
799
#define HA_CREATE_USED_INDEXDIR         (1L << 11)
800
#define HA_CREATE_USED_ENGINE           (1L << 12)
801
#define HA_CREATE_USED_CHECKSUM         (1L << 13)
802
#define HA_CREATE_USED_DELAY_KEY_WRITE  (1L << 14)
803
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
804
#define HA_CREATE_USED_COMMENT          (1L << 16)
805
#define HA_CREATE_USED_CONNECTION       (1L << 18)
806
#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)
807
#define HA_CREATE_USED_PAGE_CHECKSUM    (1L << 21)
808
#define HA_CREATE_USED_BLOCK_SIZE       (1L << 22)
809
810
#define MAXGTRIDSIZE 64
811
#define MAXBQUALSIZE 64
812
813
#define COMPATIBLE_DATA_YES 0
814
#define COMPATIBLE_DATA_NO  1
815
816
#define UNDEF_NODEGROUP 65535
817
#define NOT_A_PARTITION_ID ((uint32_t)-1)
818
819
enum ha_choice { HA_CHOICE_UNDEF, HA_CHOICE_NO, HA_CHOICE_YES };
820
821
/* Possible flags of a handlerton (there can be 32 of them) */
822
#define HTON_NO_FLAGS                 0
823
#define HTON_CLOSE_CURSORS_AT_COMMIT (1 << 0)
824
#define HTON_ALTER_NOT_SUPPORTED     (1 << 1) //Engine does not support alter
825
#define HTON_CAN_RECREATE            (1 << 2) //Delete all is used fro truncate
826
#define HTON_HIDDEN                  (1 << 3) //Engine does not appear in lists
827
#define HTON_FLUSH_AFTER_RENAME      (1 << 4)
828
#define HTON_NOT_USER_SELECTABLE     (1 << 5)
829
#define HTON_TEMPORARY_NOT_SUPPORTED (1 << 6) //Having temporary tables not supported
830
#define HTON_SUPPORT_LOG_TABLES      (1 << 7) //Engine supports log tables
831
#define HTON_NO_PARTITION            (1 << 8) //You can not partition these tables
832
/*
833
  The below two are not used (and not handled) in this milestone of this WL
834
  entry because there seems to be no use for them at this stage of
835
  implementation.
836
*/
837
#define HA_MRR_SINGLE_POINT 1
838
#define HA_MRR_FIXED_KEY  2
839
840
/* 
841
  Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
842
  'range' parameter.
843
*/
844
#define HA_MRR_NO_ASSOCIATION 4
845
846
/* 
847
  The MRR user will provide ranges in key order, and MRR implementation
848
  must return rows in key order.
849
*/
850
#define HA_MRR_SORTED 8
851
852
/* MRR implementation doesn't have to retrieve full records */
853
#define HA_MRR_INDEX_ONLY 16
854
855
/* 
856
  The passed memory buffer is of maximum possible size, the caller can't
857
  assume larger buffer.
858
*/
859
#define HA_MRR_LIMITS 32
860
861
862
/*
863
  Flag set <=> default MRR implementation is used
864
  (The choice is made by **_info[_const]() function which may set this
865
   flag. SQL layer remembers the flag value and then passes it to
866
   multi_read_range_init().
867
*/
868
#define HA_MRR_USE_DEFAULT_IMPL 64
869
870
/*
871
  Used only as parameter to multi_range_read_info():
872
  Flag set <=> the caller guarantees that the bounds of the scanned ranges
873
  will not have NULL values.
874
*/
875
#define HA_MRR_NO_NULL_ENDPOINTS 128
876
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
877
enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY, RNEXT_SAME };
878
879
enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED,
880
                         ISO_REPEATABLE_READ, ISO_SERIALIZABLE};
881
882
575.1.5 by Monty Taylor
Moved stuff to handlerton.cc
883
enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
884
575.1.6 by Monty Taylor
Cleaned up some headers for PCH.
885
typedef int myf;
886
#define MYF(v)		(myf) (v)
887
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
888
#endif /* DRIZZLE_SERVER_DEFINITIONS_H */