~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definitions.h

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
 
20
 
20
21
/**
21
22
 * @file
22
23
 *
23
 
 * Mostly constants and some macros/functions used by the server
 
24
 * Mostly constants and some macros/functions used by the server  
24
25
 */
25
26
 
26
27
#ifndef DRIZZLE_SERVER_DEFINITIONS_H
27
28
#define DRIZZLE_SERVER_DEFINITIONS_H
28
29
 
29
 
#include <stdint.h>
30
 
 
31
30
#ifndef NO_ALARM_LOOP
32
31
#define NO_ALARM_LOOP           /* lib5 and popen can't use alarm */
33
32
#endif
39
38
#define TEMP_PREFIX     "MY"
40
39
#define LOG_PREFIX      "ML"
41
40
#define PROGDIR         "bin/"
42
 
 
43
 
#define ER(X) error_message((X))
44
 
 
 
41
#ifndef DATADIR
 
42
#define DATADIR         "data/"
 
43
#endif
 
44
#ifndef SHAREDIR
 
45
#define SHAREDIR        "share/"
 
46
#endif
 
47
#ifndef PLUGINDIR
 
48
#define PLUGINDIR       "lib/plugin"
 
49
#endif
 
50
 
 
51
#define ER(X) _(drizzled_error_messages[(X) - ER_ERROR_FIRST])
 
52
#define ER_SAFE(X) (((X) >= ER_ERROR_FIRST && (X) <= ER_ERROR_LAST) ? ER(X) : _("Invalid error code"))
 
53
 
 
54
#define ERRMAPP 1                               /* Errormap f|r my_error */
45
55
#define LIBLEN FN_REFLEN-FN_LEN                 /* Max l{ngd p} dev */
46
56
/* extra 4+4 bytes for slave tmp tables */
47
57
#define MAX_DBKEY_LENGTH (NAME_LEN*2+1+1+4+4)
98
108
#define EXTRA_RECORDS   10                      /* Extra records in sort */
99
109
#define SCROLL_EXTRA    5                       /* Extra scroll-rows. */
100
110
#define FIELD_NAME_USED ((uint) 32768)          /* Bit set if fieldname used */
 
111
#define FORM_NAME_USED  ((uint) 16384)          /* Bit set if formname used */
101
112
#define FIELD_NR_MASK   16383                   /* To get fieldnumber */
102
113
#define FERR            -1                      /* Error from my_functions */
103
114
#define CREATE_MODE     0                       /* Default mode on new files */
151
162
#define TE_INFO_LENGTH 3
152
163
#define MTYP_NOEMPTY_BIT 128
153
164
 
154
 
#define FRM_VER 6
155
165
#define FRM_VER_TRUE_VARCHAR (FRM_VER+4) /* 10 */
156
166
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_CGE 50120
157
167
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM 50205
164
174
*/
165
175
#define MIN_TURBOBM_PATTERN_LEN 3
166
176
 
167
 
/*
 
177
/* 
168
178
   Defines for binary logging.
169
179
   Do not decrease the value of BIN_LOG_HEADER_SIZE.
170
180
   Do not even increase it before checking code.
171
181
*/
172
182
 
173
 
#define BIN_LOG_HEADER_SIZE    4
 
183
#define BIN_LOG_HEADER_SIZE    4 
174
184
 
175
185
#define DEFAULT_KEY_CACHE_NAME "default"
176
186
 
182
192
/***************************************************************************
183
193
  Configuration parameters
184
194
****************************************************************************/
 
195
#define ACL_CACHE_SIZE          256
185
196
#define MAX_PASSWORD_LENGTH     32
 
197
#define HOST_CACHE_SIZE         128
186
198
#define MAX_ACCEPT_RETRY        10      // Test accept this many times
187
199
#define MAX_FIELDS_BEFORE_HASH  32
188
200
#define USER_VARS_HASH_SIZE     16
189
201
#define TABLE_OPEN_CACHE_MIN    64
190
 
#define TABLE_OPEN_CACHE_DEFAULT 1024
 
202
#define TABLE_OPEN_CACHE_DEFAULT 64
191
203
 
192
 
/*
 
204
/* 
193
205
 Value of 9236 discovered through binary search 2006-09-26 on Ubuntu Dapper
194
 
 Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added
 
206
 Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86.  (Added 
195
207
 100 bytes as reasonable buffer against growth and other environments'
196
208
 requirements.)
197
209
 
203
215
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
204
216
#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
205
217
 
206
 
/**
 
218
/** 
207
219
 * @TODO Move into a drizzled.h since it's only used in drizzled.cc
208
220
 *
209
221
 * @TODO Rename to DRIZZLED_NET_RETRY_COUNT
218
230
#define TRANS_ALLOC_BLOCK_SIZE          4096
219
231
#define TRANS_ALLOC_PREALLOC_SIZE       4096
220
232
#define RANGE_ALLOC_BLOCK_SIZE          4096
 
233
#define ACL_ALLOC_BLOCK_SIZE            1024
221
234
#define UDF_ALLOC_BLOCK_SIZE            1024
222
235
#define TABLE_ALLOC_BLOCK_SIZE          1024
 
236
#define BDB_LOG_ALLOC_BLOCK_SIZE        1024
223
237
#define WARN_ALLOC_BLOCK_SIZE           2048
224
238
#define WARN_ALLOC_PREALLOC_SIZE        1024
225
239
#define PROFILE_ALLOC_BLOCK_SIZE  2048
241
255
#define TIME_FOR_COMPARE   5    // 5 compares == one read
242
256
 
243
257
/**
244
 
  Number of comparisons of table rowids equivalent to reading one row from a
 
258
  Number of comparisons of table rowids equivalent to reading one row from a 
245
259
  table.
246
260
*/
247
261
#define TIME_FOR_COMPARE_ROWID  (TIME_FOR_COMPARE*2)
248
262
 
249
263
/*
250
264
  For sequential disk seeks the cost formula is:
251
 
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip
252
 
 
253
 
  The cost of average seek
 
265
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip  
 
266
  
 
267
  The cost of average seek 
254
268
    DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
255
269
*/
256
270
#define DISK_SEEK_BASE_COST ((double)0.9)
298
312
#define TEST_PRINT_CACHED_TABLES 1
299
313
#define TEST_NO_KEY_GROUP        2
300
314
#define TEST_MIT_THREAD         4
 
315
#define TEST_BLOCKING           8
301
316
#define TEST_KEEP_TMP_TABLES    16
302
317
#define TEST_READCHECK          64      /**< Force use of readcheck */
303
318
#define TEST_NO_EXTRA           128
348
363
 
349
364
#define portable_sizeof_char_ptr 8
350
365
 
351
 
#define TMP_FILE_PREFIX "#sql"                  /**< Prefix for tmp tables */
352
 
#define TMP_FILE_PREFIX_LENGTH 4
 
366
#define tmp_file_prefix "#sql"                  /**< Prefix for tmp tables */
 
367
#define tmp_file_prefix_length 4
353
368
 
354
369
/* Flags for calc_week() function.  */
355
370
#define WEEK_MONDAY_FIRST    1
356
371
#define WEEK_YEAR            2
357
372
#define WEEK_FIRST_WEEKDAY   4
358
373
 
359
 
/* used in date and time conversions */
360
 
/* Daynumber from year 0 to 9999-12-31 */
361
 
#define MAX_DAY_NUMBER 3652424L
362
 
 
363
374
#define STRING_BUFFER_USUAL_SIZE 80
364
375
 
365
376
/*
370
381
#define IS_EQUAL_PACK_LENGTH 2
371
382
 
372
383
 
373
 
/**
374
 
  Query type constants.
375
 
 
376
 
  QT_ORDINARY -- ordinary SQL query.
377
 
  QT_IS -- SQL query to be shown in INFORMATION_SCHEMA (in utf8 and without
378
 
  character set introducers).
379
 
 
380
 
  @TODO
381
 
 
382
 
  Move this out of here once Stew's done with UDF breakout.  The following headers need it:
383
 
 
384
 
    sql_lex.h --> included by session.h
385
 
    item.h
386
 
    table.h
387
 
    item_func.h
388
 
    item_subselect.h
389
 
    item_timefunc.h
390
 
    item_sum.h
391
 
    item_cmpfunc.h
392
 
    item_strfunc.h
393
 
*/
394
 
enum enum_query_type
395
 
{
396
 
  QT_ORDINARY,
397
 
  QT_IS
398
 
};
399
 
 
400
 
 
401
 
/**
402
 
 * @TODO Move to a separate header?
403
 
 *
404
 
 * It's needed by item.h and field.h, which are both inter-dependent
405
 
 * and contain forward declarations of many structs/classes in the
406
 
 * other header file.
407
 
 *
408
 
 * What is needed is a separate header file that is included
409
 
 * by *both* item.h and field.h to resolve inter-dependencies
410
 
 *
411
 
 * But, probably want to hold off on this until Stew finished the UDF cleanup
412
 
 */
413
 
enum Derivation
414
 
{
415
 
  DERIVATION_IGNORABLE= 5,
416
 
  DERIVATION_COERCIBLE= 4,
417
 
  DERIVATION_SYSCONST= 3,
418
 
  DERIVATION_IMPLICIT= 2,
419
 
  DERIVATION_NONE= 1,
420
 
  DERIVATION_EXPLICIT= 0
421
 
};
422
 
 
423
 
/**
424
 
 * Opening modes for open_temporary_table and open_table_from_share
425
 
 *
426
 
 * @TODO Put this into an appropriate header. It is only needed in:
427
 
 *
428
 
 *    table.cc
429
 
 *    sql_base.cc
430
 
 */
431
 
enum open_table_mode
432
 
{
433
 
  OTM_OPEN= 0,
434
 
  OTM_CREATE= 1,
435
 
  OTM_ALTER= 2
436
 
};
437
 
 
438
 
 
439
 
/**
440
 
 * used by several functions in functions/time directory
441
 
 *
442
 
**/
443
 
enum date_time_format_types
444
 
{
445
 
  TIME_ONLY= 0, TIME_MICROSECOND, DATE_ONLY, DATE_TIME, DATE_TIME_MICROSECOND
446
 
};
447
 
 
448
 
 
449
 
enum enum_parsing_place
450
 
{
451
 
  NO_MATTER
452
 
  , IN_HAVING
453
 
  , SELECT_LIST
454
 
  , IN_WHERE
455
 
  , IN_ON
456
 
};
457
 
 
458
 
enum enum_mysql_completiontype {
459
 
  ROLLBACK_RELEASE= -2
460
 
  , ROLLBACK= 1
461
 
  , ROLLBACK_AND_CHAIN= 7
462
 
  , COMMIT_RELEASE= -1
463
 
  , COMMIT= 0
464
 
  , COMMIT_AND_CHAIN= 6
465
 
};
466
 
 
467
 
enum enum_check_fields
468
 
{
469
 
  CHECK_FIELD_IGNORE
470
 
  , CHECK_FIELD_WARN
471
 
  , CHECK_FIELD_ERROR_FOR_NULL
472
 
};
473
 
 
474
 
enum enum_var_type
475
 
{
476
 
  OPT_DEFAULT= 0
477
 
  , OPT_SESSION
478
 
  , OPT_GLOBAL
479
 
};
480
 
 
481
 
 
482
 
typedef uint64_t query_id_t;
483
 
typedef void *range_seq_t;
484
 
 
485
 
 
486
 
/**
487
 
   The maximum is defined as (ULONG_MAX/1000) with 4 bytes uint32_t
488
 
*/
489
 
static const uint32_t SLAVE_MAX_HEARTBEAT_PERIOD= 4294967;
490
 
 
491
 
#define SLAVE_NET_TIMEOUT  3600
492
 
 
493
 
#define MAX_SLAVE_ERROR    2000
494
 
 
495
 
/* masks for start/stop operations on io and sql slave threads */
496
 
#define SLAVE_IO  1
497
 
#define SLAVE_SQL 2
498
 
 
499
 
#ifndef NO_HASH
500
 
#define NO_HASH                         /* Not yet implemented */
501
 
#endif
502
 
 
503
 
// the following is for checking tables
504
 
 
505
 
#define HA_ADMIN_ALREADY_DONE     1
506
 
#define HA_ADMIN_OK               0
507
 
#define HA_ADMIN_NOT_IMPLEMENTED -1
508
 
#define HA_ADMIN_FAILED          -2
509
 
#define HA_ADMIN_CORRUPT         -3
510
 
#define HA_ADMIN_INTERNAL_ERROR  -4
511
 
#define HA_ADMIN_INVALID         -5
512
 
#define HA_ADMIN_REJECT          -6
513
 
#define HA_ADMIN_TRY_ALTER       -7
514
 
#define HA_ADMIN_NEEDS_UPGRADE  -10
515
 
#define HA_ADMIN_NEEDS_ALTER    -11
516
 
#define HA_ADMIN_NEEDS_CHECK    -12
517
 
 
518
 
 
519
 
#define HA_ADD_INDEX                  (0)
520
 
#define HA_DROP_INDEX                 (1)
521
 
#define HA_ALTER_INDEX                (2)
522
 
#define HA_RENAME_INDEX               (3)
523
 
#define HA_ADD_UNIQUE_INDEX           (4)
524
 
#define HA_DROP_UNIQUE_INDEX          (5)
525
 
#define HA_ALTER_UNIQUE_INDEX         (6)
526
 
#define HA_RENAME_UNIQUE_INDEX        (7)
527
 
#define HA_ADD_PK_INDEX               (8)
528
 
#define HA_DROP_PK_INDEX              (9)
529
 
#define HA_ALTER_PK_INDEX             (10)
530
 
#define HA_ADD_COLUMN                 (11)
531
 
#define HA_DROP_COLUMN                (12)
532
 
#define HA_CHANGE_COLUMN              (13)
533
 
#define HA_ALTER_COLUMN_NAME          (14)
534
 
#define HA_ALTER_COLUMN_TYPE          (15)
535
 
#define HA_ALTER_COLUMN_ORDER         (16)
536
 
#define HA_ALTER_COLUMN_NULLABLE      (17)
537
 
#define HA_COLUMN_DEFAULT_VALUE       (18)
538
 
#define HA_COLUMN_STORAGE             (19)
539
 
#define HA_COLUMN_FORMAT              (20)
540
 
#define HA_ADD_FOREIGN_KEY            (21)
541
 
#define HA_DROP_FOREIGN_KEY           (22)
542
 
#define HA_ALTER_FOREIGN_KEY          (23)
543
 
#define HA_ADD_CONSTRAINT             (24)
544
 
#define HA_CHANGE_CHARACTER_SET       (30)
545
 
#define HA_SET_DEFAULT_CHARACTER_SET  (31)
546
 
#define HA_CHANGE_AUTOINCREMENT_VALUE (32)
547
 
#define HA_ALTER_STORAGE              (33)
548
 
#define HA_ALTER_TABLESPACE           (34)
549
 
#define HA_ALTER_ROW_FORMAT           (35)
550
 
#define HA_RENAME_TABLE               (36)
551
 
#define HA_ALTER_STORAGE_ENGINE       (37)
552
 
#define HA_RECREATE                   (38)
553
 
#define HA_ALTER_STORED_VCOL          (39)
554
 
/* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
555
 
 
556
 
/* Return values for check_if_supported_alter */
557
 
 
558
 
#define HA_ALTER_ERROR               -1
559
 
#define HA_ALTER_SUPPORTED_WAIT_LOCK  0
560
 
#define HA_ALTER_SUPPORTED_NO_LOCK    1
561
 
#define HA_ALTER_NOT_SUPPORTED        2
562
 
 
563
 
/* Bits in table_flags() to show what database can do */
564
 
 
565
 
#define HA_NO_TRANSACTIONS     (1 << 0) /* Doesn't support transactions */
566
 
#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */
567
 
#define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */
568
 
/*
569
 
  The following should be set if the following is not true when scanning
570
 
  a table with rnd_next()
571
 
  - We will see all rows (including deleted ones)
572
 
  - Row positions are 'table->s->db_record_offset' apart
573
 
  If this flag is not set, filesort will do a postion() call for each matched
574
 
  row to be able to find the row later.
575
 
*/
576
 
#define HA_REC_NOT_IN_SEQ      (1 << 3)
577
 
 
578
 
/*
579
 
  Reading keys in random order is as fast as reading keys in sort order
580
 
  (Used in records.cc to decide if we should use a record cache and by
581
 
  filesort to decide if we should sort key + data or key + pointer-to-row
582
 
*/
583
 
#define HA_FAST_KEY_READ       (1 << 5)
584
 
/*
585
 
  Set the following flag if we on delete should force all key to be read
586
 
  and on update read all keys that changes
587
 
*/
588
 
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6)
589
 
#define HA_NULL_IN_KEY         (1 << 7) /* One can have keys with NULL */
590
 
#define HA_DUPLICATE_POS       (1 << 8)    /* ha_position() gives dup row */
591
 
#define HA_NO_BLOBS            (1 << 9) /* Doesn't support blobs */
592
 
#define HA_CAN_INDEX_BLOBS     (1 << 10)
593
 
#define HA_AUTO_PART_KEY       (1 << 11) /* auto-increment in multi-part key */
594
 
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */
595
 
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */
596
 
/*
597
 
  If we get the primary key columns for free when we do an index read
598
 
  It also implies that we have to retrive the primary key when using
599
 
  position() and rnd_pos().
600
 
*/
601
 
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
602
 
/*
603
 
  If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
604
 
  uses a primary key. Without primary key, we can't call position().
605
 
*/
606
 
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16)
607
 
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
608
 
/*
609
 
  The following is we need to a primary key to delete (and update) a row.
610
 
  If there is no primary key, all columns needs to be read on update and delete
611
 
*/
612
 
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
613
 
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
614
 
#define HA_NO_AUTO_INCREMENT   (1 << 23)
615
 
#define HA_HAS_CHECKSUM        (1 << 24)
616
 
/* Table data are stored in separate files (for lower_case_table_names) */
617
 
#define HA_FILE_BASED          (1 << 26)
618
 
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
619
 
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
620
 
#define HA_NO_COPY_ON_ALTER    (INT64_C(1) << 31)
621
 
#define HA_HAS_RECORDS         (INT64_C(1) << 32) /* records() gives exact count*/
622
 
#define HA_MRR_CANT_SORT       (INT64_C(1) << 34)
623
 
 
624
 
/*
625
 
  Engine is capable of row-format and statement-format logging,
626
 
  respectively
627
 
*/
628
 
#define HA_BINLOG_ROW_CAPABLE  (INT64_C(1) << 35)
629
 
#define HA_BINLOG_STMT_CAPABLE (INT64_C(1) << 36)
630
 
 
631
 
#define HA_ONLINE_ALTER        (INT64_C(1) << 37)
632
 
 
633
 
/*
634
 
  Set of all binlog flags. Currently only contain the capabilities
635
 
  flags.
636
 
 */
637
 
#define HA_BINLOG_FLAGS (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE)
638
 
 
639
 
/* bits in index_flags(index_number) for what you can do with index */
640
 
#define HA_READ_NEXT            1       /* TODO really use this flag */
641
 
#define HA_READ_PREV            2       /* supports ::index_prev */
642
 
#define HA_READ_ORDER           4       /* index_next/prev follow sort order */
643
 
#define HA_READ_RANGE           8       /* can find all records in a range */
644
 
#define HA_ONLY_WHOLE_INDEX     16      /* Can't use part key searches */
645
 
#define HA_KEYREAD_ONLY         64      /* Support HA_EXTRA_KEYREAD */
646
 
/*
647
 
  Index scan will not return records in rowid order. Not guaranteed to be
648
 
  set for unordered (e.g. HASH) indexes.
649
 
*/
650
 
#define HA_KEY_SCAN_NOT_ROR     128
651
 
#define HA_DO_INDEX_COND_PUSHDOWN  256 /* Supports Index Condition Pushdown */
652
 
 
653
 
/* operations for disable/enable indexes */
654
 
#define HA_KEY_SWITCH_NONUNIQ      0
655
 
#define HA_KEY_SWITCH_ALL          1
656
 
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
657
 
#define HA_KEY_SWITCH_ALL_SAVE     3
658
 
 
659
 
/*
660
 
  Note: the following includes binlog and closing 0.
661
 
  so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
662
 
      example + csv + heap + blackhole + federated + 0
663
 
  (yes, the sum is deliberately inaccurate)
664
 
  TODO remove the limit, use dynarrays
665
 
*/
666
 
#define MAX_HA 15
667
 
 
668
 
/*
669
 
  Parameters for open() (in register form->filestat)
670
 
  HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
671
 
*/
672
 
 
673
 
#define HA_OPEN_KEYFILE         1
674
 
#define HA_OPEN_RNDFILE         2
675
 
#define HA_GET_INDEX            4
676
 
#define HA_GET_INFO             8       /* do a ha_info() after open */
677
 
#define HA_READ_ONLY            16      /* File opened as readonly */
678
 
/* Try readonly if can't open with read and write */
679
 
#define HA_TRY_READ_ONLY        32
680
 
#define HA_WAIT_IF_LOCKED       64      /* Wait if locked on open */
681
 
#define HA_ABORT_IF_LOCKED      128     /* skip if locked on open.*/
682
 
#define HA_BLOCK_LOCK           256     /* unlock when reading some records */
683
 
#define HA_OPEN_TEMPORARY       512
684
 
 
685
 
/* For transactional LOCK Table. handler::lock_table() */
686
 
#define HA_LOCK_IN_SHARE_MODE      F_RDLCK
687
 
#define HA_LOCK_IN_EXCLUSIVE_MODE  F_WRLCK
688
 
 
689
 
/* Some key definitions */
690
 
#define HA_KEY_NULL_LENGTH      1
691
 
#define HA_KEY_BLOB_LENGTH      2
692
 
 
693
 
#define HA_LEX_CREATE_TMP_TABLE 1
694
 
#define HA_LEX_CREATE_IF_NOT_EXISTS 2
695
 
#define HA_LEX_CREATE_TABLE_LIKE 4
696
 
#define HA_OPTION_NO_CHECKSUM   (1L << 17)
697
 
#define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18)
698
 
#define HA_MAX_REC_LENGTH       65535
699
 
 
700
 
/* Table caching type */
701
 
#define HA_CACHE_TBL_NONTRANSACT 0
702
 
#define HA_CACHE_TBL_NOCACHE     1
703
 
#define HA_CACHE_TBL_ASKTRANSACT 2
704
 
#define HA_CACHE_TBL_TRANSACT    4
705
 
 
706
 
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
707
 
#define DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
708
 
 
709
 
/* Flags for method is_fatal_error */
710
 
#define HA_CHECK_DUP_KEY 1
711
 
#define HA_CHECK_DUP_UNIQUE 2
712
 
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
713
 
 
714
 
enum legacy_db_type
715
 
{
716
 
  DB_TYPE_UNKNOWN=0,
717
 
  DB_TYPE_FIRST_DYNAMIC=42,
718
 
  DB_TYPE_DEFAULT=127 // Must be last
719
 
};
720
 
 
721
 
enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED,
722
 
                ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED,
723
 
                ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGE };
724
 
 
725
 
enum column_format_type { COLUMN_FORMAT_TYPE_NOT_USED= -1,
726
 
                          COLUMN_FORMAT_TYPE_DEFAULT=   0,
727
 
                          COLUMN_FORMAT_TYPE_FIXED=     1,
728
 
                          COLUMN_FORMAT_TYPE_DYNAMIC=   2 };
729
 
 
730
 
enum enum_binlog_func {
731
 
  BFN_RESET_LOGS=        1,
732
 
  BFN_RESET_SLAVE=       2,
733
 
  BFN_BINLOG_WAIT=       3,
734
 
  BFN_BINLOG_END=        4,
735
 
  BFN_BINLOG_PURGE_FILE= 5
736
 
};
737
 
 
738
 
enum enum_binlog_command {
739
 
  LOGCOM_CREATE_TABLE,
740
 
  LOGCOM_ALTER_TABLE,
741
 
  LOGCOM_RENAME_TABLE,
742
 
  LOGCOM_DROP_TABLE,
743
 
  LOGCOM_CREATE_DB,
744
 
  LOGCOM_ALTER_DB,
745
 
  LOGCOM_DROP_DB
746
 
};
747
 
 
748
 
/* struct to hold information about the table that should be created */
749
 
 
750
 
/* Bits in used_fields */
751
 
#define HA_CREATE_USED_AUTO             (1L << 0)
752
 
#ifdef DEAD_OPTIONS
753
 
#define HA_CREATE_USED_UNION            (1L << 2)
754
 
#define HA_CREATE_USED_PASSWORD         (1L << 17)
755
 
#endif
756
 
#define HA_CREATE_USED_INSERT_METHOD    (1L << 3)
757
 
#define HA_CREATE_USED_MIN_ROWS         (1L << 4)
758
 
#define HA_CREATE_USED_MAX_ROWS         (1L << 5)
759
 
#define HA_CREATE_USED_AVG_ROW_LENGTH   (1L << 6)
760
 
#define HA_CREATE_USED_PACK_KEYS        (1L << 7)
761
 
#define HA_CREATE_USED_CHARSET          (1L << 8)
762
 
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
763
 
#define HA_CREATE_USED_DATADIR          (1L << 10)
764
 
#define HA_CREATE_USED_INDEXDIR         (1L << 11)
765
 
#define HA_CREATE_USED_ENGINE           (1L << 12)
766
 
#define HA_CREATE_USED_CHECKSUM         (1L << 13)
767
 
#define HA_CREATE_USED_DELAY_KEY_WRITE  (1L << 14)
768
 
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
769
 
#define HA_CREATE_USED_COMMENT          (1L << 16)
770
 
#define HA_CREATE_USED_CONNECTION       (1L << 18)
771
 
#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)
772
 
#define HA_CREATE_USED_PAGE_CHECKSUM    (1L << 21)
773
 
#define HA_CREATE_USED_BLOCK_SIZE       (1L << 22)
774
 
 
775
 
#define MAXGTRIDSIZE 64
776
 
#define MAXBQUALSIZE 64
777
 
 
778
 
#define COMPATIBLE_DATA_YES 0
779
 
#define COMPATIBLE_DATA_NO  1
780
 
 
781
 
#define UNDEF_NODEGROUP 65535
782
 
#define NOT_A_PARTITION_ID ((uint32_t)-1)
783
 
 
784
 
enum ha_choice { HA_CHOICE_UNDEF, HA_CHOICE_NO, HA_CHOICE_YES };
785
 
 
786
 
/*
787
 
  The below two are not used (and not handled) in this milestone of this WL
788
 
  entry because there seems to be no use for them at this stage of
789
 
  implementation.
790
 
*/
791
 
#define HA_MRR_SINGLE_POINT 1
792
 
#define HA_MRR_FIXED_KEY  2
793
 
 
794
 
/*
795
 
  Indicates that RANGE_SEQ_IF::next(&range) doesn't need to fill in the
796
 
  'range' parameter.
797
 
*/
798
 
#define HA_MRR_NO_ASSOCIATION 4
799
 
 
800
 
/*
801
 
  The MRR user will provide ranges in key order, and MRR implementation
802
 
  must return rows in key order.
803
 
*/
804
 
#define HA_MRR_SORTED 8
805
 
 
806
 
/* MRR implementation doesn't have to retrieve full records */
807
 
#define HA_MRR_INDEX_ONLY 16
808
 
 
809
 
/*
810
 
  The passed memory buffer is of maximum possible size, the caller can't
811
 
  assume larger buffer.
812
 
*/
813
 
#define HA_MRR_LIMITS 32
814
 
 
815
 
 
816
 
/*
817
 
  Flag set <=> default MRR implementation is used
818
 
  (The choice is made by **_info[_const]() function which may set this
819
 
   flag. SQL layer remembers the flag value and then passes it to
820
 
   multi_read_range_init().
821
 
*/
822
 
#define HA_MRR_USE_DEFAULT_IMPL 64
823
 
 
824
 
/*
825
 
  Used only as parameter to multi_range_read_info():
826
 
  Flag set <=> the caller guarantees that the bounds of the scanned ranges
827
 
  will not have NULL values.
828
 
*/
829
 
#define HA_MRR_NO_NULL_ENDPOINTS 128
830
 
 
831
 
enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY, RNEXT_SAME };
832
 
 
833
 
enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED,
834
 
                         ISO_REPEATABLE_READ, ISO_SERIALIZABLE};
835
 
 
836
 
 
837
 
enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
838
 
 
839
 
typedef int myf;
840
 
#define MYF(v)          (myf) (v)
841
 
 
842
 
/*
843
 
  When a command is added here, be sure it's also added in mysqld.cc
844
 
  in "struct show_var_st status_vars[]= {" ...
845
 
 
846
 
  If the command returns a result set or is not allowed in stored
847
 
  functions or triggers, please also make sure that
848
 
  sp_get_flags_for_command (sp_head.cc) returns proper flags for the
849
 
  added SQLCOM_.
850
 
*/
851
 
 
852
 
enum enum_sql_command {
853
 
  SQLCOM_SELECT, SQLCOM_CREATE_TABLE, SQLCOM_CREATE_INDEX, SQLCOM_ALTER_TABLE,
854
 
  SQLCOM_UPDATE, SQLCOM_INSERT, SQLCOM_INSERT_SELECT,
855
 
  SQLCOM_DELETE, SQLCOM_TRUNCATE, SQLCOM_DROP_TABLE, SQLCOM_DROP_INDEX,
856
 
  SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS,
857
 
  SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_STATUS,
858
 
  SQLCOM_SHOW_ENGINE_LOGS, SQLCOM_SHOW_ENGINE_STATUS, SQLCOM_SHOW_ENGINE_MUTEX,
859
 
  SQLCOM_SHOW_PROCESSLIST,
860
 
  SQLCOM_SHOW_CREATE,
861
 
  SQLCOM_SHOW_CREATE_DB,
862
 
  SQLCOM_SHOW_TABLE_STATUS,
863
 
  SQLCOM_LOAD,SQLCOM_SET_OPTION,SQLCOM_LOCK_TABLES,SQLCOM_UNLOCK_TABLES,
864
 
  SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB, SQLCOM_ALTER_DB,
865
 
  SQLCOM_REPAIR, SQLCOM_REPLACE, SQLCOM_REPLACE_SELECT,
866
 
  SQLCOM_OPTIMIZE, SQLCOM_CHECK,
867
 
  SQLCOM_ASSIGN_TO_KEYCACHE,
868
 
  SQLCOM_FLUSH, SQLCOM_KILL, SQLCOM_ANALYZE,
869
 
  SQLCOM_ROLLBACK, SQLCOM_ROLLBACK_TO_SAVEPOINT,
870
 
  SQLCOM_COMMIT, SQLCOM_SAVEPOINT, SQLCOM_RELEASE_SAVEPOINT,
871
 
  SQLCOM_SLAVE_START, SQLCOM_SLAVE_STOP,
872
 
  SQLCOM_BEGIN,
873
 
  SQLCOM_RENAME_TABLE,
874
 
  SQLCOM_SHOW_OPEN_TABLES,
875
 
  SQLCOM_DELETE_MULTI, SQLCOM_UPDATE_MULTI,
876
 
  SQLCOM_SHOW_WARNS,
877
 
  SQLCOM_EMPTY_QUERY,
878
 
  SQLCOM_SHOW_ERRORS,
879
 
  SQLCOM_CHECKSUM,
880
 
  SQLCOM_SHOW_PLUGINS,
881
 
  /*
882
 
    When a command is added here, be sure it's also added in mysqld.cc
883
 
    in "struct show_var_st status_vars[]= {" ...
884
 
  */
885
 
  /* This should be the last !!! */
886
 
  SQLCOM_END
887
 
};
888
 
 
889
 
enum enum_duplicates { DUP_ERROR, DUP_REPLACE, DUP_UPDATE };
890
 
 
891
 
enum release_type { RELEASE_NORMAL, RELEASE_WAIT_FOR_DROP };
892
 
 
893
 
/*
894
 
  Make sure that the order of schema_tables and enum_schema_tables are the same.
895
 
*/
896
 
 
897
 
enum enum_schema_tables
898
 
{
899
 
  SCH_CHARSETS= 0,
900
 
  SCH_COLLATIONS,
901
 
  SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
902
 
  SCH_COLUMNS,
903
 
  SCH_GLOBAL_STATUS,
904
 
  SCH_GLOBAL_VARIABLES,
905
 
  SCH_KEY_COLUMN_USAGE,
906
 
  SCH_OPEN_TABLES,
907
 
  SCH_PLUGINS,
908
 
  SCH_PROCESSLIST,
909
 
  SCH_REFERENTIAL_CONSTRAINTS,
910
 
  SCH_SCHEMATA,
911
 
  SCH_SESSION_STATUS,
912
 
  SCH_SESSION_VARIABLES,
913
 
  SCH_STATISTICS,
914
 
  SCH_STATUS,
915
 
  SCH_TABLES,
916
 
  SCH_TABLE_CONSTRAINTS,
917
 
  SCH_TABLE_NAMES,
918
 
  SCH_VARIABLES
919
 
};
920
 
 
921
 
 
922
 
#define MY_I_S_MAYBE_NULL 1
923
 
#define MY_I_S_UNSIGNED   2
924
 
 
925
 
 
926
 
#define SKIP_OPEN_TABLE 0                // do not open table
927
 
#define OPEN_FRM_ONLY   1                // open FRM file only
928
 
#define OPEN_FULL_TABLE 2                // open FRM,MYD, MYI files
929
 
 
930
 
/*
931
 
   "Declared Type Collation"
932
 
   A combination of collation and its derivation.
933
 
 
934
 
  Flags for collation aggregation modes:
935
 
  MY_COLL_ALLOW_SUPERSET_CONV  - allow conversion to a superset
936
 
  MY_COLL_ALLOW_COERCIBLE_CONV - allow conversion of a coercible value
937
 
                                 (i.e. constant).
938
 
  MY_COLL_ALLOW_CONV           - allow any kind of conversion
939
 
                                 (combination of the above two)
940
 
  MY_COLL_DISALLOW_NONE        - don't allow return DERIVATION_NONE
941
 
                                 (e.g. when aggregating for comparison)
942
 
  MY_COLL_CMP_CONV             - combination of MY_COLL_ALLOW_CONV
943
 
                                 and MY_COLL_DISALLOW_NONE
944
 
*/
945
 
 
946
 
#define MY_COLL_ALLOW_SUPERSET_CONV   1
947
 
#define MY_COLL_ALLOW_COERCIBLE_CONV  2
948
 
#define MY_COLL_ALLOW_CONV            3
949
 
#define MY_COLL_DISALLOW_NONE         4
950
 
#define MY_COLL_CMP_CONV              7
951
 
 
952
 
 
953
 
/*
954
 
  This enum is used to report information about monotonicity of function
955
 
  represented by Item* tree.
956
 
  Monotonicity is defined only for Item* trees that represent table
957
 
  partitioning expressions (i.e. have no subselects/user vars/PS parameters
958
 
  etc etc). An Item* tree is assumed to have the same monotonicity properties
959
 
  as its correspoinding function F:
960
 
 
961
 
  [signed] int64_t F(field1, field2, ...) {
962
 
    put values of field_i into table record buffer;
963
 
    return item->val_int();
964
 
  }
965
 
 
966
 
  NOTE
967
 
  At the moment function monotonicity is not well defined (and so may be
968
 
  incorrect) for Item trees with parameters/return types that are different
969
 
  from INT_RESULT, may be NULL, or are unsigned.
970
 
  It will be possible to address this issue once the related partitioning bugs
971
 
  (BUG#16002, BUG#15447, BUG#13436) are fixed.
972
 
*/
973
 
 
974
 
typedef enum monotonicity_info
975
 
{
976
 
   NON_MONOTONIC,              /* none of the below holds */
977
 
   MONOTONIC_INCREASING,       /* F() is unary and (x < y) => (F(x) <= F(y)) */
978
 
   MONOTONIC_STRICT_INCREASING /* F() is unary and (x < y) => (F(x) <  F(y)) */
979
 
} enum_monotonicity_info;
980
 
 
981
 
enum tmp_table_type
982
 
{
983
 
  NO_TMP_TABLE, NON_TRANSACTIONAL_TMP_TABLE, TRANSACTIONAL_TMP_TABLE,
984
 
  INTERNAL_TMP_TABLE, SYSTEM_TMP_TABLE, TMP_TABLE_FRM_FILE_ONLY
985
 
};
986
 
 
987
 
/*
988
 
  Values in this enum are used to indicate how a tables TIMESTAMP field
989
 
  should be treated. It can be set to the current timestamp on insert or
990
 
  update or both.
991
 
  WARNING: The values are used for bit operations. If you change the
992
 
  enum, you must keep the bitwise relation of the values. For example:
993
 
  (int) TIMESTAMP_AUTO_SET_ON_BOTH must be equal to
994
 
  (int) TIMESTAMP_AUTO_SET_ON_INSERT | (int) TIMESTAMP_AUTO_SET_ON_UPDATE.
995
 
  We use an enum here so that the debugger can display the value names.
996
 
*/
997
 
enum timestamp_auto_set_type
998
 
{
999
 
  TIMESTAMP_NO_AUTO_SET= 0, TIMESTAMP_AUTO_SET_ON_INSERT= 1,
1000
 
  TIMESTAMP_AUTO_SET_ON_UPDATE= 2, TIMESTAMP_AUTO_SET_ON_BOTH= 3
1001
 
};
1002
 
#define clear_timestamp_auto_bits(_target_, _bits_) \
1003
 
  (_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
1004
 
 
1005
 
/**
1006
 
  Category of table found in the table share.
1007
 
*/
1008
 
enum enum_table_category
1009
 
{
1010
 
  /**
1011
 
    Unknown value.
1012
 
  */
1013
 
  TABLE_UNKNOWN_CATEGORY=0,
1014
 
 
1015
 
  /**
1016
 
    Temporary table.
1017
 
    The table is visible only in the session.
1018
 
    Therefore,
1019
 
    - FLUSH TABLES WITH READ LOCK
1020
 
    - SET GLOBAL READ_ONLY = ON
1021
 
    do not apply to this table.
1022
 
    Note that LOCK Table t FOR READ/WRITE
1023
 
    can be used on temporary tables.
1024
 
    Temporary tables are not part of the table cache.
1025
 
  */
1026
 
  TABLE_CATEGORY_TEMPORARY=1,
1027
 
 
1028
 
  /**
1029
 
    User table.
1030
 
    These tables do honor:
1031
 
    - LOCK Table t FOR READ/WRITE
1032
 
    - FLUSH TABLES WITH READ LOCK
1033
 
    - SET GLOBAL READ_ONLY = ON
1034
 
    User tables are cached in the table cache.
1035
 
  */
1036
 
  TABLE_CATEGORY_USER=2,
1037
 
 
1038
 
  /**
1039
 
    Information schema tables.
1040
 
    These tables are an interface provided by the system
1041
 
    to inspect the system metadata.
1042
 
    These tables do *not* honor:
1043
 
    - LOCK Table t FOR READ/WRITE
1044
 
    - FLUSH TABLES WITH READ LOCK
1045
 
    - SET GLOBAL READ_ONLY = ON
1046
 
    as there is no point in locking explicitely
1047
 
    an INFORMATION_SCHEMA table.
1048
 
    Nothing is directly written to information schema tables.
1049
 
    Note that this value is not used currently,
1050
 
    since information schema tables are not shared,
1051
 
    but implemented as session specific temporary tables.
1052
 
  */
1053
 
  /*
1054
 
    TODO: Fixing the performance issues of I_S will lead
1055
 
    to I_S tables in the table cache, which should use
1056
 
    this table type.
1057
 
  */
1058
 
  TABLE_CATEGORY_INFORMATION
1059
 
};
1060
 
 
1061
 
/* Information for one open table */
1062
 
enum index_hint_type
1063
 
{
1064
 
  INDEX_HINT_IGNORE,
1065
 
  INDEX_HINT_USE,
1066
 
  INDEX_HINT_FORCE
1067
 
};
1068
 
 
1069
 
 
1070
 
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
1071
 
enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON,
1072
 
                            DELAY_KEY_WRITE_ALL };
1073
 
enum enum_slave_exec_mode { SLAVE_EXEC_MODE_STRICT,
1074
 
                            SLAVE_EXEC_MODE_IDEMPOTENT,
1075
 
                            SLAVE_EXEC_MODE_LAST_BIT};
1076
 
enum enum_mark_columns
1077
 
{ MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE};
1078
 
 
1079
 
enum enum_filetype { FILETYPE_CSV, FILETYPE_XML };
1080
 
 
1081
 
enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND,
1082
 
                                  IGNORE_ERRORS, REPORT_EXCEPT_NON_UNIQUE,
1083
 
                                  IGNORE_EXCEPT_NON_UNIQUE};
1084
 
 
1085
 
enum enum_schema_table_state
1086
 
{
1087
 
  NOT_PROCESSED= 0,
1088
 
  PROCESSED_BY_CREATE_SORT_INDEX,
1089
 
  PROCESSED_BY_JOIN_EXEC
1090
 
};
1091
 
 
1092
 
/*
1093
 
 * The following are for the interface with the .frm file
1094
 
 */
1095
 
 
1096
 
#define FIELDFLAG_DECIMAL    1
1097
 
#define FIELDFLAG_BINARY    1  // Shares same flag
1098
 
#define FIELDFLAG_NUMBER    2
1099
 
#define FIELDFLAG_DECIMAL_POSITION      4
1100
 
#define FIELDFLAG_PACK      120  // Bits used for packing
1101
 
#define FIELDFLAG_INTERVAL    256     // mangled with decimals!
1102
 
#define FIELDFLAG_BLOB      1024  // mangled with decimals!
1103
 
 
1104
 
#define FIELDFLAG_NO_DEFAULT    16384   /* sql */
1105
 
#define FIELDFLAG_SUM      ((uint32_t) 32768)// predit: +#fieldflag
1106
 
#define FIELDFLAG_MAYBE_NULL    ((uint32_t) 32768)// sql
1107
 
#define FIELDFLAG_HEX_ESCAPE    ((uint32_t) 0x10000)
1108
 
#define FIELDFLAG_PACK_SHIFT    3
1109
 
#define FIELDFLAG_DEC_SHIFT    8
1110
 
#define FIELDFLAG_MAX_DEC    31
1111
 
 
1112
 
#define MTYP_TYPENR(type) (type & 127)  /* Remove bits from type */
1113
 
 
1114
 
#define f_is_dec(x)     ((x) & FIELDFLAG_DECIMAL)
1115
 
#define f_is_num(x)     ((x) & FIELDFLAG_NUMBER)
1116
 
#define f_is_decimal_precision(x)  ((x) & FIELDFLAG_DECIMAL_POSITION)
1117
 
#define f_is_packed(x)  ((x) & FIELDFLAG_PACK)
1118
 
#define f_packtype(x)   (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
1119
 
#define f_decimals(x)   ((uint8_t) (((x) >> FIELDFLAG_DEC_SHIFT) & \
1120
 
                                     FIELDFLAG_MAX_DEC))
1121
 
#define f_is_alpha(x)   (!f_is_num(x))
1122
 
#define f_is_binary(x)  ((x) & FIELDFLAG_BINARY) // 4.0- compatibility
1123
 
#define f_is_enum(x)    (((x) & (FIELDFLAG_INTERVAL | FIELDFLAG_NUMBER)) == \
1124
 
                         FIELDFLAG_INTERVAL)
1125
 
#define f_is_blob(x)    (((x) & (FIELDFLAG_BLOB | FIELDFLAG_NUMBER)) == \
1126
 
                         FIELDFLAG_BLOB)
1127
 
#define f_is_equ(x)     ((x) & (1+2+FIELDFLAG_PACK+31*256))
1128
 
#define f_settype(x)    (((int) x) << FIELDFLAG_PACK_SHIFT)
1129
 
#define f_maybe_null(x) (x & FIELDFLAG_MAYBE_NULL)
1130
 
#define f_no_default(x) (x & FIELDFLAG_NO_DEFAULT)
1131
 
#define f_is_hex_escape(x) ((x) & FIELDFLAG_HEX_ESCAPE)
1132
 
 
1133
384
#endif /* DRIZZLE_SERVER_DEFINITIONS_H */
1134