~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
 *
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
23
 * Mostly constants and some macros/functions used by the server
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
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
#include <stdint.h>
30
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
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
549 by Monty Taylor
Took gettext.h out of header files.
43
#define ER(X) error_message((X))
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
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_BIT_FIELD_LENGTH    64      /* Max length in bits for bit fields */
71
72
#define MAX_DATE_WIDTH		10	/* YYYY-MM-DD */
73
#define MAX_TIME_WIDTH		23	/* -DDDDDD HH:MM:SS.###### */
74
#define MAX_DATETIME_FULL_WIDTH 29	/* YYYY-MM-DD HH:MM:SS.###### AM */
75
#define MAX_DATETIME_WIDTH	19	/* YYYY-MM-DD HH:MM:SS */
76
#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
77
78
#define MAX_TABLES	(sizeof(table_map)*8-3)	/* Max tables in join */
79
#define PARAM_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-3))
80
#define OUTER_REF_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-2))
81
#define RAND_TABLE_BIT	(((table_map) 1) << (sizeof(table_map)*8-1))
82
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
83
                           RAND_TABLE_BIT)
84
#define MAX_FIELDS	4096			/* Limit in the .frm file */
85
86
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
87
88
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
89
#define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
90
91
/* Memory allocated when parsing a statement / saving a statement */
92
#define MEM_ROOT_BLOCK_SIZE       8192
93
#define MEM_ROOT_PREALLOC         8192
94
#define TRANS_MEM_ROOT_BLOCK_SIZE 4096
95
#define TRANS_MEM_ROOT_PREALLOC   4096
96
97
#define DEFAULT_ERROR_COUNT	64
98
#define EXTRA_RECORDS	10			/* Extra records in sort */
99
#define SCROLL_EXTRA	5			/* Extra scroll-rows. */
100
#define FIELD_NAME_USED ((uint) 32768)		/* Bit set if fieldname used */
101
#define FIELD_NR_MASK	16383			/* To get fieldnumber */
102
#define FERR		-1			/* Error from my_functions */
103
#define CREATE_MODE	0			/* Default mode on new files */
104
#define NAMES_SEP_CHAR	'\377'			/* Char to sep. names */
105
106
#define READ_RECORD_BUFFER	(uint) (IO_SIZE*8) /* Pointer_buffer_size */
107
#define DISK_BUFFER_SIZE	(uint) (IO_SIZE*16) /* Size of diskbuffer */
108
109
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
110
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
111
#define MYF_RW MYF(MY_WME+MY_NABP)		/* Vid my_read & my_write */
112
113
	/* Extern defines */
114
#define store_record(A,B) memcpy((A)->B,(A)->record[0],(size_t) (A)->s->reclength)
115
#define restore_record(A,B) memcpy((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
116
#define cmp_record(A,B) memcmp((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
117
#define empty_record(A)                                 \
118
  do {                                                  \
119
    restore_record((A),s->default_values);              \
120
    memset((A)->null_flags, 255, (A)->s->null_bytes);   \
121
  } while (0)
122
123
	/* Defines for use with openfrm, openprt and openfrd */
124
125
#define READ_ALL		1	/* openfrm: Read all parameters */
126
#define CHANGE_FRM		2	/* openfrm: open .frm as O_RDWR */
127
#define EXTRA_RECORD		8	/* Reservera plats f|r extra record */
128
#define DONT_GIVE_ERROR		256	/* Don't do frm_error on openfrm  */
129
#define DELAYED_OPEN		4096	/* Open table later */
130
/**
131
  This flag is used in function get_all_tables() which fills
132
  I_S tables with data which are retrieved from frm files and storage engine
133
  The flag means that we need to open FRM file only to get necessary data.
134
*/
135
#define OPEN_FRM_FILE_ONLY     32768
136
/**
137
  This flag is used in function get_all_tables() which fills
138
  I_S tables with data which are retrieved from frm files and storage engine
139
  The flag means that we need to process tables only to get necessary data.
140
  Views are not processed.
141
*/
142
#define OPEN_TABLE_ONLY        OPEN_FRM_FILE_ONLY*2
143
/**
144
  This flag is used in function get_all_tables() which fills
145
  I_S tables with data which are retrieved from frm files and storage engine.
146
  The flag means that I_S table uses optimization algorithm.
147
*/
357 by Brian Aker
flag cleanup
148
#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
149
150
#define SC_INFO_LENGTH 4		/* Form format constant */
151
#define TE_INFO_LENGTH 3
152
#define MTYP_NOEMPTY_BIT 128
153
722.1.3 by Monty Taylor
Cleaned up a few build things.
154
#define FRM_VER 6
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
155
#define FRM_VER_TRUE_VARCHAR (FRM_VER+4) /* 10 */
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
156
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_CGE 50120
157
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM 50205
158
#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
159
160
/*
161
  Minimum length pattern before Turbo Boyer-Moore is used
162
  for SELECT "text" LIKE "%pattern%", excluding the two
163
  wildcards in class Item_func_like.
164
*/
165
#define MIN_TURBOBM_PATTERN_LEN 3
166
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
167
/*
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
168
   Defines for binary logging.
169
   Do not decrease the value of BIN_LOG_HEADER_SIZE.
170
   Do not even increase it before checking code.
171
*/
172
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
173
#define BIN_LOG_HEADER_SIZE    4
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
174
175
#define DEFAULT_KEY_CACHE_NAME "default"
176
177
#define STORAGE_TYPE_MASK 7
178
#define COLUMN_FORMAT_MASK 7
179
#define COLUMN_FORMAT_SHIFT 3
180
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
181
/* Below are #defines that used to be in mysql_priv.h */
182
/***************************************************************************
183
  Configuration parameters
184
****************************************************************************/
185
#define ACL_CACHE_SIZE		256
186
#define MAX_PASSWORD_LENGTH	32
187
#define HOST_CACHE_SIZE		128
188
#define MAX_ACCEPT_RETRY	10	// Test accept this many times
189
#define MAX_FIELDS_BEFORE_HASH	32
190
#define USER_VARS_HASH_SIZE     16
191
#define TABLE_OPEN_CACHE_MIN    64
192
#define TABLE_OPEN_CACHE_DEFAULT 64
193
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
194
/*
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
195
 Value of 9236 discovered through binary search 2006-09-26 on Ubuntu Dapper
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
196
 Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
197
 100 bytes as reasonable buffer against growth and other environments'
198
 requirements.)
199
200
 Feel free to raise this by the smallest amount you can to get the
201
 "execution_constants" test to pass.
202
 */
203
#define STACK_MIN_SIZE          12000   ///< Abort if less stack during eval.
204
205
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
206
#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
207
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
208
/**
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
209
 * @TODO Move into a drizzled.h since it's only used in drizzled.cc
210
 *
211
 * @TODO Rename to DRIZZLED_NET_RETRY_COUNT
212
 */
213
#ifndef MYSQLD_NET_RETRY_COUNT
214
#define MYSQLD_NET_RETRY_COUNT  10	///< Abort read after this many int.
215
#endif
216
#define TEMP_POOL_SIZE          128
217
218
#define QUERY_ALLOC_BLOCK_SIZE		8192
219
#define QUERY_ALLOC_PREALLOC_SIZE   	8192
220
#define TRANS_ALLOC_BLOCK_SIZE		4096
221
#define TRANS_ALLOC_PREALLOC_SIZE	4096
222
#define RANGE_ALLOC_BLOCK_SIZE		4096
223
#define UDF_ALLOC_BLOCK_SIZE		1024
224
#define TABLE_ALLOC_BLOCK_SIZE		1024
225
#define WARN_ALLOC_BLOCK_SIZE		2048
226
#define WARN_ALLOC_PREALLOC_SIZE	1024
227
#define PROFILE_ALLOC_BLOCK_SIZE  2048
228
#define PROFILE_ALLOC_PREALLOC_SIZE 1024
229
230
/*
231
  The following parameters is to decide when to use an extra cache to
232
  optimise seeks when reading a big table in sorted order
233
*/
234
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
235
#define MIN_ROWS_TO_USE_TABLE_CACHE	 100
236
#define MIN_ROWS_TO_USE_BULK_INSERT	 100
237
238
/**
239
  The following is used to decide if MySQL should use table scanning
240
  instead of reading with keys.  The number says how many evaluation of the
241
  WHERE clause is comparable to reading one extra row from a table.
242
*/
243
#define TIME_FOR_COMPARE   5	// 5 compares == one read
244
245
/**
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
246
  Number of comparisons of table rowids equivalent to reading one row from a
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
247
  table.
248
*/
249
#define TIME_FOR_COMPARE_ROWID  (TIME_FOR_COMPARE*2)
250
251
/*
252
  For sequential disk seeks the cost formula is:
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
253
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip
254
255
  The cost of average seek
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
256
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
257
*/
258
#define DISK_SEEK_BASE_COST ((double)0.9)
259
260
#define BLOCKS_IN_AVG_SEEK  128
261
262
#define DISK_SEEK_PROP_COST ((double)0.1/BLOCKS_IN_AVG_SEEK)
263
264
265
/**
266
  Number of rows in a reference table when refereed through a not unique key.
267
  This value is only used when we don't know anything about the key
268
  distribution.
269
*/
270
#define MATCHING_ROWS_IN_OTHER_TABLE 10
271
272
/** Don't pack string keys shorter than this (if PACK_KEYS=1 isn't used). */
273
#define KEY_DEFAULT_PACK_LENGTH 8
274
275
/** Characters shown for the command in 'show processlist'. */
276
#define PROCESS_LIST_WIDTH 100
277
/* Characters shown for the command in 'information_schema.processlist' */
278
#define PROCESS_LIST_INFO_WIDTH 65535
279
280
#define PRECISION_FOR_DOUBLE 53
281
#define PRECISION_FOR_FLOAT  24
282
283
/*
284
  Default time to wait before aborting a new client connection
285
  that does not respond to "initial server greeting" timely
286
*/
287
#define CONNECT_TIMEOUT		10
288
289
/* The following can also be changed from the command line */
290
#define DEFAULT_CONCURRENCY	10
291
#define FLUSH_TIME		0		/**< Don't flush tables */
292
#define MAX_CONNECT_ERRORS	10		///< errors before disabling host
293
294
#define INTERRUPT_PRIOR 10
295
#define CONNECT_PRIOR	9
296
#define WAIT_PRIOR	8
297
#define QUERY_PRIOR	6
298
299
	/* Bits from testflag */
300
#define TEST_PRINT_CACHED_TABLES 1
301
#define TEST_NO_KEY_GROUP	 2
302
#define TEST_MIT_THREAD		4
303
#define TEST_KEEP_TMP_TABLES	16
304
#define TEST_READCHECK		64	/**< Force use of readcheck */
305
#define TEST_NO_EXTRA		128
306
#define TEST_CORE_ON_SIGNAL	256	/**< Give core if signal */
307
#define TEST_NO_STACKTRACE	512
308
#define TEST_SIGINT		1024	/**< Allow sigint on threads */
309
#define TEST_SYNCHRONIZATION    2048    /**< get server to do sleep in some places */
310
311
/* Bits for different SQL modes modes (including ANSI mode) */
361 by Brian Aker
One more mode down, two more left to go!
312
#define MODE_NO_ZERO_DATE		(2)
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
313
#define MODE_INVALID_DATES		(MODE_NO_ZERO_DATE*2)
314
315
/* @@optimizer_switch flags */
316
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
317
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
318
319
#define MY_CHARSET_BIN_MB_MAXLEN 1
320
321
// uncachable cause
322
#define UNCACHEABLE_DEPENDENT   1
323
#define UNCACHEABLE_RAND        2
324
#define UNCACHEABLE_SIDEEFFECT	4
325
/// forcing to save JOIN for explain
326
#define UNCACHEABLE_EXPLAIN     8
327
/** Don't evaluate subqueries in prepare even if they're not correlated */
328
#define UNCACHEABLE_PREPARE    16
329
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
330
#define UNCACHEABLE_UNITED     32
331
332
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
333
#define UNDEF_POS (-1)
334
335
/* BINLOG_DUMP options */
336
337
#define BINLOG_DUMP_NON_BLOCK   1
338
339
/* sql_show.cc:show_log_files() */
340
#define SHOW_LOG_STATUS_FREE "FREE"
341
#define SHOW_LOG_STATUS_INUSE "IN USE"
342
343
/* Options to add_table_to_list() */
344
#define TL_OPTION_UPDATING	1
345
#define TL_OPTION_FORCE_INDEX	2
346
#define TL_OPTION_IGNORE_LEAVES 4
347
#define TL_OPTION_ALIAS         8
348
349
/* Some portable defines */
350
351
#define portable_sizeof_char_ptr 8
352
584.2.1 by Stewart Smith
convert tmp_file_prefix to TMP_FILE_PREFIX to indicate it's a macro
353
#define TMP_FILE_PREFIX "#sql"			/**< Prefix for tmp tables */
354
#define TMP_FILE_PREFIX_LENGTH 4
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
355
356
/* Flags for calc_week() function.  */
357
#define WEEK_MONDAY_FIRST    1
358
#define WEEK_YEAR            2
359
#define WEEK_FIRST_WEEKDAY   4
360
574.3.17 by Lee
moving functions from item_timefunc to functions/time directory
361
/* used in date and time conversions */
362
/* Daynumber from year 0 to 9999-12-31 */
363
#define MAX_DAY_NUMBER 3652424L
364
243.1.14 by Jay Pipes
* Ensured all drizzled/field/x.cc files to include mysql_priv.h
365
#define STRING_BUFFER_USUAL_SIZE 80
366
367
/*
368
  Some defines for exit codes for ::is_equal class functions.
369
*/
370
#define IS_EQUAL_NO 0
371
#define IS_EQUAL_YES 1
372
#define IS_EQUAL_PACK_LENGTH 2
373
561.1.3 by Monty Taylor
Split some more things out of common_includes.h.
374
375
/**
376
  Query type constants.
377
378
  QT_ORDINARY -- ordinary SQL query.
379
  QT_IS -- SQL query to be shown in INFORMATION_SCHEMA (in utf8 and without
380
  character set introducers).
381
382
  @TODO
383
384
  Move this out of here once Stew's done with UDF breakout.  The following headers need it:
385
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
386
    sql_lex.h --> included by session.h
561.1.3 by Monty Taylor
Split some more things out of common_includes.h.
387
    item.h
388
    table.h
389
    item_func.h
390
    item_subselect.h
391
    item_timefunc.h
392
    item_sum.h
393
    item_cmpfunc.h
394
    item_strfunc.h
395
*/
396
enum enum_query_type
397
{
398
  QT_ORDINARY,
399
  QT_IS
400
};
401
402
403
/**
404
 * @TODO Move to a separate header?
405
 *
406
 * It's needed by item.h and field.h, which are both inter-dependent
407
 * and contain forward declarations of many structs/classes in the
408
 * other header file.
409
 *
410
 * What is needed is a separate header file that is included
411
 * by *both* item.h and field.h to resolve inter-dependencies
412
 *
413
 * But, probably want to hold off on this until Stew finished the UDF cleanup
414
 */
415
enum Derivation
416
{
417
  DERIVATION_IGNORABLE= 5,
418
  DERIVATION_COERCIBLE= 4,
419
  DERIVATION_SYSCONST= 3,
420
  DERIVATION_IMPLICIT= 2,
421
  DERIVATION_NONE= 1,
422
  DERIVATION_EXPLICIT= 0
423
};
424
425
/**
426
 * Opening modes for open_temporary_table and open_table_from_share
427
 *
428
 * @TODO Put this into an appropriate header. It is only needed in:
429
 *
430
 *    table.cc
431
 *    sql_base.cc
432
 */
433
enum open_table_mode
434
{
435
  OTM_OPEN= 0,
436
  OTM_CREATE= 1,
437
  OTM_ALTER= 2
438
};
439
642.1.13 by Lee
remove drizzled/item/timefunc.h, no longer needed
440
441
/**
442
 * used by several functions in functions/time directory
443
 *
444
**/
445
enum date_time_format_types
446
{
447
  TIME_ONLY= 0, TIME_MICROSECOND, DATE_ONLY, DATE_TIME, DATE_TIME_MICROSECOND
448
};
449
450
561.1.3 by Monty Taylor
Split some more things out of common_includes.h.
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_NEEDS_UPGRADE  -10
517
#define HA_ADMIN_NEEDS_ALTER    -11
518
#define HA_ADMIN_NEEDS_CHECK    -12
519
520
521
#define HA_ADD_INDEX                  (0)
522
#define HA_DROP_INDEX                 (1)
523
#define HA_ALTER_INDEX                (2)
524
#define HA_RENAME_INDEX               (3)
525
#define HA_ADD_UNIQUE_INDEX           (4)
526
#define HA_DROP_UNIQUE_INDEX          (5)
527
#define HA_ALTER_UNIQUE_INDEX         (6)
528
#define HA_RENAME_UNIQUE_INDEX        (7)
529
#define HA_ADD_PK_INDEX               (8)
530
#define HA_DROP_PK_INDEX              (9)
531
#define HA_ALTER_PK_INDEX             (10)
532
#define HA_ADD_COLUMN                 (11)
533
#define HA_DROP_COLUMN                (12)
534
#define HA_CHANGE_COLUMN              (13)
535
#define HA_ALTER_COLUMN_NAME          (14)
536
#define HA_ALTER_COLUMN_TYPE          (15)
537
#define HA_ALTER_COLUMN_ORDER         (16)
538
#define HA_ALTER_COLUMN_NULLABLE      (17)
539
#define HA_COLUMN_DEFAULT_VALUE       (18)
540
#define HA_COLUMN_STORAGE             (19)
541
#define HA_COLUMN_FORMAT              (20)
542
#define HA_ADD_FOREIGN_KEY            (21)
543
#define HA_DROP_FOREIGN_KEY           (22)
544
#define HA_ALTER_FOREIGN_KEY          (23)
545
#define HA_ADD_CONSTRAINT             (24)
546
#define HA_CHANGE_CHARACTER_SET       (30)
547
#define HA_SET_DEFAULT_CHARACTER_SET  (31)
548
#define HA_CHANGE_AUTOINCREMENT_VALUE (32)
549
#define HA_ALTER_STORAGE              (33)
550
#define HA_ALTER_TABLESPACE           (34)
551
#define HA_ALTER_ROW_FORMAT           (35)
552
#define HA_RENAME_TABLE               (36)
553
#define HA_ALTER_STORAGE_ENGINE       (37)
554
#define HA_RECREATE                   (38)
555
#define HA_ALTER_STORED_VCOL          (39)
556
/* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
557
558
/* Return values for check_if_supported_alter */
559
560
#define HA_ALTER_ERROR               -1
561
#define HA_ALTER_SUPPORTED_WAIT_LOCK  0
562
#define HA_ALTER_SUPPORTED_NO_LOCK    1
563
#define HA_ALTER_NOT_SUPPORTED        2
564
565
/* Bits in table_flags() to show what database can do */
566
567
#define HA_NO_TRANSACTIONS     (1 << 0) /* Doesn't support transactions */
568
#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */
569
#define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */
570
/*
571
  The following should be set if the following is not true when scanning
572
  a table with rnd_next()
573
  - We will see all rows (including deleted ones)
574
  - Row positions are 'table->s->db_record_offset' apart
575
  If this flag is not set, filesort will do a postion() call for each matched
576
  row to be able to find the row later.
577
*/
578
#define HA_REC_NOT_IN_SEQ      (1 << 3)
579
580
/*
581
  Reading keys in random order is as fast as reading keys in sort order
582
  (Used in records.cc to decide if we should use a record cache and by
583
  filesort to decide if we should sort key + data or key + pointer-to-row
584
*/
585
#define HA_FAST_KEY_READ       (1 << 5)
586
/*
587
  Set the following flag if we on delete should force all key to be read
588
  and on update read all keys that changes
589
*/
590
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6)
591
#define HA_NULL_IN_KEY         (1 << 7) /* One can have keys with NULL */
592
#define HA_DUPLICATE_POS       (1 << 8)    /* ha_position() gives dup row */
593
#define HA_NO_BLOBS            (1 << 9) /* Doesn't support blobs */
594
#define HA_CAN_INDEX_BLOBS     (1 << 10)
595
#define HA_AUTO_PART_KEY       (1 << 11) /* auto-increment in multi-part key */
596
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */
597
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */
598
/*
599
  If we get the primary key columns for free when we do an index read
600
  It also implies that we have to retrive the primary key when using
601
  position() and rnd_pos().
602
*/
603
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
604
/*
605
  If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
606
  uses a primary key. Without primary key, we can't call position().
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
607
*/
608
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16)
520.8.6 by Monty Taylor
Removed handler from common_includes.
609
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
610
/*
611
  The following is we need to a primary key to delete (and update) a row.
612
  If there is no primary key, all columns needs to be read on update and delete
613
*/
614
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
615
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
616
#define HA_NO_AUTO_INCREMENT   (1 << 23)
617
#define HA_HAS_CHECKSUM        (1 << 24)
618
/* Table data are stored in separate files (for lower_case_table_names) */
619
#define HA_FILE_BASED	       (1 << 26)
620
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
621
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
622
#define HA_NO_COPY_ON_ALTER    (INT64_C(1) << 31)
623
#define HA_HAS_RECORDS	       (INT64_C(1) << 32) /* records() gives exact count*/
624
#define HA_MRR_CANT_SORT       (INT64_C(1) << 34)
625
626
/*
627
  Engine is capable of row-format and statement-format logging,
628
  respectively
629
*/
630
#define HA_BINLOG_ROW_CAPABLE  (INT64_C(1) << 35)
631
#define HA_BINLOG_STMT_CAPABLE (INT64_C(1) << 36)
632
633
#define HA_ONLINE_ALTER        (INT64_C(1) << 37)
634
635
/*
636
  Set of all binlog flags. Currently only contain the capabilities
637
  flags.
638
 */
639
#define HA_BINLOG_FLAGS (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE)
640
641
/* bits in index_flags(index_number) for what you can do with index */
642
#define HA_READ_NEXT            1       /* TODO really use this flag */
643
#define HA_READ_PREV            2       /* supports ::index_prev */
644
#define HA_READ_ORDER           4       /* index_next/prev follow sort order */
645
#define HA_READ_RANGE           8       /* can find all records in a range */
646
#define HA_ONLY_WHOLE_INDEX	16	/* Can't use part key searches */
647
#define HA_KEYREAD_ONLY         64	/* Support HA_EXTRA_KEYREAD */
648
/*
649
  Index scan will not return records in rowid order. Not guaranteed to be
650
  set for unordered (e.g. HASH) indexes.
651
*/
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
652
#define HA_KEY_SCAN_NOT_ROR     128
520.8.6 by Monty Taylor
Removed handler from common_includes.
653
#define HA_DO_INDEX_COND_PUSHDOWN  256 /* Supports Index Condition Pushdown */
654
655
/* operations for disable/enable indexes */
656
#define HA_KEY_SWITCH_NONUNIQ      0
657
#define HA_KEY_SWITCH_ALL          1
658
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
659
#define HA_KEY_SWITCH_ALL_SAVE     3
660
661
/*
662
  Note: the following includes binlog and closing 0.
663
  so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
664
      example + csv + heap + blackhole + federated + 0
665
  (yes, the sum is deliberately inaccurate)
666
  TODO remove the limit, use dynarrays
667
*/
668
#define MAX_HA 15
669
670
/*
671
  Parameters for open() (in register form->filestat)
672
  HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
673
*/
674
675
#define HA_OPEN_KEYFILE		1
676
#define HA_OPEN_RNDFILE		2
677
#define HA_GET_INDEX		4
678
#define HA_GET_INFO		8	/* do a ha_info() after open */
679
#define HA_READ_ONLY		16	/* File opened as readonly */
680
/* Try readonly if can't open with read and write */
681
#define HA_TRY_READ_ONLY	32
682
#define HA_WAIT_IF_LOCKED	64	/* Wait if locked on open */
683
#define HA_ABORT_IF_LOCKED	128	/* skip if locked on open.*/
684
#define HA_BLOCK_LOCK		256	/* unlock when reading some records */
685
#define HA_OPEN_TEMPORARY	512
686
687
/* For transactional LOCK Table. handler::lock_table() */
688
#define HA_LOCK_IN_SHARE_MODE      F_RDLCK
689
#define HA_LOCK_IN_EXCLUSIVE_MODE  F_WRLCK
690
691
/* Some key definitions */
692
#define HA_KEY_NULL_LENGTH	1
693
#define HA_KEY_BLOB_LENGTH	2
694
695
#define HA_LEX_CREATE_TMP_TABLE	1
696
#define HA_LEX_CREATE_IF_NOT_EXISTS 2
697
#define HA_LEX_CREATE_TABLE_LIKE 4
698
#define HA_OPTION_NO_CHECKSUM	(1L << 17)
699
#define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18)
700
#define HA_MAX_REC_LENGTH	65535
701
702
/* Table caching type */
703
#define HA_CACHE_TBL_NONTRANSACT 0
704
#define HA_CACHE_TBL_NOCACHE     1
705
#define HA_CACHE_TBL_ASKTRANSACT 2
706
#define HA_CACHE_TBL_TRANSACT    4
707
708
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
709
#define DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
710
711
/* Flags for method is_fatal_error */
712
#define HA_CHECK_DUP_KEY 1
713
#define HA_CHECK_DUP_UNIQUE 2
714
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
715
716
enum legacy_db_type
717
{
718
  DB_TYPE_UNKNOWN=0,
719
  DB_TYPE_FIRST_DYNAMIC=42,
720
  DB_TYPE_DEFAULT=127 // Must be last
721
};
722
723
enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED,
724
		ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED,
725
		ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGE };
726
727
enum column_format_type { COLUMN_FORMAT_TYPE_NOT_USED= -1,
728
                          COLUMN_FORMAT_TYPE_DEFAULT=   0,
729
                          COLUMN_FORMAT_TYPE_FIXED=     1,
730
                          COLUMN_FORMAT_TYPE_DYNAMIC=   2 };
731
732
enum enum_binlog_func {
733
  BFN_RESET_LOGS=        1,
734
  BFN_RESET_SLAVE=       2,
735
  BFN_BINLOG_WAIT=       3,
736
  BFN_BINLOG_END=        4,
737
  BFN_BINLOG_PURGE_FILE= 5
738
};
739
740
enum enum_binlog_command {
741
  LOGCOM_CREATE_TABLE,
742
  LOGCOM_ALTER_TABLE,
743
  LOGCOM_RENAME_TABLE,
744
  LOGCOM_DROP_TABLE,
745
  LOGCOM_CREATE_DB,
746
  LOGCOM_ALTER_DB,
747
  LOGCOM_DROP_DB
748
};
749
750
/* struct to hold information about the table that should be created */
751
752
/* Bits in used_fields */
753
#define HA_CREATE_USED_AUTO             (1L << 0)
754
#ifdef DEAD_OPTIONS
755
#define HA_CREATE_USED_UNION            (1L << 2)
756
#define HA_CREATE_USED_PASSWORD         (1L << 17)
757
#endif
758
#define HA_CREATE_USED_INSERT_METHOD    (1L << 3)
759
#define HA_CREATE_USED_MIN_ROWS         (1L << 4)
760
#define HA_CREATE_USED_MAX_ROWS         (1L << 5)
761
#define HA_CREATE_USED_AVG_ROW_LENGTH   (1L << 6)
762
#define HA_CREATE_USED_PACK_KEYS        (1L << 7)
763
#define HA_CREATE_USED_CHARSET          (1L << 8)
764
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
765
#define HA_CREATE_USED_DATADIR          (1L << 10)
766
#define HA_CREATE_USED_INDEXDIR         (1L << 11)
767
#define HA_CREATE_USED_ENGINE           (1L << 12)
768
#define HA_CREATE_USED_CHECKSUM         (1L << 13)
769
#define HA_CREATE_USED_DELAY_KEY_WRITE  (1L << 14)
770
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
771
#define HA_CREATE_USED_COMMENT          (1L << 16)
772
#define HA_CREATE_USED_CONNECTION       (1L << 18)
773
#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)
774
#define HA_CREATE_USED_PAGE_CHECKSUM    (1L << 21)
775
#define HA_CREATE_USED_BLOCK_SIZE       (1L << 22)
776
777
#define MAXGTRIDSIZE 64
778
#define MAXBQUALSIZE 64
779
780
#define COMPATIBLE_DATA_YES 0
781
#define COMPATIBLE_DATA_NO  1
782
783
#define UNDEF_NODEGROUP 65535
784
#define NOT_A_PARTITION_ID ((uint32_t)-1)
785
786
enum ha_choice { HA_CHOICE_UNDEF, HA_CHOICE_NO, HA_CHOICE_YES };
787
788
/*
789
  The below two are not used (and not handled) in this milestone of this WL
790
  entry because there seems to be no use for them at this stage of
791
  implementation.
792
*/
793
#define HA_MRR_SINGLE_POINT 1
794
#define HA_MRR_FIXED_KEY  2
795
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
796
/*
520.8.6 by Monty Taylor
Removed handler from common_includes.
797
  Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
798
  'range' parameter.
799
*/
800
#define HA_MRR_NO_ASSOCIATION 4
801
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
802
/*
520.8.6 by Monty Taylor
Removed handler from common_includes.
803
  The MRR user will provide ranges in key order, and MRR implementation
804
  must return rows in key order.
805
*/
806
#define HA_MRR_SORTED 8
807
808
/* MRR implementation doesn't have to retrieve full records */
809
#define HA_MRR_INDEX_ONLY 16
810
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
811
/*
520.8.6 by Monty Taylor
Removed handler from common_includes.
812
  The passed memory buffer is of maximum possible size, the caller can't
813
  assume larger buffer.
814
*/
815
#define HA_MRR_LIMITS 32
816
817
818
/*
819
  Flag set <=> default MRR implementation is used
820
  (The choice is made by **_info[_const]() function which may set this
821
   flag. SQL layer remembers the flag value and then passes it to
822
   multi_read_range_init().
823
*/
824
#define HA_MRR_USE_DEFAULT_IMPL 64
825
826
/*
827
  Used only as parameter to multi_range_read_info():
828
  Flag set <=> the caller guarantees that the bounds of the scanned ranges
829
  will not have NULL values.
830
*/
831
#define HA_MRR_NO_NULL_ENDPOINTS 128
832
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
833
enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY, RNEXT_SAME };
834
835
enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED,
836
                         ISO_REPEATABLE_READ, ISO_SERIALIZABLE};
837
838
575.1.5 by Monty Taylor
Moved stuff to handlerton.cc
839
enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
840
575.1.6 by Monty Taylor
Cleaned up some headers for PCH.
841
typedef int myf;
842
#define MYF(v)		(myf) (v)
843
575.4.7 by Monty Taylor
More header cleanup.
844
/*
845
  When a command is added here, be sure it's also added in mysqld.cc
846
  in "struct show_var_st status_vars[]= {" ...
847
848
  If the command returns a result set or is not allowed in stored
849
  functions or triggers, please also make sure that
850
  sp_get_flags_for_command (sp_head.cc) returns proper flags for the
851
  added SQLCOM_.
852
*/
853
854
enum enum_sql_command {
855
  SQLCOM_SELECT, SQLCOM_CREATE_TABLE, SQLCOM_CREATE_INDEX, SQLCOM_ALTER_TABLE,
856
  SQLCOM_UPDATE, SQLCOM_INSERT, SQLCOM_INSERT_SELECT,
857
  SQLCOM_DELETE, SQLCOM_TRUNCATE, SQLCOM_DROP_TABLE, SQLCOM_DROP_INDEX,
858
  SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS,
859
  SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_STATUS,
860
  SQLCOM_SHOW_ENGINE_LOGS, SQLCOM_SHOW_ENGINE_STATUS, SQLCOM_SHOW_ENGINE_MUTEX,
861
  SQLCOM_SHOW_PROCESSLIST, SQLCOM_SHOW_MASTER_STAT, SQLCOM_SHOW_SLAVE_STAT,
862
  SQLCOM_SHOW_CREATE,
863
  SQLCOM_SHOW_CREATE_DB,
864
  SQLCOM_SHOW_TABLE_STATUS,
865
  SQLCOM_LOAD,SQLCOM_SET_OPTION,SQLCOM_LOCK_TABLES,SQLCOM_UNLOCK_TABLES,
866
  SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB, SQLCOM_ALTER_DB,
867
  SQLCOM_REPAIR, SQLCOM_REPLACE, SQLCOM_REPLACE_SELECT,
868
  SQLCOM_OPTIMIZE, SQLCOM_CHECK,
869
  SQLCOM_ASSIGN_TO_KEYCACHE,
870
  SQLCOM_FLUSH, SQLCOM_KILL, SQLCOM_ANALYZE,
871
  SQLCOM_ROLLBACK, SQLCOM_ROLLBACK_TO_SAVEPOINT,
872
  SQLCOM_COMMIT, SQLCOM_SAVEPOINT, SQLCOM_RELEASE_SAVEPOINT,
873
  SQLCOM_SLAVE_START, SQLCOM_SLAVE_STOP,
874
  SQLCOM_BEGIN, SQLCOM_CHANGE_MASTER,
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
875
  SQLCOM_RENAME_TABLE,
575.4.7 by Monty Taylor
More header cleanup.
876
  SQLCOM_RESET, SQLCOM_PURGE, SQLCOM_PURGE_BEFORE, SQLCOM_SHOW_BINLOGS,
877
  SQLCOM_SHOW_OPEN_TABLES,
878
  SQLCOM_DELETE_MULTI, SQLCOM_UPDATE_MULTI,
879
  SQLCOM_SHOW_WARNS,
880
  SQLCOM_EMPTY_QUERY,
881
  SQLCOM_SHOW_ERRORS,
882
  SQLCOM_CHECKSUM,
883
  SQLCOM_BINLOG_BASE64_EVENT,
884
  SQLCOM_SHOW_PLUGINS,
885
  /*
886
    When a command is added here, be sure it's also added in mysqld.cc
887
    in "struct show_var_st status_vars[]= {" ...
888
  */
889
  /* This should be the last !!! */
890
  SQLCOM_END
891
};
892
893
enum enum_duplicates { DUP_ERROR, DUP_REPLACE, DUP_UPDATE };
894
895
enum release_type { RELEASE_NORMAL, RELEASE_WAIT_FOR_DROP };
896
584.1.1 by Monty Taylor
Moved an enum def to fix Lee's problem.
897
/*
898
  Make sure that the order of schema_tables and enum_schema_tables are the same.
899
*/
900
901
enum enum_schema_tables
902
{
903
  SCH_CHARSETS= 0,
904
  SCH_COLLATIONS,
905
  SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
906
  SCH_COLUMNS,
907
  SCH_GLOBAL_STATUS,
908
  SCH_GLOBAL_VARIABLES,
909
  SCH_KEY_COLUMN_USAGE,
910
  SCH_OPEN_TABLES,
911
  SCH_PLUGINS,
912
  SCH_PROCESSLIST,
913
  SCH_REFERENTIAL_CONSTRAINTS,
914
  SCH_SCHEMATA,
915
  SCH_SESSION_STATUS,
916
  SCH_SESSION_VARIABLES,
917
  SCH_STATISTICS,
918
  SCH_STATUS,
919
  SCH_TABLES,
920
  SCH_TABLE_CONSTRAINTS,
921
  SCH_TABLE_NAMES,
922
  SCH_VARIABLES
923
};
924
925
926
#define MY_I_S_MAYBE_NULL 1
927
#define MY_I_S_UNSIGNED   2
928
929
930
#define SKIP_OPEN_TABLE 0                // do not open table
931
#define OPEN_FRM_ONLY   1                // open FRM file only
932
#define OPEN_FULL_TABLE 2                // open FRM,MYD, MYI files
933
584.4.1 by Monty Taylor
Split out DTCollation.
934
/*
935
   "Declared Type Collation"
936
   A combination of collation and its derivation.
937
938
  Flags for collation aggregation modes:
939
  MY_COLL_ALLOW_SUPERSET_CONV  - allow conversion to a superset
940
  MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
941
                                 (i.e. constant).
942
  MY_COLL_ALLOW_CONV           - allow any kind of conversion
943
                                 (combination of the above two)
944
  MY_COLL_DISALLOW_NONE        - don't allow return DERIVATION_NONE
945
                                 (e.g. when aggregating for comparison)
946
  MY_COLL_CMP_CONV             - combination of MY_COLL_ALLOW_CONV
947
                                 and MY_COLL_DISALLOW_NONE
948
*/
949
950
#define MY_COLL_ALLOW_SUPERSET_CONV   1
951
#define MY_COLL_ALLOW_COERCIBLE_CONV  2
952
#define MY_COLL_ALLOW_CONV            3
953
#define MY_COLL_DISALLOW_NONE         4
954
#define MY_COLL_CMP_CONV              7
955
584.1.1 by Monty Taylor
Moved an enum def to fix Lee's problem.
956
584.4.2 by Monty Taylor
Split out hybrid_type_traits.
957
/*
958
  This enum is used to report information about monotonicity of function
959
  represented by Item* tree.
960
  Monotonicity is defined only for Item* trees that represent table
961
  partitioning expressions (i.e. have no subselects/user vars/PS parameters
962
  etc etc). An Item* tree is assumed to have the same monotonicity properties
963
  as its correspoinding function F:
964
965
  [signed] int64_t F(field1, field2, ...) {
966
    put values of field_i into table record buffer;
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
967
    return item->val_int();
584.4.2 by Monty Taylor
Split out hybrid_type_traits.
968
  }
969
970
  NOTE
971
  At the moment function monotonicity is not well defined (and so may be
972
  incorrect) for Item trees with parameters/return types that are different
973
  from INT_RESULT, may be NULL, or are unsigned.
974
  It will be possible to address this issue once the related partitioning bugs
975
  (BUG#16002, BUG#15447, BUG#13436) are fixed.
976
*/
977
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
978
typedef enum monotonicity_info
584.4.2 by Monty Taylor
Split out hybrid_type_traits.
979
{
980
   NON_MONOTONIC,              /* none of the below holds */
981
   MONOTONIC_INCREASING,       /* F() is unary and (x < y) => (F(x) <= F(y)) */
982
   MONOTONIC_STRICT_INCREASING /* F() is unary and (x < y) => (F(x) <  F(y)) */
983
} enum_monotonicity_info;
984
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
985
enum tmp_table_type
986
{
987
  NO_TMP_TABLE, NON_TRANSACTIONAL_TMP_TABLE, TRANSACTIONAL_TMP_TABLE,
988
  INTERNAL_TMP_TABLE, SYSTEM_TMP_TABLE, TMP_TABLE_FRM_FILE_ONLY
989
};
990
991
/*
992
  Values in this enum are used to indicate how a tables TIMESTAMP field
993
  should be treated. It can be set to the current timestamp on insert or
994
  update or both.
995
  WARNING: The values are used for bit operations. If you change the
996
  enum, you must keep the bitwise relation of the values. For example:
997
  (int) TIMESTAMP_AUTO_SET_ON_BOTH must be equal to
998
  (int) TIMESTAMP_AUTO_SET_ON_INSERT | (int) TIMESTAMP_AUTO_SET_ON_UPDATE.
999
  We use an enum here so that the debugger can display the value names.
1000
*/
1001
enum timestamp_auto_set_type
1002
{
1003
  TIMESTAMP_NO_AUTO_SET= 0, TIMESTAMP_AUTO_SET_ON_INSERT= 1,
1004
  TIMESTAMP_AUTO_SET_ON_UPDATE= 2, TIMESTAMP_AUTO_SET_ON_BOTH= 3
1005
};
1006
#define clear_timestamp_auto_bits(_target_, _bits_) \
1007
  (_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
1008
1009
/**
1010
  Category of table found in the table share.
1011
*/
1012
enum enum_table_category
1013
{
1014
  /**
1015
    Unknown value.
1016
  */
1017
  TABLE_UNKNOWN_CATEGORY=0,
1018
1019
  /**
1020
    Temporary table.
1021
    The table is visible only in the session.
1022
    Therefore,
1023
    - FLUSH TABLES WITH READ LOCK
1024
    - SET GLOBAL READ_ONLY = ON
1025
    do not apply to this table.
1026
    Note that LOCK Table t FOR READ/WRITE
1027
    can be used on temporary tables.
1028
    Temporary tables are not part of the table cache.
1029
  */
1030
  TABLE_CATEGORY_TEMPORARY=1,
1031
1032
  /**
1033
    User table.
1034
    These tables do honor:
1035
    - LOCK Table t FOR READ/WRITE
1036
    - FLUSH TABLES WITH READ LOCK
1037
    - SET GLOBAL READ_ONLY = ON
1038
    User tables are cached in the table cache.
1039
  */
1040
  TABLE_CATEGORY_USER=2,
1041
1042
  /**
1043
    Information schema tables.
1044
    These tables are an interface provided by the system
1045
    to inspect the system metadata.
1046
    These tables do *not* honor:
1047
    - LOCK Table t FOR READ/WRITE
1048
    - FLUSH TABLES WITH READ LOCK
1049
    - SET GLOBAL READ_ONLY = ON
1050
    as there is no point in locking explicitely
1051
    an INFORMATION_SCHEMA table.
1052
    Nothing is directly written to information schema tables.
1053
    Note that this value is not used currently,
1054
    since information schema tables are not shared,
1055
    but implemented as session specific temporary tables.
1056
  */
1057
  /*
1058
    TODO: Fixing the performance issues of I_S will lead
1059
    to I_S tables in the table cache, which should use
1060
    this table type.
1061
  */
1062
  TABLE_CATEGORY_INFORMATION
1063
};
1064
1065
/* Information for one open table */
1066
enum index_hint_type
1067
{
1068
  INDEX_HINT_IGNORE,
1069
  INDEX_HINT_USE,
1070
  INDEX_HINT_FORCE
1071
};
1072
584.4.2 by Monty Taylor
Split out hybrid_type_traits.
1073
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
1074
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
1075
enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON,
1076
                            DELAY_KEY_WRITE_ALL };
1077
enum enum_slave_exec_mode { SLAVE_EXEC_MODE_STRICT,
1078
                            SLAVE_EXEC_MODE_IDEMPOTENT,
1079
                            SLAVE_EXEC_MODE_LAST_BIT};
1080
enum enum_mark_columns
1081
{ MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE};
1082
1083
enum enum_filetype { FILETYPE_CSV, FILETYPE_XML };
1084
1085
enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND,
1086
                                  IGNORE_ERRORS, REPORT_EXCEPT_NON_UNIQUE,
1087
                                  IGNORE_EXCEPT_NON_UNIQUE};
1088
1089
enum enum_schema_table_state
1090
{
1091
  NOT_PROCESSED= 0,
1092
  PROCESSED_BY_CREATE_SORT_INDEX,
1093
  PROCESSED_BY_JOIN_EXEC
1094
};
1095
584.5.1 by Monty Taylor
Removed field includes from field.h.
1096
/*
1097
 * The following are for the interface with the .frm file
1098
 */
1099
1100
#define FIELDFLAG_DECIMAL    1
1101
#define FIELDFLAG_BINARY    1  // Shares same flag
1102
#define FIELDFLAG_NUMBER    2
1103
#define FIELDFLAG_DECIMAL_POSITION      4
1104
#define FIELDFLAG_PACK      120  // Bits used for packing
1105
#define FIELDFLAG_INTERVAL    256     // mangled with decimals!
1106
#define FIELDFLAG_BLOB      1024  // mangled with decimals!
1107
1108
#define FIELDFLAG_NO_DEFAULT    16384   /* sql */
1109
#define FIELDFLAG_SUM      ((uint32_t) 32768)// predit: +#fieldflag
1110
#define FIELDFLAG_MAYBE_NULL    ((uint32_t) 32768)// sql
1111
#define FIELDFLAG_HEX_ESCAPE    ((uint32_t) 0x10000)
1112
#define FIELDFLAG_PACK_SHIFT    3
1113
#define FIELDFLAG_DEC_SHIFT    8
1114
#define FIELDFLAG_MAX_DEC    31
1115
1116
#define MTYP_TYPENR(type) (type & 127)  /* Remove bits from type */
1117
1118
#define f_is_dec(x)     ((x) & FIELDFLAG_DECIMAL)
1119
#define f_is_num(x)     ((x) & FIELDFLAG_NUMBER)
1120
#define f_is_decimal_precision(x)  ((x) & FIELDFLAG_DECIMAL_POSITION)
1121
#define f_is_packed(x)  ((x) & FIELDFLAG_PACK)
1122
#define f_packtype(x)   (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
1123
#define f_decimals(x)   ((uint8_t) (((x) >> FIELDFLAG_DEC_SHIFT) & \
1124
                                     FIELDFLAG_MAX_DEC))
1125
#define f_is_alpha(x)   (!f_is_num(x))
1126
#define f_is_binary(x)  ((x) & FIELDFLAG_BINARY) // 4.0- compatibility
1127
#define f_is_enum(x)    (((x) & (FIELDFLAG_INTERVAL | FIELDFLAG_NUMBER)) == \
1128
                         FIELDFLAG_INTERVAL)
1129
#define f_is_blob(x)    (((x) & (FIELDFLAG_BLOB | FIELDFLAG_NUMBER)) == \
1130
                         FIELDFLAG_BLOB)
1131
#define f_is_equ(x)     ((x) & (1+2+FIELDFLAG_PACK+31*256))
1132
#define f_settype(x)    (((int) x) << FIELDFLAG_PACK_SHIFT)
1133
#define f_maybe_null(x) (x & FIELDFLAG_MAYBE_NULL)
1134
#define f_no_default(x) (x & FIELDFLAG_NO_DEFAULT)
1135
#define f_is_hex_escape(x) ((x) & FIELDFLAG_HEX_ESCAPE)
1136
243.1.12 by Jay Pipes
* Added drizzled/definitions.h which contains many of the #defines from
1137
#endif /* DRIZZLE_SERVER_DEFINITIONS_H */
575.4.7 by Monty Taylor
More header cleanup.
1138