1
by brian
clean slate |
1 |
/* Copyright (C) 2002-2006 MySQL AB
|
2 |
||
3 |
This library is free software; you can redistribute it and/or
|
|
4 |
modify it under the terms of the GNU Library General Public
|
|
5 |
License as published by the Free Software Foundation; version 2
|
|
6 |
of the License.
|
|
7 |
||
8 |
This library is distributed in the hope that it will be useful,
|
|
9 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
11 |
Library General Public License for more details.
|
|
12 |
||
13 |
You should have received a copy of the GNU Library General Public
|
|
14 |
License along with this library; if not, write to the Free
|
|
15 |
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
|
16 |
MA 02111-1307, USA */
|
|
17 |
||
18 |
#ifndef _my_handler_h
|
|
19 |
#define _my_handler_h
|
|
20 |
||
21 |
#include "myisampack.h" |
|
22 |
#ifdef __cplusplus
|
|
23 |
extern "C" { |
|
24 |
#endif
|
|
25 |
||
26 |
/*
|
|
27 |
There is a hard limit for the maximum number of keys as there are only
|
|
28 |
8 bits in the index file header for the number of keys in a table.
|
|
29 |
This means that 0..255 keys can exist for a table. The idea of
|
|
30 |
HA_MAX_POSSIBLE_KEY is to ensure that one can use myisamchk & tools on
|
|
31 |
a MyISAM table for which one has more keys than MyISAM is normally
|
|
32 |
compiled for. If you don't have this, you will get a core dump when
|
|
33 |
running myisamchk compiled for 128 keys on a table with 255 keys.
|
|
34 |
*/
|
|
35 |
||
36 |
#define HA_MAX_POSSIBLE_KEY 255 /* For myisamchk */ |
|
37 |
/*
|
|
38 |
The following defines can be increased if necessary.
|
|
39 |
But beware the dependency of MI_MAX_POSSIBLE_KEY_BUFF and HA_MAX_KEY_LENGTH.
|
|
40 |
*/
|
|
41 |
||
42 |
#define HA_MAX_KEY_LENGTH 1332 /* Max length in bytes */ |
|
43 |
#define HA_MAX_KEY_SEG 16 /* Max segments for key */ |
|
44 |
||
45 |
#define HA_MAX_POSSIBLE_KEY_BUFF (HA_MAX_KEY_LENGTH + 24+ 6+6)
|
|
46 |
#define HA_MAX_KEY_BUFF (HA_MAX_KEY_LENGTH+HA_MAX_KEY_SEG*6+8+8)
|
|
47 |
||
48 |
typedef struct st_HA_KEYSEG /* Key-portion */ |
|
49 |
{
|
|
50 |
CHARSET_INFO *charset; |
|
51 |
uint32 start; /* Start of key in record */ |
|
52 |
uint32 null_pos; /* position to NULL indicator */ |
|
53 |
uint16 bit_pos; /* Position to bit part */ |
|
54 |
uint16 flag; |
|
55 |
uint16 length; /* Keylength */ |
|
56 |
uint8 type; /* Type of key (for sort) */ |
|
57 |
uint8 language; |
|
58 |
uint8 null_bit; /* bitmask to test for NULL */ |
|
59 |
uint8 bit_start,bit_end; /* if bit field */ |
|
60 |
uint8 bit_length; /* Length of bit part */ |
|
61 |
} HA_KEYSEG; |
|
62 |
||
63 |
#define get_key_length(length,key) \
|
|
64 |
{ if (*(uchar*) (key) != 255) \
|
|
65 |
length= (uint) *(uchar*) ((key)++); \
|
|
66 |
else \
|
|
67 |
{ length= mi_uint2korr((key)+1); (key)+=3; } \
|
|
68 |
}
|
|
69 |
||
70 |
#define get_key_length_rdonly(length,key) \
|
|
71 |
{ if (*(uchar*) (key) != 255) \
|
|
72 |
length= ((uint) *(uchar*) ((key))); \
|
|
73 |
else \
|
|
74 |
{ length= mi_uint2korr((key)+1); } \
|
|
75 |
}
|
|
76 |
||
77 |
#define get_key_pack_length(length,length_pack,key) \
|
|
78 |
{ if (*(uchar*) (key) != 255) \
|
|
79 |
{ length= (uint) *(uchar*) ((key)++); length_pack= 1; }\
|
|
80 |
else \
|
|
81 |
{ length=mi_uint2korr((key)+1); (key)+= 3; length_pack= 3; } \
|
|
82 |
}
|
|
83 |
||
84 |
#define store_key_length_inc(key,length) \
|
|
85 |
{ if ((length) < 255) \
|
|
86 |
{ *(key)++= (length); } \
|
|
87 |
else \
|
|
88 |
{ *(key)=255; mi_int2store((key)+1,(length)); (key)+=3; } \
|
|
89 |
}
|
|
90 |
||
91 |
#define size_to_store_key_length(length) ((length) < 255 ? 1 : 3)
|
|
92 |
||
93 |
#define get_rec_bits(bit_ptr, bit_ofs, bit_len) \
|
|
94 |
(((((uint16) (bit_ptr)[1] << 8) | (uint16) (bit_ptr)[0]) >> (bit_ofs)) & \
|
|
95 |
((1 << (bit_len)) - 1))
|
|
96 |
||
97 |
#define set_rec_bits(bits, bit_ptr, bit_ofs, bit_len) \
|
|
98 |
{ \
|
|
99 |
(bit_ptr)[0]= ((bit_ptr)[0] & ~(((1 << (bit_len)) - 1) << (bit_ofs))) | \
|
|
100 |
((bits) << (bit_ofs)); \
|
|
101 |
if ((bit_ofs) + (bit_len) > 8) \
|
|
102 |
(bit_ptr)[1]= ((bit_ptr)[1] & ~((1 << ((bit_len) - 8 + (bit_ofs))) - 1)) | \
|
|
103 |
((bits) >> (8 - (bit_ofs))); \
|
|
104 |
}
|
|
105 |
||
106 |
#define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \
|
|
107 |
set_rec_bits(0, bit_ptr, bit_ofs, bit_len)
|
|
108 |
||
109 |
extern int ha_compare_text(CHARSET_INFO *, uchar *, uint, uchar *, uint , |
|
110 |
my_bool, my_bool); |
|
111 |
||
112 |
extern HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a); |
|
113 |
extern void my_handler_error_register(void); |
|
114 |
extern void my_handler_error_unregister(void); |
|
77.1.7
by Monty Taylor
Heap builds clean. |
115 |
extern int ha_key_cmp(HA_KEYSEG *keyseg, uchar *a,uchar *b, |
116 |
uint key_length,uint nextflag,uint *diff_length); |
|
117 |
||
1
by brian
clean slate |
118 |
/*
|
119 |
Inside an in-memory data record, memory pointers to pieces of the
|
|
120 |
record (like BLOBs) are stored in their native byte order and in
|
|
121 |
this amount of bytes.
|
|
122 |
*/
|
|
123 |
#define portable_sizeof_char_ptr 8
|
|
124 |
#ifdef __cplusplus
|
|
125 |
}
|
|
126 |
#endif
|
|
127 |
||
128 |
#endif /* _my_handler_h */ |