~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definitions.h

  • Committer: Stewart Smith
  • Date: 2009-06-16 00:46:49 UTC
  • mto: (1119.2.6 merge)
  • mto: This revision was merged to the branch mainline in revision 1124.
  • Revision ID: stewart@flamingspork.com-20090616004649-k2qt6b31sorpi6am
make type_blob test not leave tables behind

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
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
 
26
#ifndef DRIZZLE_SERVER_DEFINITIONS_H
 
27
#define DRIZZLE_SERVER_DEFINITIONS_H
28
28
 
29
29
#include <drizzled/enum.h>
30
30
 
31
31
#include <stdint.h>
32
32
 
33
 
#include "common.h"
34
 
 
35
 
namespace drizzled
36
 
{
37
 
 
38
 
/* Global value for how we extend our temporary directory */
39
 
#define GLOBAL_TEMPORARY_EXT ".temporary"
40
 
 
41
33
/* These paths are converted to other systems (WIN95) before use */
42
34
 
43
35
#define LANGUAGE        "english/"
44
36
#define TEMP_PREFIX     "MY"
45
37
#define LOG_PREFIX      "ML"
46
 
 
47
 
#define ER(X) ::drizzled::error_message((X))
48
 
 
49
 
/* buffer size for strerror_r() */
50
 
#define STRERROR_MAX 256
51
 
 
 
38
#define PROGDIR         "bin/"
 
39
 
 
40
#define ER(X) error_message((X))
 
41
 
 
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)
54
45
#define MAX_ALIAS_NAME 256
55
46
#define MAX_FIELD_NAME 34                       /* Max colum name length +2 */
56
47
#define MAX_SYS_VAR_LENGTH 32
57
 
#define MAX_INDEXES 64
58
48
#define MAX_KEY MAX_INDEXES                     /* Max used keys */
59
49
#define MAX_REF_PARTS 16                        /* Max parts used as ref */
60
50
#define MAX_KEY_LENGTH 4096                     /* max possible key */
61
51
#define MAX_KEY_LENGTH_DECIMAL_WIDTH 4          /* strlen("4096") */
62
 
 
63
52
#if SIZEOF_OFF_T > 4
64
53
#define MAX_REFLENGTH 8                         /* Max length for record ref */
65
54
#else
83
72
#define RAND_TABLE_BIT  (((table_map) 1) << (sizeof(table_map)*8-1))
84
73
#define PSEUDO_TABLE_BITS (PARAM_TABLE_BIT | OUTER_REF_TABLE_BIT | \
85
74
                           RAND_TABLE_BIT)
86
 
#define MAX_FIELDS      4096      /* Historical limit from MySQL FRM. */
 
75
#define MAX_FIELDS      4096                    /* Limit in the .frm file */
87
76
 
88
77
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
89
78
 
90
79
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
91
80
#define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
92
81
 
 
82
/* Memory allocated when parsing a statement / saving a statement */
 
83
#define MEM_ROOT_BLOCK_SIZE       8192
 
84
#define MEM_ROOT_PREALLOC         8192
 
85
#define TRANS_MEM_ROOT_BLOCK_SIZE 4096
 
86
#define TRANS_MEM_ROOT_PREALLOC   4096
 
87
 
93
88
#define DEFAULT_ERROR_COUNT     64
94
89
#define EXTRA_RECORDS   10                      /* Extra records in sort */
 
90
#define SCROLL_EXTRA    5                       /* Extra scroll-rows. */
 
91
#define FIELD_NAME_USED ((uint32_t) 32768)              /* Bit set if fieldname used */
 
92
#define FIELD_NR_MASK   16383                   /* To get fieldnumber */
 
93
#define FERR            -1                      /* Error from my_functions */
 
94
#define CREATE_MODE     0                       /* Default mode on new files */
95
95
#define NAMES_SEP_CHAR  '\377'                  /* Char to sep. names */
96
96
 
97
97
#define READ_RECORD_BUFFER      (uint32_t) (IO_SIZE*8) /* Pointer_buffer_size */
98
98
#define DISK_BUFFER_SIZE        (uint32_t) (IO_SIZE*16) /* Size of diskbuffer */
99
99
 
 
100
#define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH)
100
101
#define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH)
101
102
#define MYF_RW MYF(MY_WME+MY_NABP)              /* Vid my_read & my_write */
102
103
 
 
104
        /* Defines for use with openfrm, openprt and openfrd */
 
105
 
 
106
#define READ_ALL                1       /* openfrm: Read all parameters */
 
107
#define CHANGE_FRM              2       /* openfrm: open .frm as O_RDWR */
 
108
#define EXTRA_RECORD            8       /* Reservera plats f|r extra record */
 
109
#define DONT_GIVE_ERROR         256     /* Don't do frm_error on openfrm  */
 
110
#define DELAYED_OPEN            4096    /* Open table later */
 
111
/**
 
112
  This flag is used in function get_all_tables() which fills
 
113
  I_S tables with data which are retrieved from frm files and storage engine
 
114
  The flag means that we need to open FRM file only to get necessary data.
 
115
*/
 
116
#define OPEN_FRM_FILE_ONLY     32768
 
117
/**
 
118
  This flag is used in function get_all_tables() which fills
 
119
  I_S tables with data which are retrieved from frm files and storage engine
 
120
  The flag means that we need to process tables only to get necessary data.
 
121
  Views are not processed.
 
122
*/
 
123
#define OPEN_TABLE_ONLY        OPEN_FRM_FILE_ONLY*2
 
124
/**
 
125
  This flag is used in function get_all_tables() which fills
 
126
  I_S tables with data which are retrieved from frm files and storage engine.
 
127
  The flag means that I_S table uses optimization algorithm.
 
128
*/
 
129
#define OPTIMIZE_I_S_TABLE     OPEN_TABLE_ONLY*2
 
130
 
103
131
/*
104
132
  Minimum length pattern before Turbo Boyer-Moore is used
105
133
  for SELECT "text" LIKE "%pattern%", excluding the two
107
135
*/
108
136
#define MIN_TURBOBM_PATTERN_LEN 3
109
137
 
 
138
/*
 
139
   Defines for binary logging.
 
140
   Do not decrease the value of BIN_LOG_HEADER_SIZE.
 
141
   Do not even increase it before checking code.
 
142
*/
 
143
 
 
144
#define BIN_LOG_HEADER_SIZE    4
 
145
 
 
146
#define DEFAULT_KEY_CACHE_NAME "default"
 
147
 
 
148
#define STORAGE_TYPE_MASK 7
 
149
#define COLUMN_FORMAT_MASK 7
 
150
#define COLUMN_FORMAT_SHIFT 3
 
151
 
110
152
/* Below are #defines that used to be in mysql_priv.h */
111
153
/***************************************************************************
112
154
  Configuration parameters
113
155
****************************************************************************/
 
156
#define MAX_PASSWORD_LENGTH     32
 
157
#define MAX_ACCEPT_RETRY        10      // Test accept this many times
114
158
#define MAX_FIELDS_BEFORE_HASH  32
115
159
#define USER_VARS_HASH_SIZE     16
116
160
#define TABLE_OPEN_CACHE_MIN    64
130
174
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
131
175
#define STACK_BUFF_ALLOC        352     ///< For stack overrun checks
132
176
 
 
177
#define TEMP_POOL_SIZE          128
 
178
 
133
179
#define QUERY_ALLOC_BLOCK_SIZE          8192
134
180
#define QUERY_ALLOC_PREALLOC_SIZE       8192
 
181
#define TRANS_ALLOC_BLOCK_SIZE          4096
 
182
#define TRANS_ALLOC_PREALLOC_SIZE       4096
135
183
#define RANGE_ALLOC_BLOCK_SIZE          4096
 
184
#define UDF_ALLOC_BLOCK_SIZE            1024
136
185
#define TABLE_ALLOC_BLOCK_SIZE          1024
137
186
#define WARN_ALLOC_BLOCK_SIZE           2048
138
187
#define WARN_ALLOC_PREALLOC_SIZE        1024
 
188
#define PROFILE_ALLOC_BLOCK_SIZE  2048
 
189
#define PROFILE_ALLOC_PREALLOC_SIZE 1024
139
190
 
140
191
/*
141
192
  The following parameters is to decide when to use an extra cache to
143
194
*/
144
195
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
145
196
#define MIN_ROWS_TO_USE_TABLE_CACHE      100
 
197
#define MIN_ROWS_TO_USE_BULK_INSERT      100
146
198
 
147
199
/**
148
200
  The following is used to decide if MySQL should use table scanning
183
235
 
184
236
/** Characters shown for the command in 'show processlist'. */
185
237
#define PROCESS_LIST_WIDTH 100
 
238
/* Characters shown for the command in 'information_schema.processlist' */
 
239
#define PROCESS_LIST_INFO_WIDTH 65535
186
240
 
187
241
#define PRECISION_FOR_DOUBLE 53
188
242
#define PRECISION_FOR_FLOAT  24
190
244
/* The following can also be changed from the command line */
191
245
#define DEFAULT_CONCURRENCY     10
192
246
#define FLUSH_TIME              0               /**< Don't flush tables */
 
247
#define MAX_CONNECT_ERRORS      10              ///< errors before disabling host
 
248
 
 
249
#define INTERRUPT_PRIOR 10
 
250
#define CONNECT_PRIOR   9
 
251
#define WAIT_PRIOR      8
 
252
#define QUERY_PRIOR     6
 
253
 
 
254
/* Bits from testflag */
 
255
enum test_flag_bit
 
256
{
 
257
  TEST_PRINT_CACHED_TABLES= 1,
 
258
  TEST_NO_KEY_GROUP,
 
259
  TEST_MIT_THREAD,
 
260
  TEST_KEEP_TMP_TABLES,
 
261
  TEST_READCHECK, /**< Force use of readcheck */
 
262
  TEST_NO_EXTRA,
 
263
  TEST_CORE_ON_SIGNAL, /**< Give core if signal */
 
264
  TEST_NO_STACKTRACE,
 
265
  TEST_SIGINT, /**< Allow sigint on threads */
 
266
  TEST_SYNCHRONIZATION /**< get server to do sleep in some places */
 
267
};
193
268
 
194
269
/* Bits for different SQL modes modes (including ANSI mode) */
195
270
#define MODE_NO_ZERO_DATE               (2)
196
271
#define MODE_INVALID_DATES              (MODE_NO_ZERO_DATE*2)
197
272
 
 
273
/* @@optimizer_switch flags */
 
274
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
 
275
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
 
276
 
198
277
#define MY_CHARSET_BIN_MB_MAXLEN 1
199
278
 
200
279
// uncachable cause
201
 
static const uint32_t UNCACHEABLE_DEPENDENT= 1;
202
 
static const uint32_t UNCACHEABLE_RAND= 2;
203
 
static const uint32_t UNCACHEABLE_SIDEEFFECT= 3;
 
280
#define UNCACHEABLE_DEPENDENT   1
 
281
#define UNCACHEABLE_RAND        2
 
282
#define UNCACHEABLE_SIDEEFFECT  4
204
283
/// forcing to save JOIN for explain
205
 
static const uint32_t UNCACHEABLE_EXPLAIN= 4;
 
284
#define UNCACHEABLE_EXPLAIN     8
206
285
/** Don't evaluate subqueries in prepare even if they're not correlated */
207
 
static const uint32_t UNCACHEABLE_PREPARE= 5;
 
286
#define UNCACHEABLE_PREPARE    16
208
287
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
209
 
static const uint32_t UNCACHEABLE_UNITED= 6;
 
288
#define UNCACHEABLE_UNITED     32
210
289
 
211
290
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
212
291
#define UNDEF_POS (-1)
213
292
 
 
293
/* sql_show.cc:show_log_files() */
 
294
#define SHOW_LOG_STATUS_FREE "FREE"
 
295
#define SHOW_LOG_STATUS_INUSE "IN USE"
 
296
 
214
297
/* Options to add_table_to_list() */
215
 
static const uint32_t TL_OPTION_UPDATING= 0;
216
 
static const uint32_t TL_OPTION_FORCE_INDEX= 1;
217
 
static const uint32_t TL_OPTION_IGNORE_LEAVES= 2;
218
 
static const uint32_t TL_OPTION_ALIAS= 3;
219
 
static const uint32_t NUM_OF_TABLE_OPTIONS= 4;
 
298
#define TL_OPTION_UPDATING      1
 
299
#define TL_OPTION_FORCE_INDEX   2
 
300
#define TL_OPTION_IGNORE_LEAVES 4
 
301
#define TL_OPTION_ALIAS         8
220
302
 
221
303
/* Some portable defines */
222
304
 
236
318
 
237
319
#define STRING_BUFFER_USUAL_SIZE 80
238
320
 
 
321
/*
 
322
  Some defines for exit codes for ::is_equal class functions.
 
323
*/
 
324
#define IS_EQUAL_NO 0
 
325
#define IS_EQUAL_YES 1
 
326
#define IS_EQUAL_PACK_LENGTH 2
 
327
 
 
328
 
 
329
typedef uint64_t query_id_t;
239
330
typedef void *range_seq_t;
240
331
 
241
 
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
242
332
// the following is for checking tables
243
333
 
244
334
#define HA_ADMIN_ALREADY_DONE     1
249
339
#define HA_ADMIN_INTERNAL_ERROR  -4
250
340
#define HA_ADMIN_INVALID         -5
251
341
#define HA_ADMIN_REJECT          -6
 
342
#define HA_ADMIN_TRY_ALTER       -7
 
343
#define HA_ADMIN_NEEDS_UPGRADE  -10
 
344
#define HA_ADMIN_NEEDS_ALTER    -11
 
345
#define HA_ADMIN_NEEDS_CHECK    -12
 
346
 
 
347
 
 
348
/* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
 
349
 
 
350
/* Return values for check_if_supported_alter */
 
351
 
 
352
#define HA_ALTER_ERROR               -1
 
353
#define HA_ALTER_SUPPORTED_WAIT_LOCK  0
 
354
#define HA_ALTER_SUPPORTED_NO_LOCK    1
 
355
#define HA_ALTER_NOT_SUPPORTED        2
 
356
 
 
357
/* Bits in table_flags() to show what database can do */
 
358
 
 
359
#define HA_NO_TRANSACTIONS     (1 << 0) /* Doesn't support transactions */
 
360
#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */
 
361
#define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */
 
362
/*
 
363
  The following should be set if the following is not true when scanning
 
364
  a table with rnd_next()
 
365
  - We will see all rows (including deleted ones)
 
366
  - Row positions are 'table->s->db_record_offset' apart
 
367
  If this flag is not set, filesort will do a postion() call for each matched
 
368
  row to be able to find the row later.
 
369
*/
 
370
#define HA_REC_NOT_IN_SEQ      (1 << 3)
 
371
 
 
372
/*
 
373
  Reading keys in random order is as fast as reading keys in sort order
 
374
  (Used in records.cc to decide if we should use a record cache and by
 
375
  filesort to decide if we should sort key + data or key + pointer-to-row
 
376
*/
 
377
#define HA_FAST_KEY_READ       (1 << 5)
 
378
/*
 
379
  Set the following flag if we on delete should force all key to be read
 
380
  and on update read all keys that changes
 
381
*/
 
382
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6)
 
383
#define HA_NULL_IN_KEY         (1 << 7) /* One can have keys with NULL */
 
384
#define HA_DUPLICATE_POS       (1 << 8)    /* ha_position() gives dup row */
 
385
#define HA_NO_BLOBS            (1 << 9) /* Doesn't support blobs */
 
386
#define HA_CAN_INDEX_BLOBS     (1 << 10)
 
387
#define HA_AUTO_PART_KEY       (1 << 11) /* auto-increment in multi-part key */
 
388
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */
 
389
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */
 
390
/*
 
391
  If we get the primary key columns for free when we do an index read
 
392
  It also implies that we have to retrive the primary key when using
 
393
  position() and rnd_pos().
 
394
*/
 
395
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
 
396
/*
 
397
  If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
 
398
  uses a primary key. Without primary key, we can't call position().
 
399
*/
 
400
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16)
 
401
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
 
402
/*
 
403
  The following is we need to a primary key to delete (and update) a row.
 
404
  If there is no primary key, all columns needs to be read on update and delete
 
405
*/
 
406
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
 
407
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
 
408
#define HA_NO_AUTO_INCREMENT   (1 << 23)
 
409
#define HA_HAS_CHECKSUM        (1 << 24)
 
410
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
 
411
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
 
412
#define HA_HAS_RECORDS         (INT64_C(1) << 32) /* records() gives exact count*/
 
413
#define HA_MRR_CANT_SORT       (INT64_C(1) << 34)
252
414
 
253
415
/* bits in index_flags(index_number) for what you can do with index */
254
416
#define HA_READ_NEXT            1       /* TODO really use this flag */
262
424
  set for unordered (e.g. HASH) indexes.
263
425
*/
264
426
#define HA_KEY_SCAN_NOT_ROR     128
 
427
#define HA_DO_INDEX_COND_PUSHDOWN  256 /* Supports Index Condition Pushdown */
265
428
 
266
429
/* operations for disable/enable indexes */
267
430
#define HA_KEY_SWITCH_NONUNIQ      0
303
466
#define HA_KEY_NULL_LENGTH      1
304
467
#define HA_KEY_BLOB_LENGTH      2
305
468
 
 
469
#define HA_LEX_CREATE_TMP_TABLE 1
 
470
#define HA_LEX_CREATE_IF_NOT_EXISTS 2
 
471
#define HA_LEX_CREATE_TABLE_LIKE 4
 
472
#define HA_OPTION_NO_CHECKSUM   (1L << 17)
306
473
#define HA_MAX_REC_LENGTH       65535
307
474
 
308
475
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
309
 
enum start_transaction_option_t
310
 
{
311
 
  START_TRANS_NO_OPTIONS,
312
 
  START_TRANS_OPT_WITH_CONS_SNAPSHOT
313
 
};
 
476
#define DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
314
477
 
315
478
/* Flags for method is_fatal_error */
316
479
#define HA_CHECK_DUP_KEY 1
322
485
#define HA_CREATE_USED_AUTO             (1L << 0)
323
486
#define HA_CREATE_USED_CHARSET          (1L << 8)
324
487
#define HA_CREATE_USED_DEFAULT_CHARSET  (1L << 9)
 
488
#define HA_CREATE_USED_DATADIR          (1L << 10)
 
489
#define HA_CREATE_USED_INDEXDIR         (1L << 11)
 
490
#define HA_CREATE_USED_ENGINE           (1L << 12)
325
491
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
 
492
#define HA_CREATE_USED_COMMENT          (1L << 16)
 
493
#define HA_CREATE_USED_CONNECTION       (1L << 18)
 
494
#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)
 
495
#define HA_CREATE_USED_BLOCK_SIZE       (1L << 22)
 
496
 
 
497
#define MAXGTRIDSIZE 64
 
498
#define MAXBQUALSIZE 64
326
499
 
327
500
/*
328
501
  The below two are not used (and not handled) in this milestone of this WL
362
535
*/
363
536
#define HA_MRR_USE_DEFAULT_IMPL 64
364
537
 
 
538
/*
 
539
  Used only as parameter to multi_range_read_info():
 
540
  Flag set <=> the caller guarantees that the bounds of the scanned ranges
 
541
  will not have NULL values.
 
542
*/
 
543
#define HA_MRR_NO_NULL_ENDPOINTS 128
 
544
 
365
545
typedef int myf;
366
 
#define MYF(v)          (static_cast<drizzled::myf>(v))
 
546
#define MYF(v)          (myf) (v)
 
547
 
 
548
#define MY_I_S_MAYBE_NULL 1
 
549
#define MY_I_S_UNSIGNED   2
 
550
 
 
551
 
 
552
#define SKIP_OPEN_TABLE 0                // do not open table
 
553
#define OPEN_FRM_ONLY   1                // open FRM file only
 
554
#define OPEN_FULL_TABLE 2                // open FRM,MYD, MYI files
367
555
 
368
556
/*
369
557
   "Declared Type Collation"
386
574
#define MY_COLL_ALLOW_CONV            3
387
575
#define MY_COLL_DISALLOW_NONE         4
388
576
#define MY_COLL_CMP_CONV              7
389
 
 
390
 
inline static void clear_timestamp_auto_bits(timestamp_auto_set_type &_target_, 
391
 
                                             timestamp_auto_set_type _bits_)
392
 
{
393
 
  _target_= static_cast<timestamp_auto_set_type>(_target_ & ~_bits_);
394
 
}
 
577
#define clear_timestamp_auto_bits(_target_, _bits_) \
 
578
  (_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
395
579
 
396
580
/*
397
581
 * The following are for the interface with the .frm file
398
582
 */
399
583
 
 
584
#define FIELDFLAG_DECIMAL    1
 
585
#define FIELDFLAG_BINARY    1  // Shares same flag
 
586
#define FIELDFLAG_NUMBER    2
 
587
#define FIELDFLAG_DECIMAL_POSITION      4
 
588
#define FIELDFLAG_PACK      120  // Bits used for packing
 
589
#define FIELDFLAG_INTERVAL    256     // mangled with decimals!
 
590
#define FIELDFLAG_BLOB      1024  // mangled with decimals!
 
591
 
 
592
#define FIELDFLAG_NO_DEFAULT    16384   /* sql */
 
593
#define FIELDFLAG_SUM      ((uint32_t) 32768)// predit: +#fieldflag
 
594
#define FIELDFLAG_MAYBE_NULL    ((uint32_t) 32768)// sql
 
595
#define FIELDFLAG_HEX_ESCAPE    ((uint32_t) 0x10000)
400
596
#define FIELDFLAG_PACK_SHIFT    3
 
597
#define FIELDFLAG_DEC_SHIFT    8
401
598
#define FIELDFLAG_MAX_DEC    31
402
599
 
403
 
#ifdef __cplusplus
404
 
// FIXME: T will just be drizzled::Field::utype, but that would
405
 
// require including field.h. Moving the function elsewhere might be a
406
 
// better idea. Leaving it for restructuring.
407
 
template <typename T> 
408
 
T MTYP_TYPENR(const T& type)
409
 
{
410
 
  return static_cast<T>(type & 127);
411
 
}
412
 
#else
413
600
#define MTYP_TYPENR(type) (type & 127)  /* Remove bits from type */
414
 
#endif
415
 
 
416
 
inline static uint32_t f_settype(const enum enum_field_types x)
417
 
{
418
 
  return (uint32_t(x) << FIELDFLAG_PACK_SHIFT);
419
 
}
420
 
 
421
 
#ifdef __cplusplus
422
 
template <class T> void set_if_bigger(T &a, const T &b)
423
 
{
424
 
  if (a < b)
425
 
    a=b;
426
 
}
427
 
 
428
 
template <class T> void set_if_smaller(T &a, const T &b)
429
 
{
430
 
  if (a > b)
431
 
    a=b;
432
 
}
433
 
#else
434
 
#ifdef __GNUC__
435
 
#define set_if_bigger(a,b) do {                 \
436
 
  const typeof(a) _a = (a);                     \
437
 
  const typeof(b) _b = (b);                     \
438
 
  (void) (&_a == &_b);                          \
439
 
  if ((a) < (b)) (a)=(b);                       \
440
 
  } while(0)
441
 
#define set_if_smaller(a,b) do {                \
442
 
  const typeof(a) _a = (a);                     \
443
 
  const typeof(b) _b = (b);                     \
444
 
  (void) (&_a == &_b);                          \
445
 
  if ((a) > (b)) (a)=(b);                       \
446
 
  } while(0)
447
 
 
448
 
#else
449
 
#define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)
450
 
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
451
 
#endif
452
 
#endif
453
 
 
454
 
 
455
 
#define array_elements(a) \
456
 
  ((sizeof(a) / sizeof(*(a))) / \
457
 
   static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
458
 
 
459
 
 
460
 
/* Some types that is different between systems */
461
 
 
462
 
#ifndef FN_LIBCHAR
463
 
#define FN_LIBCHAR  '/'
464
 
#define FN_ROOTDIR  "/"
465
 
#endif
466
 
#define MY_NFILE  64  /* This is only used to save filenames */
467
 
#ifndef OS_FILE_LIMIT
468
 
#define OS_FILE_LIMIT  65535
469
 
#endif
470
 
 
471
 
/*
472
 
  How much overhead does malloc have. The code often allocates
473
 
  something like 1024-MALLOC_OVERHEAD bytes
474
 
*/
475
 
#define MALLOC_OVERHEAD 8
476
 
 
477
 
/* get memory in huncs */
478
 
static const uint32_t ONCE_ALLOC_INIT= 4096;
479
 
/* Typical record cash */
480
 
static const uint32_t RECORD_CACHE_SIZE= 64*1024;
481
 
 
482
 
 
483
 
/* Some things that this system doesn't have */
484
 
 
485
 
/* Some defines of functions for portability */
486
 
 
487
 
#ifndef uint64_t2double
488
 
#define uint64_t2double(A) ((double) (uint64_t) (A))
489
 
#endif
490
 
 
491
 
#ifndef int64_t2double
492
 
#define int64_t2double(A) ((double) (int64_t) (A))
493
 
#endif
494
 
 
495
 
#ifndef offsetof
496
 
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
497
 
#endif
498
 
#define ulong_to_double(X) ((double) (ulong) (X))
499
 
 
500
 
/* From limits.h instead */
501
 
#ifndef DBL_MIN
502
 
#define DBL_MIN    4.94065645841246544e-324
503
 
#endif
504
 
#ifndef DBL_MAX
505
 
#define DBL_MAX    1.79769313486231470e+308
506
 
#endif
507
 
 
508
 
 
509
 
/* Define missing math constants. */
510
 
#ifndef M_PI
511
 
#define M_PI 3.14159265358979323846
512
 
#endif
513
 
#ifndef M_E
514
 
#define M_E 2.7182818284590452354
515
 
#endif
516
 
#ifndef M_LN2
517
 
#define M_LN2 0.69314718055994530942
518
 
#endif
519
 
 
520
 
/*
521
 
  Max size that must be added to a so that we know Size to make
522
 
  adressable obj.
523
 
*/
524
 
#define MY_ALIGN(A,L)  (((A) + (L) - 1) & ~((L) - 1))
525
 
#define ALIGN_SIZE(A)  MY_ALIGN((A),sizeof(double))
526
 
/* Size to make adressable obj. */
527
 
#define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t)))
528
 
/* Offset of field f in structure t */
529
 
#define OFFSET(t, f)  ((size_t)(char *)&((t *)0)->f)
530
 
#ifdef __cplusplus
531
 
#define ADD_TO_PTR(ptr,size,type) (type) (reinterpret_cast<const unsigned char*>(ptr)+size)
532
 
#define PTR_BYTE_DIFF(A,B) (ptrdiff_t) (reinterpret_cast<const unsigned char*>(A) - reinterpret_cast<const unsigned char*>(B))
533
 
#else
534
 
 #define ADD_TO_PTR(ptr,size,type) (type) ((unsigned char*) (ptr)+size)
535
 
 #define PTR_BYTE_DIFF(A,B) (ptrdiff_t) ((unsigned char*) (A) - (unsigned char*) (B))
536
 
#endif
537
 
 
538
 
#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B))
539
 
#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))]
540
 
 
541
 
/* Typdefs for easyier portability */
542
 
 
543
 
 
544
 
#if defined(SIZEOF_OFF_T)
545
 
# if (SIZEOF_OFF_T == 8)
546
 
#  define OFF_T_MAX (INT64_MAX)
547
 
# else
548
 
#  define OFF_T_MAX (INT32_MAX)
549
 
# endif
550
 
#endif
551
 
 
552
 
#define MY_FILEPOS_ERROR  -1
553
 
 
554
 
#define DRIZZLE_SERVER
555
 
 
556
 
/* Length of decimal number represented by INT32. */
557
 
#define MY_INT32_NUM_DECIMAL_DIGITS 11
558
 
 
559
 
/* Length of decimal number represented by INT64. */
560
 
#define MY_INT64_NUM_DECIMAL_DIGITS 21
561
 
 
562
 
/*
563
 
  Io buffer size; Must be a power of 2 and
564
 
  a multiple of 512. May be
565
 
  smaller what the disk page size. This influences the speed of the
566
 
  isam btree library. eg to big to slow.
567
 
*/
568
 
#define IO_SIZE 4096
569
 
/* Max file name len */
570
 
#define FN_LEN 256
571
 
/* Max length of extension (part of FN_LEN) */
572
 
#define FN_EXTLEN 20
573
 
/* Max length of full path-name */
574
 
#define FN_REFLEN 512
575
 
/* File extension character */
576
 
#define FN_EXTCHAR '.'
577
 
/* ~ is used as abbrev for home dir */
578
 
#define FN_HOMELIB '~'
579
 
/* ./ is used as abbrev for current dir */
580
 
#define FN_CURLIB '.'
581
 
/* Parent directory; Must be a string */
582
 
#define FN_PARENTDIR ".."
583
 
 
584
 
/* Quote argument (before cpp) */
585
 
#ifndef QUOTE_ARG
586
 
# define QUOTE_ARG(x) #x
587
 
#endif
588
 
/* Quote argument, (after cpp) */
589
 
#ifndef STRINGIFY_ARG
590
 
# define STRINGIFY_ARG(x) QUOTE_ARG(x)
591
 
#endif
592
 
 
593
 
/*
594
 
 * The macros below are borrowed from include/linux/compiler.h in the
595
 
 * Linux kernel. Use them to indicate the likelyhood of the truthfulness
596
 
 * of a condition. This serves two purposes - newer versions of gcc will be
597
 
 * able to optimize for branch predication, which could yield siginficant
598
 
 * performance gains in frequently executed sections of the code, and the
599
 
 * other reason to use them is for documentation
600
 
 */
601
 
#if !defined(__GNUC__)
602
 
#define __builtin_expect(x, expected_value) (x)
603
 
#endif
604
 
 
605
 
#define likely(x)  __builtin_expect((x),1)
606
 
#define unlikely(x)  __builtin_expect((x),0)
607
 
 
608
 
 
609
 
/*
610
 
  Only Linux is known to need an explicit sync of the directory to make sure a
611
 
  file creation/deletion/renaming in(from,to) this directory durable.
612
 
*/
613
 
#ifdef TARGET_OS_LINUX
614
 
#define NEED_EXPLICIT_SYNC_DIR 1
615
 
#endif
616
 
 
617
 
/* We need to turn off _DTRACE_VERSION if we're not going to use dtrace */
618
 
#if !defined(HAVE_DTRACE)
619
 
# undef _DTRACE_VERSION
620
 
# define _DTRACE_VERSION 0
621
 
#endif
622
 
 
623
 
typedef uint64_t table_map;   /* Used for table bits in join */
624
 
typedef uint32_t nesting_map; /* Used for flags of nesting constructs */
625
 
 
626
 
} /* namespace drizzled */
627
 
 
628
 
#endif /* DRIZZLED_DEFINITIONS_H */
 
601
 
 
602
#define f_is_dec(x)     ((x) & FIELDFLAG_DECIMAL)
 
603
#define f_is_num(x)     ((x) & FIELDFLAG_NUMBER)
 
604
#define f_is_decimal_precision(x)  ((x) & FIELDFLAG_DECIMAL_POSITION)
 
605
#define f_is_packed(x)  ((x) & FIELDFLAG_PACK)
 
606
#define f_packtype(x)   (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
 
607
#define f_decimals(x)   ((uint8_t) (((x) >> FIELDFLAG_DEC_SHIFT) & \
 
608
                                     FIELDFLAG_MAX_DEC))
 
609
#define f_is_alpha(x)   (!f_is_num(x))
 
610
#define f_is_binary(x)  ((x) & FIELDFLAG_BINARY) // 4.0- compatibility
 
611
#define f_is_enum(x)    (((x) & (FIELDFLAG_INTERVAL | FIELDFLAG_NUMBER)) == \
 
612
                         FIELDFLAG_INTERVAL)
 
613
#define f_is_blob(x)    (((x) & (FIELDFLAG_BLOB | FIELDFLAG_NUMBER)) == \
 
614
                         FIELDFLAG_BLOB)
 
615
#define f_is_equ(x)     ((x) & (1+2+FIELDFLAG_PACK+31*256))
 
616
#define f_settype(x)    (((int) x) << FIELDFLAG_PACK_SHIFT)
 
617
#define f_maybe_null(x) (x & FIELDFLAG_MAYBE_NULL)
 
618
#define f_no_default(x) (x & FIELDFLAG_NO_DEFAULT)
 
619
#define f_is_hex_escape(x) ((x) & FIELDFLAG_HEX_ESCAPE)
 
620
 
 
621
#endif /* DRIZZLE_SERVER_DEFINITIONS_H */
 
622