2011-03-29 14:43:49 +02:00
|
|
|
/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
2003-01-21 19:24:34 +01:00
|
|
|
|
2011-03-29 14:43:49 +02:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; version 2 of the License.
|
2003-01-21 19:24:34 +01:00
|
|
|
|
2010-12-28 19:57:23 +01:00
|
|
|
This program is distributed in the hope that it will be useful,
|
2002-04-25 10:36:55 +02:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-03-29 14:43:49 +02:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2003-01-21 19:24:34 +01:00
|
|
|
|
2011-03-29 14:43:49 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2013-03-19 15:53:48 +01:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
|
2002-04-25 10:36:55 +02:00
|
|
|
|
2011-03-29 14:43:49 +02:00
|
|
|
#ifndef _my_compare_h
|
|
|
|
#define _my_compare_h
|
2002-04-25 10:36:55 +02:00
|
|
|
|
|
|
|
#include "myisampack.h"
|
2008-03-28 17:45:03 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2002-04-25 10:36:55 +02:00
|
|
|
|
2010-03-31 16:05:33 +02:00
|
|
|
#include "m_ctype.h" /* CHARSET_INFO */
|
|
|
|
|
2007-10-11 17:07:40 +02:00
|
|
|
/*
|
|
|
|
There is a hard limit for the maximum number of keys as there are only
|
|
|
|
8 bits in the index file header for the number of keys in a table.
|
|
|
|
This means that 0..255 keys can exist for a table. The idea of
|
|
|
|
HA_MAX_POSSIBLE_KEY is to ensure that one can use myisamchk & tools on
|
|
|
|
a MyISAM table for which one has more keys than MyISAM is normally
|
|
|
|
compiled for. If you don't have this, you will get a core dump when
|
|
|
|
running myisamchk compiled for 128 keys on a table with 255 keys.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define HA_MAX_POSSIBLE_KEY 255 /* For myisamchk */
|
|
|
|
/*
|
|
|
|
The following defines can be increased if necessary.
|
|
|
|
But beware the dependency of MI_MAX_POSSIBLE_KEY_BUFF and HA_MAX_KEY_LENGTH.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define HA_MAX_KEY_LENGTH 1000 /* Max length in bytes */
|
|
|
|
#define HA_MAX_KEY_SEG 16 /* Max segments for key */
|
|
|
|
|
|
|
|
#define HA_MAX_POSSIBLE_KEY_BUFF (HA_MAX_KEY_LENGTH + 24+ 6+6)
|
|
|
|
#define HA_MAX_KEY_BUFF (HA_MAX_KEY_LENGTH+HA_MAX_KEY_SEG*6+8+8)
|
|
|
|
|
2002-04-25 12:10:29 +02:00
|
|
|
typedef struct st_HA_KEYSEG /* Key-portion */
|
2002-04-25 10:36:55 +02:00
|
|
|
{
|
2004-12-30 23:44:00 +01:00
|
|
|
CHARSET_INFO *charset;
|
|
|
|
uint32 start; /* Start of key in record */
|
|
|
|
uint32 null_pos; /* position to NULL indicator */
|
|
|
|
uint16 bit_pos; /* Position to bit part */
|
|
|
|
uint16 flag;
|
|
|
|
uint16 length; /* Keylength */
|
2009-10-15 12:17:32 +02:00
|
|
|
uint16 language;
|
2002-04-25 10:36:55 +02:00
|
|
|
uint8 type; /* Type of key (for sort) */
|
|
|
|
uint8 null_bit; /* bitmask to test for NULL */
|
|
|
|
uint8 bit_start,bit_end; /* if bit field */
|
2004-12-30 23:44:00 +01:00
|
|
|
uint8 bit_length; /* Length of bit part */
|
2002-04-25 12:10:29 +02:00
|
|
|
} HA_KEYSEG;
|
2002-04-25 10:36:55 +02:00
|
|
|
|
|
|
|
#define get_key_length(length,key) \
|
2007-10-11 17:07:40 +02:00
|
|
|
{ if (*(uchar*) (key) != 255) \
|
|
|
|
length= (uint) *(uchar*) ((key)++); \
|
2002-04-25 10:36:55 +02:00
|
|
|
else \
|
2007-10-11 17:07:40 +02:00
|
|
|
{ length= mi_uint2korr((key)+1); (key)+=3; } \
|
2002-04-25 10:36:55 +02:00
|
|
|
}
|
|
|
|
|
2003-01-21 19:24:34 +01:00
|
|
|
#define get_key_length_rdonly(length,key) \
|
2007-10-11 17:07:40 +02:00
|
|
|
{ if (*(uchar*) (key) != 255) \
|
|
|
|
length= ((uint) *(uchar*) ((key))); \
|
2003-01-21 19:24:34 +01:00
|
|
|
else \
|
2007-10-11 17:07:40 +02:00
|
|
|
{ length= mi_uint2korr((key)+1); } \
|
2003-01-21 19:24:34 +01:00
|
|
|
}
|
|
|
|
|
2002-04-25 10:36:55 +02:00
|
|
|
#define get_key_pack_length(length,length_pack,key) \
|
2007-10-11 17:07:40 +02:00
|
|
|
{ if (*(uchar*) (key) != 255) \
|
|
|
|
{ length= (uint) *(uchar*) ((key)++); length_pack= 1; }\
|
2002-04-25 10:36:55 +02:00
|
|
|
else \
|
2007-10-11 17:07:40 +02:00
|
|
|
{ length=mi_uint2korr((key)+1); (key)+= 3; length_pack= 3; } \
|
2002-04-25 10:36:55 +02:00
|
|
|
}
|
|
|
|
|
2004-12-06 01:00:37 +01:00
|
|
|
#define store_key_length_inc(key,length) \
|
|
|
|
{ if ((length) < 255) \
|
2007-10-11 17:07:40 +02:00
|
|
|
{ *(key)++= (length); } \
|
2004-12-06 01:00:37 +01:00
|
|
|
else \
|
|
|
|
{ *(key)=255; mi_int2store((key)+1,(length)); (key)+=3; } \
|
|
|
|
}
|
|
|
|
|
2007-10-11 17:07:40 +02:00
|
|
|
#define size_to_store_key_length(length) ((length) < 255 ? 1 : 3)
|
|
|
|
|
2004-12-17 15:06:05 +01:00
|
|
|
#define get_rec_bits(bit_ptr, bit_ofs, bit_len) \
|
|
|
|
(((((uint16) (bit_ptr)[1] << 8) | (uint16) (bit_ptr)[0]) >> (bit_ofs)) & \
|
|
|
|
((1 << (bit_len)) - 1))
|
|
|
|
|
|
|
|
#define set_rec_bits(bits, bit_ptr, bit_ofs, bit_len) \
|
|
|
|
{ \
|
2005-05-05 14:17:55 +02:00
|
|
|
(bit_ptr)[0]= ((bit_ptr)[0] & ~(((1 << (bit_len)) - 1) << (bit_ofs))) | \
|
2004-12-17 15:06:05 +01:00
|
|
|
((bits) << (bit_ofs)); \
|
|
|
|
if ((bit_ofs) + (bit_len) > 8) \
|
2005-05-05 14:17:55 +02:00
|
|
|
(bit_ptr)[1]= ((bit_ptr)[1] & ~((1 << ((bit_len) - 8 + (bit_ofs))) - 1)) | \
|
|
|
|
((bits) >> (8 - (bit_ofs))); \
|
2004-12-17 15:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \
|
|
|
|
set_rec_bits(0, bit_ptr, bit_ofs, bit_len)
|
|
|
|
|
2007-10-11 17:07:40 +02:00
|
|
|
extern int ha_compare_text(CHARSET_INFO *, uchar *, uint, uchar *, uint ,
|
2004-03-25 14:05:01 +01:00
|
|
|
my_bool, my_bool);
|
2002-04-25 12:10:29 +02:00
|
|
|
extern int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
|
2002-05-21 18:54:08 +02:00
|
|
|
register uchar *b, uint key_length, uint nextflag,
|
|
|
|
uint *diff_pos);
|
2002-04-25 10:36:55 +02:00
|
|
|
|
2007-10-11 17:07:40 +02:00
|
|
|
/*
|
|
|
|
Inside an in-memory data record, memory pointers to pieces of the
|
|
|
|
record (like BLOBs) are stored in their native byte order and in
|
|
|
|
this amount of bytes.
|
|
|
|
*/
|
|
|
|
#define portable_sizeof_char_ptr 8
|
2008-03-28 17:45:03 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2005-10-21 04:29:17 +02:00
|
|
|
|
2011-03-29 14:43:49 +02:00
|
|
|
#endif /* _my_compare_h */
|