1
/* Copyright (C) 2000-2006 MySQL AB
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.
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.
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 */
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
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.
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.
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
20
* Mostly constants and some macros/functions used by the server
23
* Mostly constants and some macros/functions used by the server
23
#ifndef DRIZZLE_SERVER_DEFINITIONS_H
24
#define DRIZZLE_SERVER_DEFINITIONS_H
27
#define NO_ALARM_LOOP /* lib5 and popen can't use alarm */
26
#ifndef DRIZZLED_DEFINITIONS_H
27
#define DRIZZLED_DEFINITIONS_H
29
#include <drizzled/enum.h>
30
33
/* These paths are converted to other systems (WIN95) before use */
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/"
38
#define DATADIR "data/"
41
#define SHAREDIR "share/"
44
#define PLUGINDIR "lib/plugin"
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"))
50
#define ERRMAPP 1 /* Errormap f|r my_error */
40
#define ER(X) error_message((X))
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)
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 */
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 */
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 */
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 */
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) \
140
restore_record((A),s->default_values); \
141
memset((A)->null_flags, 255, (A)->s->null_bytes); \
144
104
/* Defines for use with openfrm, openprt and openfrd */
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 */
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
343
251
#define WAIT_PRIOR 8
344
252
#define QUERY_PRIOR 6
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 */
360
/* The rest of the file is included in the server only */
361
#ifndef DRIZZLE_CLIENT
254
/* Bits from testflag */
257
TEST_PRINT_CACHED_TABLES= 1,
260
TEST_KEEP_TMP_TABLES,
261
TEST_READCHECK, /**< Force use of readcheck */
263
TEST_CORE_ON_SIGNAL, /**< Give core if signal */
265
TEST_SIGINT, /**< Allow sigint on threads */
266
TEST_SYNCHRONIZATION /**< get server to do sleep in some places */
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)
397
273
/* @@optimizer_switch flags */
398
274
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
399
275
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
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).
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
412
#define RAID_BLOCK_SIZE 1024
414
277
#define MY_CHARSET_BIN_MB_MAXLEN 1
416
279
// uncachable cause
463
326
#define IS_EQUAL_PACK_LENGTH 2
466
#endif /* DRIZZLE_SERVER_DEFINITIONS_H */
329
typedef uint64_t query_id_t;
330
typedef void *range_seq_t;
332
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
333
// the following is for checking tables
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
349
/* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
351
/* Return values for check_if_supported_alter */
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
358
/* Bits in table_flags() to show what database can do */
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 */
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.
371
#define HA_REC_NOT_IN_SEQ (1 << 3)
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
378
#define HA_FAST_KEY_READ (1 << 5)
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
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 */
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().
396
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
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().
401
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16)
402
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
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
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)
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 */
424
Index scan will not return records in rowid order. Not guaranteed to be
425
set for unordered (e.g. HASH) indexes.
427
#define HA_KEY_SCAN_NOT_ROR 128
428
#define HA_DO_INDEX_COND_PUSHDOWN 256 /* Supports Index Condition Pushdown */
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
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
446
Parameters for open() (in register form->filestat)
447
HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
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
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
466
/* Some key definitions */
467
#define HA_KEY_NULL_LENGTH 1
468
#define HA_KEY_BLOB_LENGTH 2
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
476
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
477
#define DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
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)
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)
495
#define MAXGTRIDSIZE 64
496
#define MAXBQUALSIZE 64
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
503
#define HA_MRR_SINGLE_POINT 1
504
#define HA_MRR_FIXED_KEY 2
507
Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
510
#define HA_MRR_NO_ASSOCIATION 4
513
The MRR user will provide ranges in key order, and MRR implementation
514
must return rows in key order.
516
#define HA_MRR_SORTED 8
518
/* MRR implementation doesn't have to retrieve full records */
519
#define HA_MRR_INDEX_ONLY 16
522
The passed memory buffer is of maximum possible size, the caller can't
523
assume larger buffer.
525
#define HA_MRR_LIMITS 32
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().
534
#define HA_MRR_USE_DEFAULT_IMPL 64
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.
541
#define HA_MRR_NO_NULL_ENDPOINTS 128
544
#define MYF(v) (myf) (v)
546
#define MY_I_S_MAYBE_NULL 1
547
#define MY_I_S_UNSIGNED 2
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
555
"Declared Type Collation"
556
A combination of collation and its derivation.
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
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
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_))
579
* The following are for the interface with the .frm file
582
#define FIELDFLAG_PACK_SHIFT 3
583
#define FIELDFLAG_MAX_DEC 31
585
#define MTYP_TYPENR(type) (type & 127) /* Remove bits from type */
587
#define f_packtype(x) (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
588
#define f_settype(x) (((int) x) << FIELDFLAG_PACK_SHIFT)
590
#endif /* DRIZZLED_DEFINITIONS_H */