Drizzled Public API Documentation

my_handler.h

00001 /* Copyright (C) 2002-2006 MySQL AB
00002 
00003    This library is free software; you can redistribute it and/or
00004    modify it under the terms of the GNU Library General Public
00005    License as published by the Free Software Foundation; version 2
00006    of the License.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public
00014    License along with this library; if not, write to the Free
00015    Software Foundation, Inc., 51 Franklin Place - Suite 330, Boston,
00016    MA 02110-1301, USA */
00017 
00018 #pragma once
00019 
00020 #include <drizzled/charset_info.h>
00021 #include <plugin/myisam/myisampack.h>
00022 
00023 /*
00024   There is a hard limit for the maximum number of keys as there are only
00025   8 bits in the index file header for the number of keys in a table.
00026   This means that 0..255 keys can exist for a table. The idea of
00027   HA_MAX_POSSIBLE_KEY is to ensure that one can use myisamchk & tools on
00028   a MyISAM table for which one has more keys than MyISAM is normally
00029   compiled for. If you don't have this, you will get a core dump when
00030   running myisamchk compiled for 128 keys on a table with 255 keys.
00031 */
00032 
00033 #define HA_MAX_POSSIBLE_KEY         255         /* For myisamchk */
00034 /*
00035   The following defines can be increased if necessary.
00036   But beware the dependency of MI_MAX_POSSIBLE_KEY_BUFF and HA_MAX_KEY_LENGTH.
00037 */
00038 
00039 #define HA_MAX_KEY_LENGTH           1332        /* Max length in bytes */
00040 #define HA_MAX_KEY_SEG              16          /* Max segments for key */
00041 
00042 #define HA_MAX_POSSIBLE_KEY_BUFF    (HA_MAX_KEY_LENGTH + 24+ 6+6)
00043 #define HA_MAX_KEY_BUFF  (HA_MAX_KEY_LENGTH+HA_MAX_KEY_SEG*6+8+8)
00044 
00045 typedef struct st_HA_KEYSEG   /* Key-portion */
00046 {
00047   const drizzled::CHARSET_INFO *charset;
00048   uint32_t start;       /* Start of key in record */
00049   uint32_t null_pos;      /* position to NULL indicator */
00050   uint16_t bit_pos;                       /* Position to bit part */
00051   uint16_t flag;
00052   uint16_t length;      /* Keylength */
00053   uint8_t  type;        /* Type of key (for sort) */
00054   uint8_t  language;
00055   uint8_t  null_bit;      /* bitmask to test for NULL */
00056   uint8_t  bit_start,bit_end;   /* if bit field */
00057   uint8_t  bit_length;                    /* Length of bit part */
00058 } HA_KEYSEG;
00059 
00060 #define get_key_length(length,key) \
00061 { if (*(unsigned char*) (key) != 255) \
00062     length= (uint) *(unsigned char*) ((key)++); \
00063   else \
00064   { length= mi_uint2korr((key)+1); (key)+=3; } \
00065 }
00066 
00067 #define get_key_length_rdonly(length,key) \
00068 { if (*(unsigned char*) (key) != 255) \
00069     length= ((uint) *(unsigned char*) ((key))); \
00070   else \
00071   { length= mi_uint2korr((key)+1); } \
00072 }
00073 
00074 #define get_key_pack_length(length,length_pack,key) \
00075 { if (*(unsigned char*) (key) != 255) \
00076   { length= (uint) *(unsigned char*) ((key)++); length_pack= 1; }\
00077   else \
00078   { length=mi_uint2korr((key)+1); (key)+= 3; length_pack= 3; } \
00079 }
00080 
00081 #define store_key_length_inc(key,length) \
00082 { if ((length) < 255) \
00083   { *(key)++= (length); } \
00084   else \
00085   { *(key)=255; mi_int2store((key)+1,(length)); (key)+=3; } \
00086 }
00087 
00088 #define size_to_store_key_length(length) ((length) < 255 ? 1 : 3)
00089 
00090 #define get_rec_bits(bit_ptr, bit_ofs, bit_len) \
00091   (((((uint16_t) (bit_ptr)[1] << 8) | (uint16_t) (bit_ptr)[0]) >> (bit_ofs)) & \
00092    ((1 << (bit_len)) - 1))
00093 
00094 #define set_rec_bits(bits, bit_ptr, bit_ofs, bit_len) \
00095 { \
00096   (bit_ptr)[0]= ((bit_ptr)[0] & ~(((1 << (bit_len)) - 1) << (bit_ofs))) | \
00097                 ((bits) << (bit_ofs)); \
00098   if ((bit_ofs) + (bit_len) > 8) \
00099     (bit_ptr)[1]= ((bit_ptr)[1] & ~((1 << ((bit_len) - 8 + (bit_ofs))) - 1)) | \
00100                   ((bits) >> (8 - (bit_ofs))); \
00101 }
00102 
00103 #define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \
00104   set_rec_bits(0, bit_ptr, bit_ofs, bit_len)
00105 
00106 extern int ha_compare_text(const drizzled::CHARSET_INFO * const, unsigned char *, uint, unsigned char *, uint, bool, bool);
00107 
00108 extern HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, unsigned char *a);
00109 void my_handler_error_register(void);
00110 extern int ha_key_cmp(HA_KEYSEG *keyseg, unsigned char *a,unsigned char *b,
00111                       uint32_t key_length,uint32_t nextflag,uint32_t *diff_length);
00112 
00113 /*
00114   Inside an in-memory data record, memory pointers to pieces of the
00115   record (like BLOBs) are stored in their native byte order and in
00116   this amount of bytes.
00117 */
00118 #define portable_sizeof_char_ptr 8
00119