~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definitions.h

  • Committer: Jay Pipes
  • Date: 2009-03-13 23:42:05 UTC
  • mto: This revision was merged to the branch mainline in revision 937.
  • Revision ID: jpipes@serialcoder-20090313234205-fmr8bd072nvfa28v
Forgot to add the new files...

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 * Mostly constants and some macros/functions used by the server
24
24
 */
25
25
 
26
 
#ifndef DRIZZLED_DEFINITIONS_H
27
 
#define DRIZZLED_DEFINITIONS_H
28
 
 
29
 
#include <drizzled/enum.h>
 
26
#ifndef DRIZZLE_SERVER_DEFINITIONS_H
 
27
#define DRIZZLE_SERVER_DEFINITIONS_H
30
28
 
31
29
#include <stdint.h>
32
30
 
 
31
#ifndef NO_ALARM_LOOP
 
32
#define NO_ALARM_LOOP           /* lib5 and popen can't use alarm */
 
33
#endif
 
34
 
33
35
/* These paths are converted to other systems (WIN95) before use */
34
36
 
35
37
#define LANGUAGE        "english/"
 
38
#define ERRMSG_FILE     "errmsg.sys"
36
39
#define TEMP_PREFIX     "MY"
37
40
#define LOG_PREFIX      "ML"
38
41
#define PROGDIR         "bin/"
45
48
#define MAX_ALIAS_NAME 256
46
49
#define MAX_FIELD_NAME 34                       /* Max colum name length +2 */
47
50
#define MAX_SYS_VAR_LENGTH 32
48
 
#define MAX_INDEXES 64
49
51
#define MAX_KEY MAX_INDEXES                     /* Max used keys */
50
52
#define MAX_REF_PARTS 16                        /* Max parts used as ref */
51
53
#define MAX_KEY_LENGTH 4096                     /* max possible key */
65
67
/* Max column width +1 */
66
68
#define MAX_FIELD_WIDTH         (MAX_FIELD_CHARLENGTH*MAX_MBWIDTH+1)
67
69
 
 
70
#define MAX_DATE_WIDTH          10      /* YYYY-MM-DD */
 
71
#define MAX_TIME_WIDTH          23      /* -DDDDDD HH:MM:SS.###### */
 
72
#define MAX_DATETIME_FULL_WIDTH 29      /* YYYY-MM-DD HH:MM:SS.###### AM */
 
73
#define MAX_DATETIME_WIDTH      19      /* YYYY-MM-DD HH:MM:SS */
68
74
#define MAX_DATETIME_COMPRESSED_WIDTH 14  /* YYYYMMDDHHMMSS */
69
75
 
70
76
#define MAX_TABLES      (sizeof(table_map)*8-3) /* Max tables in join */
83
89
/* Memory allocated when parsing a statement / saving a statement */
84
90
#define MEM_ROOT_BLOCK_SIZE       8192
85
91
#define MEM_ROOT_PREALLOC         8192
 
92
#define TRANS_MEM_ROOT_BLOCK_SIZE 4096
 
93
#define TRANS_MEM_ROOT_PREALLOC   4096
86
94
 
87
95
#define DEFAULT_ERROR_COUNT     64
88
96
#define EXTRA_RECORDS   10                      /* Extra records in sort */
100
108
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
101
109
#define MYF_RW MYF(MY_WME+MY_NABP)              /* Vid my_read & my_write */
102
110
 
 
111
        /* Extern defines */
 
112
#define store_record(A,B) memcpy((A)->B,(A)->record[0],(size_t) (A)->s->reclength)
 
113
#define restore_record(A,B) memcpy((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
 
114
#define cmp_record(A,B) memcmp((A)->record[0],(A)->B,(size_t) (A)->s->reclength)
 
115
#define empty_record(A)                                 \
 
116
  do {                                                  \
 
117
    restore_record((A),s->default_values);              \
 
118
    memset((A)->null_flags, 255, (A)->s->null_bytes);   \
 
119
  } while (0)
 
120
 
103
121
        /* Defines for use with openfrm, openprt and openfrd */
104
122
 
105
123
#define READ_ALL                1       /* openfrm: Read all parameters */
 
124
#define CHANGE_FRM              2       /* openfrm: open .frm as O_RDWR */
106
125
#define EXTRA_RECORD            8       /* Reservera plats f|r extra record */
107
126
#define DONT_GIVE_ERROR         256     /* Don't do frm_error on openfrm  */
108
127
#define DELAYED_OPEN            4096    /* Open table later */
126
145
*/
127
146
#define OPTIMIZE_I_S_TABLE     OPEN_TABLE_ONLY*2
128
147
 
 
148
#define SC_INFO_LENGTH 4                /* Form format constant */
 
149
#define TE_INFO_LENGTH 3
 
150
 
 
151
#define FRM_VER 6
 
152
#define FRM_VER_TRUE_VARCHAR (FRM_VER+4) /* 10 */
 
153
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_CGE 50120
 
154
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM 50205
 
155
#define DRIZZLE_VERSION_TABLESPACE_IN_FRM_STR "50205"
 
156
 
129
157
/*
130
158
  Minimum length pattern before Turbo Boyer-Moore is used
131
159
  for SELECT "text" LIKE "%pattern%", excluding the two
141
169
 
142
170
#define BIN_LOG_HEADER_SIZE    4
143
171
 
 
172
#define DEFAULT_KEY_CACHE_NAME "default"
 
173
 
 
174
#define STORAGE_TYPE_MASK 7
144
175
#define COLUMN_FORMAT_MASK 7
145
176
#define COLUMN_FORMAT_SHIFT 3
146
177
 
148
179
/***************************************************************************
149
180
  Configuration parameters
150
181
****************************************************************************/
 
182
#define MAX_PASSWORD_LENGTH     32
 
183
#define MAX_ACCEPT_RETRY        10      // Test accept this many times
151
184
#define MAX_FIELDS_BEFORE_HASH  32
152
185
#define USER_VARS_HASH_SIZE     16
153
186
#define TABLE_OPEN_CACHE_MIN    64
167
200
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
168
201
#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
169
202
 
 
203
/**
 
204
 * @TODO Move into a drizzled.h since it's only used in drizzled.cc
 
205
 *
 
206
 * @TODO Rename to DRIZZLED_NET_RETRY_COUNT
 
207
 */
 
208
#ifndef MYSQLD_NET_RETRY_COUNT
 
209
#define MYSQLD_NET_RETRY_COUNT  10      ///< Abort read after this many int.
 
210
#endif
170
211
#define TEMP_POOL_SIZE          128
171
212
 
172
213
#define QUERY_ALLOC_BLOCK_SIZE          8192
174
215
#define TRANS_ALLOC_BLOCK_SIZE          4096
175
216
#define TRANS_ALLOC_PREALLOC_SIZE       4096
176
217
#define RANGE_ALLOC_BLOCK_SIZE          4096
 
218
#define UDF_ALLOC_BLOCK_SIZE            1024
177
219
#define TABLE_ALLOC_BLOCK_SIZE          1024
178
220
#define WARN_ALLOC_BLOCK_SIZE           2048
179
221
#define WARN_ALLOC_PREALLOC_SIZE        1024
 
222
#define PROFILE_ALLOC_BLOCK_SIZE  2048
 
223
#define PROFILE_ALLOC_PREALLOC_SIZE 1024
180
224
 
181
225
/*
182
226
  The following parameters is to decide when to use an extra cache to
231
275
#define PRECISION_FOR_DOUBLE 53
232
276
#define PRECISION_FOR_FLOAT  24
233
277
 
 
278
/*
 
279
  Default time to wait before aborting a new client connection
 
280
  that does not respond to "initial server greeting" timely
 
281
*/
 
282
#define CONNECT_TIMEOUT         10
 
283
 
234
284
/* The following can also be changed from the command line */
235
285
#define DEFAULT_CONCURRENCY     10
236
286
#define FLUSH_TIME              0               /**< Don't flush tables */
241
291
#define WAIT_PRIOR      8
242
292
#define QUERY_PRIOR     6
243
293
 
244
 
/* Bits from testflag */
245
 
enum test_flag_bit
246
 
{
247
 
  TEST_PRINT_CACHED_TABLES= 1,
248
 
  TEST_NO_KEY_GROUP,
249
 
  TEST_MIT_THREAD,
250
 
  TEST_KEEP_TMP_TABLES,
251
 
  TEST_READCHECK, /**< Force use of readcheck */
252
 
  TEST_NO_EXTRA,
253
 
  TEST_CORE_ON_SIGNAL, /**< Give core if signal */
254
 
  TEST_NO_STACKTRACE,
255
 
  TEST_SIGINT, /**< Allow sigint on threads */
256
 
  TEST_SYNCHRONIZATION /**< get server to do sleep in some places */
257
 
};
 
294
        /* Bits from testflag */
 
295
#define TEST_PRINT_CACHED_TABLES 1
 
296
#define TEST_NO_KEY_GROUP        2
 
297
#define TEST_MIT_THREAD         4
 
298
#define TEST_KEEP_TMP_TABLES    16
 
299
#define TEST_READCHECK          64      /**< Force use of readcheck */
 
300
#define TEST_NO_EXTRA           128
 
301
#define TEST_CORE_ON_SIGNAL     256     /**< Give core if signal */
 
302
#define TEST_NO_STACKTRACE      512
 
303
#define TEST_SIGINT             1024    /**< Allow sigint on threads */
 
304
#define TEST_SYNCHRONIZATION    2048    /**< get server to do sleep in some places */
258
305
 
259
306
/* Bits for different SQL modes modes (including ANSI mode) */
260
307
#define MODE_NO_ZERO_DATE               (2)
280
327
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
281
328
#define UNDEF_POS (-1)
282
329
 
 
330
/* BINLOG_DUMP options */
 
331
 
 
332
#define BINLOG_DUMP_NON_BLOCK   1
 
333
 
283
334
/* sql_show.cc:show_log_files() */
284
335
#define SHOW_LOG_STATUS_FREE "FREE"
285
336
#define SHOW_LOG_STATUS_INUSE "IN USE"
316
367
#define IS_EQUAL_PACK_LENGTH 2
317
368
 
318
369
 
 
370
/**
 
371
  Query type constants.
 
372
 
 
373
  QT_ORDINARY -- ordinary SQL query.
 
374
  QT_IS -- SQL query to be shown in INFORMATION_SCHEMA (in utf8 and without
 
375
  character set introducers).
 
376
 
 
377
  @TODO
 
378
 
 
379
  Move this out of here once Stew's done with UDF breakout.  The following headers need it:
 
380
 
 
381
    sql_lex.h --> included by session.h
 
382
    item.h
 
383
    table.h
 
384
    item_func.h
 
385
    item_subselect.h
 
386
    item_timefunc.h
 
387
    item_sum.h
 
388
    item_cmpfunc.h
 
389
    item_strfunc.h
 
390
*/
 
391
enum enum_query_type
 
392
{
 
393
  QT_ORDINARY,
 
394
  QT_IS
 
395
};
 
396
 
 
397
 
 
398
/**
 
399
 * @TODO Move to a separate header?
 
400
 *
 
401
 * It's needed by item.h and field.h, which are both inter-dependent
 
402
 * and contain forward declarations of many structs/classes in the
 
403
 * other header file.
 
404
 *
 
405
 * What is needed is a separate header file that is included
 
406
 * by *both* item.h and field.h to resolve inter-dependencies
 
407
 *
 
408
 * But, probably want to hold off on this until Stew finished the UDF cleanup
 
409
 */
 
410
enum Derivation
 
411
{
 
412
  DERIVATION_IGNORABLE= 5,
 
413
  DERIVATION_COERCIBLE= 4,
 
414
  DERIVATION_SYSCONST= 3,
 
415
  DERIVATION_IMPLICIT= 2,
 
416
  DERIVATION_NONE= 1,
 
417
  DERIVATION_EXPLICIT= 0
 
418
};
 
419
 
 
420
/**
 
421
 * Opening modes for open_temporary_table and open_table_from_share
 
422
 *
 
423
 * @TODO Put this into an appropriate header. It is only needed in:
 
424
 *
 
425
 *    table.cc
 
426
 *    sql_base.cc
 
427
 */
 
428
enum open_table_mode
 
429
{
 
430
  OTM_OPEN= 0,
 
431
  OTM_CREATE= 1,
 
432
  OTM_ALTER= 2
 
433
};
 
434
 
 
435
enum enum_parsing_place
 
436
{
 
437
  NO_MATTER
 
438
  , IN_HAVING
 
439
  , SELECT_LIST
 
440
  , IN_WHERE
 
441
  , IN_ON
 
442
};
 
443
 
 
444
enum enum_mysql_completiontype {
 
445
  ROLLBACK_RELEASE= -2
 
446
  , ROLLBACK= 1
 
447
  , ROLLBACK_AND_CHAIN= 7
 
448
  , COMMIT_RELEASE= -1
 
449
  , COMMIT= 0
 
450
  , COMMIT_AND_CHAIN= 6
 
451
};
 
452
 
 
453
enum enum_check_fields
 
454
{
 
455
  CHECK_FIELD_IGNORE
 
456
  , CHECK_FIELD_WARN
 
457
  , CHECK_FIELD_ERROR_FOR_NULL
 
458
};
 
459
 
 
460
enum enum_var_type
 
461
{
 
462
  OPT_DEFAULT= 0
 
463
  , OPT_SESSION
 
464
  , OPT_GLOBAL
 
465
};
 
466
 
 
467
 
 
468
typedef uint64_t query_id_t;
319
469
typedef void *range_seq_t;
320
470
 
321
 
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
 
471
 
 
472
/**
 
473
   The maximum is defined as (ULONG_MAX/1000) with 4 bytes uint32_t
 
474
*/
 
475
static const uint32_t SLAVE_MAX_HEARTBEAT_PERIOD= 4294967;
 
476
 
 
477
#define SLAVE_NET_TIMEOUT  3600
 
478
 
 
479
#define MAX_SLAVE_ERROR    2000
 
480
 
 
481
/* masks for start/stop operations on io and sql slave threads */
 
482
#define SLAVE_IO  1
 
483
#define SLAVE_SQL 2
 
484
 
 
485
#ifndef NO_HASH
 
486
#define NO_HASH                         /* Not yet implemented */
 
487
#endif
 
488
 
322
489
// the following is for checking tables
323
490
 
324
491
#define HA_ADMIN_ALREADY_DONE     1
329
496
#define HA_ADMIN_INTERNAL_ERROR  -4
330
497
#define HA_ADMIN_INVALID         -5
331
498
#define HA_ADMIN_REJECT          -6
332
 
 
 
499
#define HA_ADMIN_TRY_ALTER       -7
 
500
#define HA_ADMIN_NEEDS_UPGRADE  -10
 
501
#define HA_ADMIN_NEEDS_ALTER    -11
 
502
#define HA_ADMIN_NEEDS_CHECK    -12
 
503
 
 
504
 
 
505
#define HA_ADD_INDEX                  (0)
 
506
#define HA_DROP_INDEX                 (1)
 
507
#define HA_ALTER_INDEX                (2)
 
508
#define HA_RENAME_INDEX               (3)
 
509
#define HA_ADD_UNIQUE_INDEX           (4)
 
510
#define HA_DROP_UNIQUE_INDEX          (5)
 
511
#define HA_ALTER_UNIQUE_INDEX         (6)
 
512
#define HA_RENAME_UNIQUE_INDEX        (7)
 
513
#define HA_ADD_PK_INDEX               (8)
 
514
#define HA_DROP_PK_INDEX              (9)
 
515
#define HA_ALTER_PK_INDEX             (10)
 
516
#define HA_ADD_COLUMN                 (11)
 
517
#define HA_DROP_COLUMN                (12)
 
518
#define HA_CHANGE_COLUMN              (13)
 
519
#define HA_ALTER_COLUMN_NAME          (14)
 
520
#define HA_ALTER_COLUMN_TYPE          (15)
 
521
#define HA_ALTER_COLUMN_ORDER         (16)
 
522
#define HA_ALTER_COLUMN_NULLABLE      (17)
 
523
#define HA_COLUMN_DEFAULT_VALUE       (18)
 
524
#define HA_COLUMN_STORAGE             (19)
 
525
#define HA_COLUMN_FORMAT              (20)
 
526
#define HA_ADD_FOREIGN_KEY            (21)
 
527
#define HA_DROP_FOREIGN_KEY           (22)
 
528
#define HA_ALTER_FOREIGN_KEY          (23)
 
529
#define HA_ADD_CONSTRAINT             (24)
 
530
#define HA_CHANGE_CHARACTER_SET       (30)
 
531
#define HA_SET_DEFAULT_CHARACTER_SET  (31)
 
532
#define HA_CHANGE_AUTOINCREMENT_VALUE (32)
 
533
#define HA_ALTER_STORAGE              (33)
 
534
#define HA_ALTER_TABLESPACE           (34)
 
535
#define HA_ALTER_ROW_FORMAT           (35)
 
536
#define HA_RENAME_TABLE               (36)
 
537
#define HA_ALTER_STORAGE_ENGINE       (37)
 
538
#define HA_RECREATE                   (38)
 
539
#define HA_ALTER_STORED_VCOL          (39)
 
540
/* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
 
541
 
 
542
/* Return values for check_if_supported_alter */
 
543
 
 
544
#define HA_ALTER_ERROR               -1
 
545
#define HA_ALTER_SUPPORTED_WAIT_LOCK  0
 
546
#define HA_ALTER_SUPPORTED_NO_LOCK    1
 
547
#define HA_ALTER_NOT_SUPPORTED        2
 
548
 
 
549
/* Bits in table_flags() to show what database can do */
 
550
 
 
551
#define HA_NO_TRANSACTIONS     (1 << 0) /* Doesn't support transactions */
 
552
#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */
 
553
#define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */
 
554
/*
 
555
  The following should be set if the following is not true when scanning
 
556
  a table with rnd_next()
 
557
  - We will see all rows (including deleted ones)
 
558
  - Row positions are 'table->s->db_record_offset' apart
 
559
  If this flag is not set, filesort will do a postion() call for each matched
 
560
  row to be able to find the row later.
 
561
*/
 
562
#define HA_REC_NOT_IN_SEQ      (1 << 3)
 
563
 
 
564
/*
 
565
  Reading keys in random order is as fast as reading keys in sort order
 
566
  (Used in records.cc to decide if we should use a record cache and by
 
567
  filesort to decide if we should sort key + data or key + pointer-to-row
 
568
*/
 
569
#define HA_FAST_KEY_READ       (1 << 5)
 
570
/*
 
571
  Set the following flag if we on delete should force all key to be read
 
572
  and on update read all keys that changes
 
573
*/
 
574
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6)
 
575
#define HA_NULL_IN_KEY         (1 << 7) /* One can have keys with NULL */
 
576
#define HA_DUPLICATE_POS       (1 << 8)    /* ha_position() gives dup row */
 
577
#define HA_NO_BLOBS            (1 << 9) /* Doesn't support blobs */
 
578
#define HA_CAN_INDEX_BLOBS     (1 << 10)
 
579
#define HA_AUTO_PART_KEY       (1 << 11) /* auto-increment in multi-part key */
 
580
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */
 
581
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */
 
582
/*
 
583
  If we get the primary key columns for free when we do an index read
 
584
  It also implies that we have to retrive the primary key when using
 
585
  position() and rnd_pos().
 
586
*/
 
587
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
 
588
/*
 
589
  If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
 
590
  uses a primary key. Without primary key, we can't call position().
 
591
*/
 
592
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16)
333
593
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
 
594
/*
 
595
  The following is we need to a primary key to delete (and update) a row.
 
596
  If there is no primary key, all columns needs to be read on update and delete
 
597
*/
 
598
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
 
599
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
 
600
#define HA_NO_AUTO_INCREMENT   (1 << 23)
 
601
#define HA_HAS_CHECKSUM        (1 << 24)
 
602
/* Table data are stored in separate files (for lower_case_table_names) */
 
603
#define HA_FILE_BASED          (1 << 26)
 
604
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
 
605
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
 
606
#define HA_NO_COPY_ON_ALTER    (INT64_C(1) << 31)
 
607
#define HA_HAS_RECORDS         (INT64_C(1) << 32) /* records() gives exact count*/
 
608
#define HA_MRR_CANT_SORT       (INT64_C(1) << 34)
 
609
 
 
610
/*
 
611
  Engine is capable of row-format and statement-format logging,
 
612
  respectively
 
613
*/
 
614
#define HA_BINLOG_ROW_CAPABLE  (INT64_C(1) << 35)
 
615
#define HA_BINLOG_STMT_CAPABLE (INT64_C(1) << 36)
 
616
 
 
617
#define HA_ONLINE_ALTER        (INT64_C(1) << 37)
 
618
 
 
619
/*
 
620
  Set of all binlog flags. Currently only contain the capabilities
 
621
  flags.
 
622
 */
 
623
#define HA_BINLOG_FLAGS (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE)
334
624
 
335
625
/* bits in index_flags(index_number) for what you can do with index */
336
626
#define HA_READ_NEXT            1       /* TODO really use this flag */
386
676
#define HA_KEY_NULL_LENGTH      1
387
677
#define HA_KEY_BLOB_LENGTH      2
388
678
 
 
679
#define HA_LEX_CREATE_TMP_TABLE 1
 
680
#define HA_LEX_CREATE_IF_NOT_EXISTS 2
 
681
#define HA_LEX_CREATE_TABLE_LIKE 4
 
682
#define HA_OPTION_NO_CHECKSUM   (1L << 17)
 
683
#define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18)
389
684
#define HA_MAX_REC_LENGTH       65535
390
685
 
 
686
/* Table caching type */
 
687
#define HA_CACHE_TBL_NONTRANSACT 0
 
688
#define HA_CACHE_TBL_NOCACHE     1
 
689
#define HA_CACHE_TBL_ASKTRANSACT 2
 
690
#define HA_CACHE_TBL_TRANSACT    4
 
691
 
391
692
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
392
 
enum start_transaction_option_t
393
 
{
394
 
  START_TRANS_NO_OPTIONS,
395
 
  START_TRANS_OPT_WITH_CONS_SNAPSHOT
396
 
};
 
693
#define DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
397
694
 
398
695
/* Flags for method is_fatal_error */
399
696
#define HA_CHECK_DUP_KEY 1
400
697
#define HA_CHECK_DUP_UNIQUE 2
401
698
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
402
699
 
 
700
enum legacy_db_type
 
701
{
 
702
  DB_TYPE_UNKNOWN=0,
 
703
  DB_TYPE_FIRST_DYNAMIC=42,
 
704
  DB_TYPE_DEFAULT=127 // Must be last
 
705
};
 
706
 
 
707
enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED,
 
708
                ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED,
 
709
                ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGE };
 
710
 
 
711
enum column_format_type { COLUMN_FORMAT_TYPE_NOT_USED= -1,
 
712
                          COLUMN_FORMAT_TYPE_DEFAULT=   0,
 
713
                          COLUMN_FORMAT_TYPE_FIXED=     1,
 
714
                          COLUMN_FORMAT_TYPE_DYNAMIC=   2 };
 
715
 
 
716
enum enum_binlog_func {
 
717
  BFN_RESET_LOGS=        1,
 
718
  BFN_RESET_SLAVE=       2,
 
719
  BFN_BINLOG_WAIT=       3,
 
720
  BFN_BINLOG_END=        4,
 
721
  BFN_BINLOG_PURGE_FILE= 5
 
722
};
 
723
 
 
724
enum enum_binlog_command {
 
725
  LOGCOM_CREATE_TABLE,
 
726
  LOGCOM_ALTER_TABLE,
 
727
  LOGCOM_RENAME_TABLE,
 
728
  LOGCOM_DROP_TABLE,
 
729
  LOGCOM_CREATE_DB,
 
730
  LOGCOM_ALTER_DB,
 
731
  LOGCOM_DROP_DB
 
732
};
 
733
 
 
734
/* struct to hold information about the table that should be created */
403
735
 
404
736
/* Bits in used_fields */
405
737
#define HA_CREATE_USED_AUTO             (1L << 0)
 
738
#ifdef DEAD_OPTIONS
 
739
#define HA_CREATE_USED_UNION            (1L << 2)
 
740
#define HA_CREATE_USED_PASSWORD         (1L << 17)
 
741
#endif
 
742
#define HA_CREATE_USED_INSERT_METHOD    (1L << 3)
 
743
#define HA_CREATE_USED_MIN_ROWS         (1L << 4)
 
744
#define HA_CREATE_USED_MAX_ROWS         (1L << 5)
 
745
#define HA_CREATE_USED_AVG_ROW_LENGTH   (1L << 6)
 
746
#define HA_CREATE_USED_PACK_KEYS        (1L << 7)
406
747
#define HA_CREATE_USED_CHARSET          (1L << 8)
407
748
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
 
749
#define HA_CREATE_USED_DATADIR          (1L << 10)
 
750
#define HA_CREATE_USED_INDEXDIR         (1L << 11)
 
751
#define HA_CREATE_USED_ENGINE           (1L << 12)
 
752
#define HA_CREATE_USED_CHECKSUM         (1L << 13)
 
753
#define HA_CREATE_USED_DELAY_KEY_WRITE  (1L << 14)
408
754
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
 
755
#define HA_CREATE_USED_COMMENT          (1L << 16)
 
756
#define HA_CREATE_USED_CONNECTION       (1L << 18)
409
757
#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)
 
758
#define HA_CREATE_USED_PAGE_CHECKSUM    (1L << 21)
410
759
#define HA_CREATE_USED_BLOCK_SIZE       (1L << 22)
411
760
 
412
761
#define MAXGTRIDSIZE 64
413
762
#define MAXBQUALSIZE 64
414
763
 
 
764
#define COMPATIBLE_DATA_YES 0
 
765
#define COMPATIBLE_DATA_NO  1
 
766
 
 
767
#define UNDEF_NODEGROUP 65535
 
768
#define NOT_A_PARTITION_ID ((uint32_t)-1)
 
769
 
 
770
enum ha_choice { HA_CHOICE_UNDEF, HA_CHOICE_NO, HA_CHOICE_YES };
 
771
 
415
772
/*
416
773
  The below two are not used (and not handled) in this milestone of this WL
417
774
  entry because there seems to be no use for them at this stage of
450
807
*/
451
808
#define HA_MRR_USE_DEFAULT_IMPL 64
452
809
 
 
810
/*
 
811
  Used only as parameter to multi_range_read_info():
 
812
  Flag set <=> the caller guarantees that the bounds of the scanned ranges
 
813
  will not have NULL values.
 
814
*/
 
815
#define HA_MRR_NO_NULL_ENDPOINTS 128
 
816
 
 
817
enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY, RNEXT_SAME };
 
818
 
 
819
enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED,
 
820
                         ISO_REPEATABLE_READ, ISO_SERIALIZABLE};
 
821
 
 
822
 
 
823
enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
 
824
 
453
825
typedef int myf;
454
826
#define MYF(v)          (myf) (v)
455
827
 
 
828
/*
 
829
  When a command is added here, be sure it's also added in mysqld.cc
 
830
  in "struct show_var_st status_vars[]= {" ...
 
831
 
 
832
  If the command returns a result set or is not allowed in stored
 
833
  functions or triggers, please also make sure that
 
834
  sp_get_flags_for_command (sp_head.cc) returns proper flags for the
 
835
  added SQLCOM_.
 
836
*/
 
837
 
 
838
enum enum_sql_command {
 
839
  SQLCOM_SELECT, SQLCOM_CREATE_TABLE, SQLCOM_CREATE_INDEX, SQLCOM_ALTER_TABLE,
 
840
  SQLCOM_UPDATE, SQLCOM_INSERT, SQLCOM_INSERT_SELECT,
 
841
  SQLCOM_DELETE, SQLCOM_TRUNCATE, SQLCOM_DROP_TABLE, SQLCOM_DROP_INDEX,
 
842
  SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS,
 
843
  SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_STATUS,
 
844
  SQLCOM_SHOW_ENGINE_LOGS, SQLCOM_SHOW_ENGINE_STATUS, SQLCOM_SHOW_ENGINE_MUTEX,
 
845
  SQLCOM_SHOW_PROCESSLIST,
 
846
  SQLCOM_SHOW_CREATE,
 
847
  SQLCOM_SHOW_CREATE_DB,
 
848
  SQLCOM_SHOW_TABLE_STATUS,
 
849
  SQLCOM_LOAD,SQLCOM_SET_OPTION,SQLCOM_LOCK_TABLES,SQLCOM_UNLOCK_TABLES,
 
850
  SQLCOM_CHANGE_DB, SQLCOM_CREATE_DB, SQLCOM_DROP_DB, SQLCOM_ALTER_DB,
 
851
  SQLCOM_REPAIR, SQLCOM_REPLACE, SQLCOM_REPLACE_SELECT,
 
852
  SQLCOM_OPTIMIZE, SQLCOM_CHECK,
 
853
  SQLCOM_ASSIGN_TO_KEYCACHE,
 
854
  SQLCOM_FLUSH, SQLCOM_KILL, SQLCOM_ANALYZE,
 
855
  SQLCOM_ROLLBACK, SQLCOM_ROLLBACK_TO_SAVEPOINT,
 
856
  SQLCOM_COMMIT, SQLCOM_SAVEPOINT, SQLCOM_RELEASE_SAVEPOINT,
 
857
  SQLCOM_SLAVE_START, SQLCOM_SLAVE_STOP,
 
858
  SQLCOM_BEGIN,
 
859
  SQLCOM_RENAME_TABLE,
 
860
  SQLCOM_SHOW_OPEN_TABLES,
 
861
  SQLCOM_DELETE_MULTI, SQLCOM_UPDATE_MULTI,
 
862
  SQLCOM_SHOW_WARNS,
 
863
  SQLCOM_EMPTY_QUERY,
 
864
  SQLCOM_SHOW_ERRORS,
 
865
  SQLCOM_CHECKSUM,
 
866
  SQLCOM_SHOW_PLUGINS,
 
867
  /*
 
868
    When a command is added here, be sure it's also added in mysqld.cc
 
869
    in "struct show_var_st status_vars[]= {" ...
 
870
  */
 
871
  /* This should be the last !!! */
 
872
  SQLCOM_END
 
873
};
 
874
 
 
875
enum enum_duplicates { DUP_ERROR, DUP_REPLACE, DUP_UPDATE };
 
876
 
 
877
enum release_type { RELEASE_NORMAL, RELEASE_WAIT_FOR_DROP };
 
878
 
 
879
/*
 
880
  Make sure that the order of schema_tables and enum_schema_tables are the same.
 
881
*/
 
882
 
 
883
enum enum_schema_tables
 
884
{
 
885
  SCH_CHARSETS= 0,
 
886
  SCH_COLLATIONS,
 
887
  SCH_COLLATION_CHARACTER_SET_APPLICABILITY,
 
888
  SCH_COLUMNS,
 
889
  SCH_GLOBAL_STATUS,
 
890
  SCH_GLOBAL_VARIABLES,
 
891
  SCH_KEY_COLUMN_USAGE,
 
892
  SCH_OPEN_TABLES,
 
893
  SCH_PLUGINS,
 
894
  SCH_PROCESSLIST,
 
895
  SCH_REFERENTIAL_CONSTRAINTS,
 
896
  SCH_SCHEMATA,
 
897
  SCH_SESSION_STATUS,
 
898
  SCH_SESSION_VARIABLES,
 
899
  SCH_STATISTICS,
 
900
  SCH_STATUS,
 
901
  SCH_TABLES,
 
902
  SCH_TABLE_CONSTRAINTS,
 
903
  SCH_TABLE_NAMES,
 
904
  SCH_VARIABLES
 
905
};
 
906
 
 
907
 
456
908
#define MY_I_S_MAYBE_NULL 1
457
909
#define MY_I_S_UNSIGNED   2
458
910
 
459
911
 
 
912
#define SKIP_OPEN_TABLE 0                // do not open table
 
913
#define OPEN_FRM_ONLY   1                // open FRM file only
 
914
#define OPEN_FULL_TABLE 2                // open FRM,MYD, MYI files
 
915
 
460
916
/*
461
917
   "Declared Type Collation"
462
918
   A combination of collation and its derivation.
478
934
#define MY_COLL_ALLOW_CONV            3
479
935
#define MY_COLL_DISALLOW_NONE         4
480
936
#define MY_COLL_CMP_CONV              7
 
937
 
 
938
 
 
939
/*
 
940
  This enum is used to report information about monotonicity of function
 
941
  represented by Item* tree.
 
942
  Monotonicity is defined only for Item* trees that represent table
 
943
  partitioning expressions (i.e. have no subselects/user vars/PS parameters
 
944
  etc etc). An Item* tree is assumed to have the same monotonicity properties
 
945
  as its correspoinding function F:
 
946
 
 
947
  [signed] int64_t F(field1, field2, ...) {
 
948
    put values of field_i into table record buffer;
 
949
    return item->val_int();
 
950
  }
 
951
 
 
952
  NOTE
 
953
  At the moment function monotonicity is not well defined (and so may be
 
954
  incorrect) for Item trees with parameters/return types that are different
 
955
  from INT_RESULT, may be NULL, or are unsigned.
 
956
  It will be possible to address this issue once the related partitioning bugs
 
957
  (BUG#16002, BUG#15447, BUG#13436) are fixed.
 
958
*/
 
959
 
 
960
typedef enum monotonicity_info
 
961
{
 
962
   NON_MONOTONIC,              /* none of the below holds */
 
963
   MONOTONIC_INCREASING,       /* F() is unary and (x < y) => (F(x) <= F(y)) */
 
964
   MONOTONIC_STRICT_INCREASING /* F() is unary and (x < y) => (F(x) <  F(y)) */
 
965
} enum_monotonicity_info;
 
966
 
 
967
enum tmp_table_type
 
968
{
 
969
  NO_TMP_TABLE, NON_TRANSACTIONAL_TMP_TABLE, TRANSACTIONAL_TMP_TABLE,
 
970
  INTERNAL_TMP_TABLE, SYSTEM_TMP_TABLE, TMP_TABLE_FRM_FILE_ONLY
 
971
};
 
972
 
 
973
/*
 
974
  Values in this enum are used to indicate how a tables TIMESTAMP field
 
975
  should be treated. It can be set to the current timestamp on insert or
 
976
  update or both.
 
977
  WARNING: The values are used for bit operations. If you change the
 
978
  enum, you must keep the bitwise relation of the values. For example:
 
979
  (int) TIMESTAMP_AUTO_SET_ON_BOTH must be equal to
 
980
  (int) TIMESTAMP_AUTO_SET_ON_INSERT | (int) TIMESTAMP_AUTO_SET_ON_UPDATE.
 
981
  We use an enum here so that the debugger can display the value names.
 
982
*/
 
983
enum timestamp_auto_set_type
 
984
{
 
985
  TIMESTAMP_NO_AUTO_SET= 0, TIMESTAMP_AUTO_SET_ON_INSERT= 1,
 
986
  TIMESTAMP_AUTO_SET_ON_UPDATE= 2, TIMESTAMP_AUTO_SET_ON_BOTH= 3
 
987
};
481
988
#define clear_timestamp_auto_bits(_target_, _bits_) \
482
989
  (_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
483
990
 
 
991
/**
 
992
  Category of table found in the table share.
 
993
*/
 
994
enum enum_table_category
 
995
{
 
996
  /**
 
997
    Unknown value.
 
998
  */
 
999
  TABLE_UNKNOWN_CATEGORY=0,
 
1000
 
 
1001
  /**
 
1002
    Temporary table.
 
1003
    The table is visible only in the session.
 
1004
    Therefore,
 
1005
    - FLUSH TABLES WITH READ LOCK
 
1006
    - SET GLOBAL READ_ONLY = ON
 
1007
    do not apply to this table.
 
1008
    Note that LOCK Table t FOR READ/WRITE
 
1009
    can be used on temporary tables.
 
1010
    Temporary tables are not part of the table cache.
 
1011
  */
 
1012
  TABLE_CATEGORY_TEMPORARY=1,
 
1013
 
 
1014
  /**
 
1015
    User table.
 
1016
    These tables do honor:
 
1017
    - LOCK Table t FOR READ/WRITE
 
1018
    - FLUSH TABLES WITH READ LOCK
 
1019
    - SET GLOBAL READ_ONLY = ON
 
1020
    User tables are cached in the table cache.
 
1021
  */
 
1022
  TABLE_CATEGORY_USER=2,
 
1023
 
 
1024
  /**
 
1025
    Information schema tables.
 
1026
    These tables are an interface provided by the system
 
1027
    to inspect the system metadata.
 
1028
    These tables do *not* honor:
 
1029
    - LOCK Table t FOR READ/WRITE
 
1030
    - FLUSH TABLES WITH READ LOCK
 
1031
    - SET GLOBAL READ_ONLY = ON
 
1032
    as there is no point in locking explicitely
 
1033
    an INFORMATION_SCHEMA table.
 
1034
    Nothing is directly written to information schema tables.
 
1035
    Note that this value is not used currently,
 
1036
    since information schema tables are not shared,
 
1037
    but implemented as session specific temporary tables.
 
1038
  */
 
1039
  /*
 
1040
    TODO: Fixing the performance issues of I_S will lead
 
1041
    to I_S tables in the table cache, which should use
 
1042
    this table type.
 
1043
  */
 
1044
  TABLE_CATEGORY_INFORMATION
 
1045
};
 
1046
 
 
1047
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
 
1048
enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON,
 
1049
                            DELAY_KEY_WRITE_ALL };
 
1050
enum enum_slave_exec_mode { SLAVE_EXEC_MODE_STRICT,
 
1051
                            SLAVE_EXEC_MODE_IDEMPOTENT,
 
1052
                            SLAVE_EXEC_MODE_LAST_BIT};
 
1053
enum enum_mark_columns
 
1054
{ MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE};
 
1055
 
 
1056
enum enum_filetype { FILETYPE_CSV, FILETYPE_XML };
 
1057
 
 
1058
enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND,
 
1059
                                  IGNORE_ERRORS, REPORT_EXCEPT_NON_UNIQUE,
 
1060
                                  IGNORE_EXCEPT_NON_UNIQUE};
 
1061
 
 
1062
enum enum_schema_table_state
 
1063
{
 
1064
  NOT_PROCESSED= 0,
 
1065
  PROCESSED_BY_CREATE_SORT_INDEX,
 
1066
  PROCESSED_BY_JOIN_EXEC
 
1067
};
 
1068
 
484
1069
/*
485
1070
 * The following are for the interface with the .frm file
486
1071
 */
487
1072
 
 
1073
#define FIELDFLAG_DECIMAL    1
 
1074
#define FIELDFLAG_BINARY    1  // Shares same flag
 
1075
#define FIELDFLAG_NUMBER    2
 
1076
#define FIELDFLAG_DECIMAL_POSITION      4
 
1077
#define FIELDFLAG_PACK      120  // Bits used for packing
 
1078
#define FIELDFLAG_INTERVAL    256     // mangled with decimals!
 
1079
#define FIELDFLAG_BLOB      1024  // mangled with decimals!
 
1080
 
 
1081
#define FIELDFLAG_NO_DEFAULT    16384   /* sql */
 
1082
#define FIELDFLAG_SUM      ((uint32_t) 32768)// predit: +#fieldflag
 
1083
#define FIELDFLAG_MAYBE_NULL    ((uint32_t) 32768)// sql
 
1084
#define FIELDFLAG_HEX_ESCAPE    ((uint32_t) 0x10000)
488
1085
#define FIELDFLAG_PACK_SHIFT    3
 
1086
#define FIELDFLAG_DEC_SHIFT    8
489
1087
#define FIELDFLAG_MAX_DEC    31
490
1088
 
491
1089
#define MTYP_TYPENR(type) (type & 127)  /* Remove bits from type */
492
1090
 
 
1091
#define f_is_dec(x)     ((x) & FIELDFLAG_DECIMAL)
 
1092
#define f_is_num(x)     ((x) & FIELDFLAG_NUMBER)
 
1093
#define f_is_decimal_precision(x)  ((x) & FIELDFLAG_DECIMAL_POSITION)
 
1094
#define f_is_packed(x)  ((x) & FIELDFLAG_PACK)
493
1095
#define f_packtype(x)   (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
 
1096
#define f_decimals(x)   ((uint8_t) (((x) >> FIELDFLAG_DEC_SHIFT) & \
 
1097
                                     FIELDFLAG_MAX_DEC))
 
1098
#define f_is_alpha(x)   (!f_is_num(x))
 
1099
#define f_is_binary(x)  ((x) & FIELDFLAG_BINARY) // 4.0- compatibility
 
1100
#define f_is_enum(x)    (((x) & (FIELDFLAG_INTERVAL | FIELDFLAG_NUMBER)) == \
 
1101
                         FIELDFLAG_INTERVAL)
 
1102
#define f_is_blob(x)    (((x) & (FIELDFLAG_BLOB | FIELDFLAG_NUMBER)) == \
 
1103
                         FIELDFLAG_BLOB)
 
1104
#define f_is_equ(x)     ((x) & (1+2+FIELDFLAG_PACK+31*256))
494
1105
#define f_settype(x)    (((int) x) << FIELDFLAG_PACK_SHIFT)
495
 
 
496
 
 
497
 
#ifdef __cplusplus
498
 
template <class T> void set_if_bigger(T &a, const T &b)
499
 
{
500
 
  if (a < b)
501
 
    a=b;
502
 
}
503
 
 
504
 
template <class T> void set_if_smaller(T &a, const T &b)
505
 
{
506
 
  if (a > b)
507
 
    a=b;
508
 
}
509
 
#else
510
 
#ifdef __GNUC__
511
 
#define set_if_bigger(a,b) do {                 \
512
 
  const typeof(a) _a = (a);                     \
513
 
  const typeof(b) _b = (b);                     \
514
 
  (void) (&_a == &_b);                          \
515
 
  if ((a) < (b)) (a)=(b);                       \
516
 
  } while(0)
517
 
#define set_if_smaller(a,b) do {                \
518
 
  const typeof(a) _a = (a);                     \
519
 
  const typeof(b) _b = (b);                     \
520
 
  (void) (&_a == &_b);                          \
521
 
  if ((a) > (b)) (a)=(b);                       \
522
 
  } while(0)
523
 
 
524
 
#else
525
 
#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
526
 
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
527
 
#endif
528
 
#endif
529
 
 
530
 
 
531
 
#define array_elements(a) \
532
 
  ((sizeof(a) / sizeof(*(a))) / \
533
 
   static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
534
 
 
535
 
 
536
 
/* Some types that is different between systems */
537
 
 
538
 
#ifndef FN_LIBCHAR
539
 
#define FN_LIBCHAR  '/'
540
 
#define FN_ROOTDIR  "/"
541
 
#endif
542
 
#define MY_NFILE  64  /* This is only used to save filenames */
543
 
#ifndef OS_FILE_LIMIT
544
 
#define OS_FILE_LIMIT  65535
545
 
#endif
546
 
 
547
 
/*
548
 
  How much overhead does malloc have. The code often allocates
549
 
  something like 1024-MALLOC_OVERHEAD bytes
550
 
*/
551
 
#define MALLOC_OVERHEAD 8
552
 
 
553
 
/* get memory in huncs */
554
 
static const uint32_t ONCE_ALLOC_INIT= 4096;
555
 
/* Typical record cash */
556
 
static const uint32_t RECORD_CACHE_SIZE= 64*1024;
557
 
/* Typical key cash */
558
 
static const uint32_t KEY_CACHE_SIZE= 8*1024*1024;
559
 
 
560
 
/* Default size of a key cache block  */
561
 
static const uint32_t KEY_CACHE_BLOCK_SIZE= 1024;
562
 
 
563
 
 
564
 
/* Some things that this system doesn't have */
565
 
 
566
 
/* Some defines of functions for portability */
567
 
 
568
 
#undef remove    /* Crashes MySQL on SCO 5.0.0 */
569
 
#ifndef uint64_t2double
570
 
#define uint64_t2double(A) ((double) (uint64_t) (A))
571
 
#endif
572
 
 
573
 
#ifndef offsetof
574
 
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
575
 
#endif
576
 
#define ulong_to_double(X) ((double) (ulong) (X))
577
 
 
578
 
#ifndef STACK_DIRECTION
579
 
#error "please add -DSTACK_DIRECTION=1 or -1 to your CPPFLAGS"
580
 
#endif
581
 
 
582
 
/* From limits.h instead */
583
 
#ifndef DBL_MIN
584
 
#define DBL_MIN    4.94065645841246544e-324
585
 
#endif
586
 
#ifndef DBL_MAX
587
 
#define DBL_MAX    1.79769313486231470e+308
588
 
#endif
589
 
 
590
 
 
591
 
/* Define missing math constants. */
592
 
#ifndef M_PI
593
 
#define M_PI 3.14159265358979323846
594
 
#endif
595
 
#ifndef M_E
596
 
#define M_E 2.7182818284590452354
597
 
#endif
598
 
#ifndef M_LN2
599
 
#define M_LN2 0.69314718055994530942
600
 
#endif
601
 
 
602
 
/*
603
 
  Max size that must be added to a so that we know Size to make
604
 
  adressable obj.
605
 
*/
606
 
#define MY_ALIGN(A,L)  (((A) + (L) - 1) & ~((L) - 1))
607
 
#define ALIGN_SIZE(A)  MY_ALIGN((A),sizeof(double))
608
 
/* Size to make adressable obj. */
609
 
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
610
 
/* Offset of field f in structure t */
611
 
#define OFFSET(t, f)  ((size_t)(char *)&((t *)0)->f)
612
 
#ifdef __cplusplus
613
 
#define ADD_TO_PTR(ptr,size,type) (type) (reinterpret_cast<const unsigned char*>(ptr)+size)
614
 
#define PTR_BYTE_DIFF(A,B) (ptrdiff_t) (reinterpret_cast<const unsigned char*>(A) - reinterpret_cast<const unsigned char*>(B))
615
 
#else
616
 
 #define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
617
 
 #define PTR_BYTE_DIFF(A,B) (ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
618
 
#endif
619
 
 
620
 
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
621
 
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
622
 
 
623
 
/* Typdefs for easyier portability */
624
 
 
625
 
 
626
 
#if defined(SIZEOF_OFF_T)
627
 
# if (SIZEOF_OFF_T == 8)
628
 
#  define OFF_T_MAX (INT64_MAX)
629
 
# else
630
 
#  define OFF_T_MAX (INT32_MAX)
631
 
# endif
632
 
#endif
633
 
 
634
 
#define MY_FILEPOS_ERROR  -1
635
 
 
636
 
/* Defines for time function */
637
 
#define SCALE_SEC  100
638
 
#define SCALE_USEC  10000
639
 
 
640
 
#define DRIZZLE_SERVER
641
 
 
642
 
/* Length of decimal number represented by INT32. */
643
 
#define MY_INT32_NUM_DECIMAL_DIGITS 11
644
 
 
645
 
/* Length of decimal number represented by INT64. */
646
 
#define MY_INT64_NUM_DECIMAL_DIGITS 21
647
 
 
648
 
/*
649
 
  Io buffer size; Must be a power of 2 and
650
 
  a multiple of 512. May be
651
 
  smaller what the disk page size. This influences the speed of the
652
 
  isam btree library. eg to big to slow.
653
 
*/
654
 
#define IO_SIZE 4096
655
 
/* Max file name len */
656
 
#define FN_LEN 256
657
 
/* Max length of extension (part of FN_LEN) */
658
 
#define FN_EXTLEN 20
659
 
/* Max length of full path-name */
660
 
#define FN_REFLEN 512
661
 
/* File extension character */
662
 
#define FN_EXTCHAR '.'
663
 
/* ~ is used as abbrev for home dir */
664
 
#define FN_HOMELIB '~'
665
 
/* ./ is used as abbrev for current dir */
666
 
#define FN_CURLIB '.'
667
 
/* Parent directory; Must be a string */
668
 
#define FN_PARENTDIR ".."
669
 
 
670
 
/* Quote argument (before cpp) */
671
 
#ifndef QUOTE_ARG
672
 
# define QUOTE_ARG(x) #x
673
 
#endif
674
 
/* Quote argument, (after cpp) */
675
 
#ifndef STRINGIFY_ARG
676
 
# define STRINGIFY_ARG(x) QUOTE_ARG(x)
677
 
#endif
678
 
 
679
 
/*
680
 
 * The macros below are borrowed from include/linux/compiler.h in the
681
 
 * Linux kernel. Use them to indicate the likelyhood of the truthfulness
682
 
 * of a condition. This serves two purposes - newer versions of gcc will be
683
 
 * able to optimize for branch predication, which could yield siginficant
684
 
 * performance gains in frequently executed sections of the code, and the
685
 
 * other reason to use them is for documentation
686
 
 */
687
 
#if !defined(__GNUC__)
688
 
#define __builtin_expect(x, expected_value) (x)
689
 
#endif
690
 
 
691
 
#define likely(x)  __builtin_expect((x),1)
692
 
#define unlikely(x)  __builtin_expect((x),0)
693
 
 
694
 
 
695
 
/*
696
 
  Only Linux is known to need an explicit sync of the directory to make sure a
697
 
  file creation/deletion/renaming in(from,to) this directory durable.
698
 
*/
699
 
#ifdef TARGET_OS_LINUX
700
 
#define NEED_EXPLICIT_SYNC_DIR 1
701
 
#endif
702
 
 
703
 
/* We need to turn off _DTRACE_VERSION if we're not going to use dtrace */
704
 
#if !defined(HAVE_DTRACE)
705
 
# undef _DTRACE_VERSION
706
 
# define _DTRACE_VERSION 0
707
 
#endif
708
 
 
709
 
#endif /* DRIZZLED_DEFINITIONS_H */
 
1106
#define f_maybe_null(x) (x & FIELDFLAG_MAYBE_NULL)
 
1107
#define f_no_default(x) (x & FIELDFLAG_NO_DEFAULT)
 
1108
#define f_is_hex_escape(x) ((x) & FIELDFLAG_HEX_ESCAPE)
 
1109
 
 
1110
#endif /* DRIZZLE_SERVER_DEFINITIONS_H */
 
1111