~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/base.h

Merge Stewart.

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
25
25
 * @TODO Convert HA_XXX defines into enums and/or bitmaps
26
26
 */
27
27
 
28
 
#include "definitions.h"
29
 
 
30
28
#ifndef DRIZZLED_BASE_H
31
29
#define DRIZZLED_BASE_H
32
30
 
194
192
  HA_KEYTYPE_ULONG_INT=9,
195
193
  HA_KEYTYPE_LONGLONG=10,
196
194
  HA_KEYTYPE_ULONGLONG=11,
 
195
  HA_KEYTYPE_UINT24=13,
197
196
  /* Varchar (0-255 bytes) with length packed with 1 byte */
198
197
  HA_KEYTYPE_VARTEXT1=15,               /* Key is sorted as letters */
199
198
  HA_KEYTYPE_VARBINARY1=16,             /* Key is sorted as unsigned chars */
202
201
  HA_KEYTYPE_VARBINARY2=18              /* Key is sorted as unsigned chars */
203
202
};
204
203
 
 
204
#define HA_MAX_KEYTYPE  31              /* Must be log2-1 */
 
205
 
205
206
        /* These flags kan be OR:ed to key-flag */
206
207
 
207
208
#define HA_NOSAME                1      /* Set if not dupplicated records */
212
213
#define HA_NULL_ARE_EQUAL       2048    /* NULL in key are cmp as equal */
213
214
#define HA_GENERATED_KEY        8192    /* Automaticly generated key */
214
215
 
 
216
        /* The combination of the above can be used for key type comparison. */
 
217
#define HA_KEYFLAG_MASK (HA_NOSAME | HA_PACK_KEY | HA_AUTO_KEY | \
 
218
                         HA_BINARY_PACK_KEY | HA_UNIQUE_CHECK | \
 
219
                         HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
 
220
 
215
221
#define HA_KEY_HAS_PART_KEY_SEG 65536   /* Key contains partial segments */
216
222
 
217
223
        /* Automatic bits in key-flag */
308
314
*/
309
315
#define HA_ERR_FIRST            120     /* Copy of first error nr.*/
310
316
 
311
 
/* Other constants */
 
317
#define HA_ERR_KEY_NOT_FOUND    120     /* Didn't find key on read or update */
 
318
#define HA_ERR_FOUND_DUPP_KEY   121     /* Dupplicate key on write */
 
319
#define HA_ERR_INTERNAL_ERROR   122     /* Internal error */
 
320
#define HA_ERR_RECORD_CHANGED   123     /* Uppdate with is recoverable */
 
321
#define HA_ERR_WRONG_INDEX      124     /* Wrong index given to function */
 
322
#define HA_ERR_CRASHED          126     /* Indexfile is crashed */
 
323
#define HA_ERR_WRONG_IN_RECORD  127     /* Record-file is crashed */
 
324
#define HA_ERR_OUT_OF_MEM       128     /* Record-file is crashed */
 
325
#define HA_ERR_NOT_A_TABLE      130     /* not a MYI file - no signature */
 
326
#define HA_ERR_WRONG_COMMAND    131     /* Command not supported */
 
327
#define HA_ERR_OLD_FILE         132     /* old databasfile */
 
328
#define HA_ERR_NO_ACTIVE_RECORD 133     /* No record read in update() */
 
329
#define HA_ERR_RECORD_DELETED   134     /* A record is not there */
 
330
#define HA_ERR_RECORD_FILE_FULL 135     /* No more room in file */
 
331
#define HA_ERR_INDEX_FILE_FULL  136     /* No more room in file */
 
332
#define HA_ERR_END_OF_FILE      137     /* end in next/prev/first/last */
 
333
#define HA_ERR_UNSUPPORTED      138     /* unsupported extension used */
 
334
#define HA_ERR_TO_BIG_ROW       139     /* Too big row */
 
335
#define HA_WRONG_CREATE_OPTION  140     /* Wrong create option */
 
336
#define HA_ERR_FOUND_DUPP_UNIQUE 141    /* Dupplicate unique on write */
 
337
#define HA_ERR_UNKNOWN_CHARSET   142    /* Can't open charset */
 
338
#define HA_ERR_WRONG_MRG_TABLE_DEF 143  /* conflicting tables in MERGE */
 
339
#define HA_ERR_CRASHED_ON_REPAIR 144    /* Last (automatic?) repair failed */
 
340
#define HA_ERR_CRASHED_ON_USAGE  145    /* Table must be repaired */
 
341
#define HA_ERR_LOCK_WAIT_TIMEOUT 146
 
342
#define HA_ERR_LOCK_TABLE_FULL   147
 
343
#define HA_ERR_READ_ONLY_TRANSACTION 148 /* Updates not allowed */
 
344
#define HA_ERR_LOCK_DEADLOCK     149
 
345
#define HA_ERR_CANNOT_ADD_FOREIGN 150    /* Cannot add a foreign key constr. */
 
346
#define HA_ERR_NO_REFERENCED_ROW 151     /* Cannot add a child row */
 
347
#define HA_ERR_ROW_IS_REFERENCED 152     /* Cannot delete a parent row */
 
348
#define HA_ERR_NO_SAVEPOINT      153     /* No savepoint with that name */
 
349
#define HA_ERR_NON_UNIQUE_BLOCK_SIZE 154 /* Non unique key block size */
 
350
#define HA_ERR_NO_SUCH_TABLE     155  /* The table does not exist in engine */
 
351
#define HA_ERR_TABLE_EXIST       156  /* The table existed in storage engine */
 
352
#define HA_ERR_NO_CONNECTION     157  /* Could not connect to storage engine */
 
353
/* NULLs are not supported in spatial index */
 
354
#define HA_ERR_NULL_IN_SPATIAL   158
 
355
#define HA_ERR_TABLE_DEF_CHANGED 159  /* The table changed in storage engine */
 
356
/* There's no partition in table for given value */
 
357
#define HA_ERR_NO_PARTITION_FOUND 160
 
358
#define HA_ERR_RBR_LOGGING_FAILED 161  /* Row-based binlogging of row failed */
 
359
#define HA_ERR_DROP_INDEX_FK      162  /* Index needed in foreign key constr */
 
360
/*
 
361
  Upholding foreign key constraints would lead to a duplicate key error
 
362
  in some other table.
 
363
*/
 
364
#define HA_ERR_FOREIGN_DUPLICATE_KEY 163
 
365
/* The table changed in storage engine */
 
366
#define HA_ERR_TABLE_NEEDS_UPGRADE 164
 
367
#define HA_ERR_TABLE_READONLY      165   /* The table is not writable */
 
368
 
 
369
#define HA_ERR_AUTOINC_READ_FAILED 166   /* Failed to get next autoinc value */
 
370
#define HA_ERR_AUTOINC_ERANGE    167     /* Failed to set row autoinc value */
 
371
#define HA_ERR_GENERIC           168     /* Generic error */
 
372
/* row not actually updated: new values same as the old values */
 
373
#define HA_ERR_RECORD_IS_THE_SAME 169
 
374
/* It is not possible to log this statement */
 
375
#define HA_ERR_LOGGING_IMPOSSIBLE 170    /* It is not possible to log this
 
376
                                            statement */
 
377
#define HA_ERR_TABLESPACE_EXIST   171
 
378
#define HA_ERR_CORRUPT_EVENT      172    /* The event was corrupt, leading to
 
379
                                            illegal data being read */
 
380
#define HA_ERR_NEW_FILE           173    /* New file format */
 
381
#define HA_ERR_ROWS_EVENT_APPLY   174    /* The event could not be processed
 
382
                                            no other hanlder error happened */
 
383
#define HA_ERR_INITIALIZATION     175    /* Error during initialization */
 
384
#define HA_ERR_FILE_TOO_SHORT     176    /* File too short */
 
385
#define HA_ERR_WRONG_CRC          177    /* Wrong CRC on page */
 
386
#define HA_ERR_LOCK_OR_ACTIVE_TRANSACTION 178
 
387
#define HA_ERR_NO_SUCH_TABLESPACE 179
 
388
#define HA_ERR_TABLESPACE_NOT_EMPTY 180
 
389
#define HA_ERR_LAST               180    /* Copy of last error nr */
 
390
 
 
391
/* Number of different errors */
 
392
#define HA_ERR_ERRORS            (HA_ERR_LAST - HA_ERR_FIRST + 1)
 
393
 
 
394
        /* Other constants */
312
395
 
313
396
typedef unsigned long key_part_map;
314
397
#define HA_WHOLE_KEY  (~(key_part_map)0)
330
413
#define MBR_WITHIN      2048
331
414
#define MBR_DISJOINT    4096
332
415
#define MBR_EQUAL       8192
 
416
#define MBR_DATA        16384
333
417
#define SEARCH_NULL_ARE_EQUAL 32768     /* NULL in keys are equal */
334
418
#define SEARCH_NULL_ARE_NOT_EQUAL 65536 /* NULL in keys are not equal */
335
419
 
336
420
        /* bits in opt_flag */
 
421
#define QUICK_USED      1
337
422
#define READ_CACHE_USED 2
338
423
#define READ_CHECK_USED 4
339
424
#define KEY_READ_USED   8
347
432
#define HA_STATE_DELETED        8
348
433
#define HA_STATE_NEXT_FOUND     16      /* Next found record (record before) */
349
434
#define HA_STATE_PREV_FOUND     32      /* Prev found record (record after) */
 
435
#define HA_STATE_NO_KEY         64      /* Last read didn't find record */
350
436
#define HA_STATE_KEY_CHANGED    128
351
437
#define HA_STATE_WRITE_AT_END   256     /* set in _ps_find_writepos */
 
438
#define HA_STATE_BUFF_SAVED     512     /* If current keybuff is info->buff */
352
439
#define HA_STATE_ROW_CHANGED    1024    /* To invalide ROW cache */
353
440
#define HA_STATE_EXTEND_BLOCK   2048
354
441
#define HA_STATE_RNEXT_SAME     4096    /* rnext_same occupied lastkey2 */
398
485
*/
399
486
#define NULL_RANGE      64
400
487
 
401
 
class key_range
 
488
typedef struct st_key_range
402
489
{
403
 
public:
404
490
  const unsigned char *key;
405
491
  uint32_t length;
406
492
  enum ha_rkey_function flag;
407
493
  key_part_map keypart_map;
408
 
};
 
494
} key_range;
409
495
 
410
 
class KEY_MULTI_RANGE
 
496
typedef struct st_key_multi_range
411
497
{
412
 
public:
413
498
  key_range start_key;
414
499
  key_range end_key;
415
500
  char  *ptr;                 /* Free to use by caller (ptr to row etc) */
416
501
  uint32_t  range_flag;           /* key range flags see above */
417
 
};
 
502
} KEY_MULTI_RANGE;
418
503
 
419
504
 
420
505
/* For number of records */
421
506
typedef uint64_t        ha_rows;
422
 
inline static double rows2double(ha_rows rows)
423
 
{  
424
 
  return uint64_t2double(rows);
425
 
}
 
507
#define rows2double(A)  uint64_t2double(A)
426
508
 
427
509
#define HA_POS_ERROR    (~ (::drizzled::ha_rows) 0)
428
510
#define HA_OFFSET_ERROR (~ (::drizzled::internal::my_off_t) 0)
433
515
#define MAX_FILE_SIZE   INT64_MAX
434
516
#endif
435
517
 
436
 
inline static uint32_t ha_varchar_packlength(uint32_t field_length)
437
 
{
438
 
  return (field_length < 256 ? 1 :2);
439
 
}
440
 
 
 
518
#define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2)
441
519
 
442
520
} /* namespace drizzled */
443
521