~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to include/my_base.h

Removed SCCS references.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
 
1
/* Copyright (C) 2000 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
19
15
 
20
16
/* This file includes constants used with all databases */
21
17
 
22
 
/** 
23
 
 * @TODO Name this file something better and split it out if necessary.  
24
 
 * base.h isn't descriptive, especially compared to global.h 
25
 
 *
26
 
 * @TODO Convert HA_XXX defines into enums and/or bitmaps
27
 
 */
28
 
 
29
 
#ifndef DRIZZLE_SERVER_BASE_H
30
 
#define DRIZZLE_SERVER_BASE_H
 
18
#ifndef _my_base_h
 
19
#define _my_base_h
31
20
 
32
21
#ifndef stdin                           /* Included first in handler */
33
22
#define CHSIZE_USED
34
 
#include <drizzled/global.h>
35
 
#include <mysys/my_dir.h>               /* This includes types */
36
 
#include <mysys/my_sys.h>
37
 
#include <mystrings/m_string.h>
 
23
#include <my_global.h>
 
24
#include <my_dir.h>                     /* This includes types */
 
25
#include <my_sys.h>
 
26
#include <m_string.h>
38
27
#include <errno.h>
39
28
 
40
29
#ifndef EOVERFLOW
41
30
#define EOVERFLOW 84
42
31
#endif
43
32
 
 
33
#if !defined(USE_MY_FUNC) && !defined(THREAD)
 
34
#include <my_nosys.h>                   /* For faster code, after test */
 
35
#endif  /* USE_MY_FUNC */
44
36
#endif  /* stdin */
45
 
#include <mysys/my_list.h>
 
37
#include <my_list.h>
46
38
 
47
39
/* The following is bits in the flag parameter to ha_open() */
48
40
 
114
106
  HA_BUILD_OFFLINE 
115
107
};
116
108
 
 
109
        /* Storage media types */ 
 
110
 
 
111
enum ha_storage_media {
 
112
  HA_SM_DEFAULT=        0,              /* Not specified (engine default) */
 
113
  HA_SM_DISK=           1,              /* DISK storage */
 
114
  HA_SM_MEMORY=         2               /* MAIN MEMORY storage */
 
115
};
 
116
 
117
117
        /* The following is parameter to ha_extra() */
118
118
 
119
119
enum ha_extra_function {
170
170
  HA_EXTRA_IGNORE_NO_KEY,
171
171
  HA_EXTRA_NO_IGNORE_NO_KEY,
172
172
  /*
 
173
    Mark the table as a log table. For some handlers (e.g. CSV) this results
 
174
    in a special locking for the table.
 
175
  */
 
176
  HA_EXTRA_MARK_AS_LOG_TABLE,
 
177
  /*
173
178
    Informs handler that write_row() which tries to insert new row into the
174
179
    table and encounters some already existing row with same primary/unique
175
180
    key can replace old row with new row instead of reporting error (basically
192
197
  */
193
198
  HA_EXTRA_INSERT_WITH_UPDATE,
194
199
  /* Inform handler that we will do a rename */
195
 
  HA_EXTRA_PREPARE_FOR_RENAME
 
200
  HA_EXTRA_PREPARE_FOR_RENAME,
 
201
  /*
 
202
    Orders MERGE handler to attach or detach its child tables. Used at
 
203
    begin and end of a statement.
 
204
  */
 
205
  HA_EXTRA_ATTACH_CHILDREN,
 
206
  HA_EXTRA_DETACH_CHILDREN
196
207
};
197
208
 
198
209
/* Compatible option, to be deleted in 6.0 */
241
252
#define HA_PACK_KEY              2      /* Pack string key to previous key */
242
253
#define HA_AUTO_KEY              16
243
254
#define HA_BINARY_PACK_KEY       32     /* Packing of all keys to prev key */
 
255
#define HA_FULLTEXT             128     /* For full-text search */
244
256
#define HA_UNIQUE_CHECK         256     /* Check the key for uniqueness */
 
257
#define HA_SPATIAL              1024    /* For spatial search */
245
258
#define HA_NULL_ARE_EQUAL       2048    /* NULL in key are cmp as equal */
246
259
#define HA_GENERATED_KEY        8192    /* Automaticly generated key */
247
260
 
248
261
        /* The combination of the above can be used for key type comparison. */
249
262
#define HA_KEYFLAG_MASK (HA_NOSAME | HA_PACK_KEY | HA_AUTO_KEY | \
250
 
                         HA_BINARY_PACK_KEY | HA_UNIQUE_CHECK | \
251
 
                         HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
 
263
                         HA_BINARY_PACK_KEY | HA_FULLTEXT | HA_UNIQUE_CHECK | \
 
264
                         HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
252
265
 
253
266
#define HA_KEY_HAS_PART_KEY_SEG 65536   /* Key contains partial segments */
254
267
 
258
271
#define HA_VAR_LENGTH_KEY        8
259
272
#define HA_NULL_PART_KEY         64
260
273
#define HA_USES_COMMENT          4096
 
274
#define HA_USES_PARSER           16384  /* Fulltext index uses [pre]parser */
261
275
#define HA_USES_BLOCK_SIZE       ((uint) 32768)
262
276
#define HA_SORT_ALLOWS_SAME      512    /* Intern bit when sorting records */
 
277
#if MYSQL_VERSION_ID < 0x50200
 
278
/*
 
279
  Key has a part that can have end space.  If this is an unique key
 
280
  we have to handle it differently from other unique keys as we can find
 
281
  many matching rows for one key (because end space are not compared)
 
282
*/
 
283
#define HA_END_SPACE_KEY      0 /* was: 4096 */
 
284
#else
 
285
#error HA_END_SPACE_KEY is obsolete, please remove it
 
286
#endif
 
287
 
263
288
 
264
289
        /* These flags can be added to key-seg-flag */
265
290
 
420
445
#define HA_ERR_TABLESPACE_EXIST   171
421
446
#define HA_ERR_CORRUPT_EVENT      172    /* The event was corrupt, leading to
422
447
                                            illegal data being read */
423
 
#define HA_ERR_NEW_FILE           173    /* New file format */
424
 
#define HA_ERR_ROWS_EVENT_APPLY   174    /* The event could not be processed
 
448
#define HA_ERR_NEW_FILE           172    /* New file format */
 
449
#define HA_ERR_ROWS_EVENT_APPLY   173    /* The event could not be processed
425
450
                                            no other hanlder error happened */
426
 
#define HA_ERR_INITIALIZATION     175    /* Error during initialization */
427
 
#define HA_ERR_FILE_TOO_SHORT     176    /* File too short */
428
 
#define HA_ERR_WRONG_CRC          177    /* Wrong CRC on page */
429
 
#define HA_ERR_LOCK_OR_ACTIVE_TRANSACTION 178
430
 
#define HA_ERR_NO_SUCH_TABLESPACE 179
431
 
#define HA_ERR_TABLESPACE_NOT_EMPTY 180
432
 
#define HA_ERR_LAST               180    /* Copy of last error nr */
 
451
#define HA_ERR_INITIALIZATION     174    /* Error during initialization */
 
452
#define HA_ERR_FILE_TOO_SHORT     175    /* File too short */
 
453
#define HA_ERR_WRONG_CRC          176    /* Wrong CRC on page */
 
454
#define HA_ERR_LOCK_OR_ACTIVE_TRANSACTION 177
 
455
#define HA_ERR_NO_SUCH_TABLESPACE 178
 
456
#define HA_ERR_TABLESPACE_NOT_EMPTY 179
 
457
#define HA_ERR_LAST               179    /* Copy of last error nr */
433
458
 
434
459
/* Number of different errors */
435
460
#define HA_ERR_ERRORS            (HA_ERR_LAST - HA_ERR_FIRST + 1)
531
556
*/
532
557
#define NULL_RANGE      64
533
558
 
 
559
#define GEOM_FLAG      128
 
560
 
 
561
/* Deprecated, currently used only by NDB at row retrieval */
 
562
#define SKIP_RANGE     256
 
563
 
534
564
typedef struct st_key_range
535
565
{
536
 
  const unsigned char *key;
537
 
  uint32_t length;
 
566
  const uchar *key;
 
567
  uint length;
538
568
  key_part_map keypart_map;
539
569
  enum ha_rkey_function flag;
540
570
} key_range;
544
574
  key_range start_key;
545
575
  key_range end_key;
546
576
  char  *ptr;                 /* Free to use by caller (ptr to row etc) */
547
 
  uint32_t  range_flag;           /* key range flags see above */
 
577
  uint  range_flag;           /* key range flags see above */
548
578
} KEY_MULTI_RANGE;
549
579
 
550
580
 
551
581
/* For number of records */
552
 
typedef uint64_t        ha_rows;
553
 
#define rows2double(A)  uint64_t2double(A)
 
582
#ifdef BIG_TABLES
 
583
#define rows2double(A)  ulonglong2double(A)
 
584
typedef my_off_t        ha_rows;
 
585
#else
 
586
#define rows2double(A)  (double) (A)
 
587
typedef ulong           ha_rows;
 
588
#endif
554
589
 
555
590
#define HA_POS_ERROR    (~ (ha_rows) 0)
556
591
#define HA_OFFSET_ERROR (~ (my_off_t) 0)
557
592
 
558
 
#if SIZEOF_OFF_T == 4
559
 
#define MAX_FILE_SIZE   INT32_MAX
 
593
#if SYSTEM_SIZEOF_OFF_T == 4
 
594
#define MAX_FILE_SIZE   INT_MAX32
560
595
#else
561
 
#define MAX_FILE_SIZE   INT64_MAX
 
596
#define MAX_FILE_SIZE   LONGLONG_MAX
562
597
#endif
563
598
 
564
599
#define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2)
566
601
/* invalidator function reference for Query Cache */
567
602
typedef void (* invalidator_by_filename)(const char * filename);
568
603
 
569
 
#endif /* DRIZZLE_SERVER_BASE_H */
 
604
#endif /* _my_base_h */