~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to include/my_compare.h

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
 
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 */
 
15
 
 
16
#ifndef _my_compare_h
 
17
#define _my_compare_h
 
18
 
 
19
#include "my_base.h"
 
20
#include "m_ctype.h"
 
21
#include "myisampack.h"
 
22
 
 
23
typedef struct st_HA_KEYSEG             /* Key-portion */
 
24
{
 
25
  CHARSET_INFO *charset;
 
26
  uint32 start;                         /* Start of key in record */
 
27
  uint32 null_pos;                      /* position to NULL indicator */
 
28
  uint16 bit_pos;                       /* Position to bit part */
 
29
  uint16 flag;
 
30
  uint16 length;                        /* Keylength */
 
31
  uint8  type;                          /* Type of key (for sort) */
 
32
  uint8  language;
 
33
  uint8  null_bit;                      /* bitmask to test for NULL */
 
34
  uint8  bit_start,bit_end;             /* if bit field */
 
35
  uint8  bit_length;                    /* Length of bit part */
 
36
} HA_KEYSEG;
 
37
 
 
38
#define get_key_length(length,key) \
 
39
{ if ((uchar) *(key) != 255) \
 
40
    length= (uint) (uchar) *((key)++); \
 
41
  else \
 
42
  { length=mi_uint2korr((key)+1); (key)+=3; } \
 
43
}
 
44
 
 
45
#define get_key_length_rdonly(length,key) \
 
46
{ if ((uchar) *(key) != 255) \
 
47
    length= ((uint) (uchar) *((key))); \
 
48
  else \
 
49
  { length=mi_uint2korr((key)+1); } \
 
50
}
 
51
 
 
52
#define get_key_pack_length(length,length_pack,key) \
 
53
{ if ((uchar) *(key) != 255) \
 
54
  { length= (uint) (uchar) *((key)++); length_pack=1; }\
 
55
  else \
 
56
  { length=mi_uint2korr((key)+1); (key)+=3; length_pack=3; } \
 
57
}
 
58
 
 
59
#define store_key_length_inc(key,length) \
 
60
{ if ((length) < 255) \
 
61
  { *(key)++=(length); } \
 
62
  else \
 
63
  { *(key)=255; mi_int2store((key)+1,(length)); (key)+=3; } \
 
64
}
 
65
 
 
66
#define get_rec_bits(bit_ptr, bit_ofs, bit_len) \
 
67
  (((((uint16) (bit_ptr)[1] << 8) | (uint16) (bit_ptr)[0]) >> (bit_ofs)) & \
 
68
   ((1 << (bit_len)) - 1))
 
69
 
 
70
#define set_rec_bits(bits, bit_ptr, bit_ofs, bit_len) \
 
71
{ \
 
72
  (bit_ptr)[0]= ((bit_ptr)[0] & ~(((1 << (bit_len)) - 1) << (bit_ofs))) | \
 
73
                ((bits) << (bit_ofs)); \
 
74
  if ((bit_ofs) + (bit_len) > 8) \
 
75
    (bit_ptr)[1]= ((bit_ptr)[1] & ~((1 << ((bit_len) - 8 + (bit_ofs))) - 1)) | \
 
76
                  ((bits) >> (8 - (bit_ofs))); \
 
77
}
 
78
 
 
79
#define clr_rec_bits(bit_ptr, bit_ofs, bit_len) \
 
80
  set_rec_bits(0, bit_ptr, bit_ofs, bit_len)
 
81
 
 
82
extern int ha_compare_text(CHARSET_INFO *, uchar *, uint, uchar *, uint ,
 
83
                           my_bool, my_bool);
 
84
extern int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
 
85
                      register uchar *b, uint key_length, uint nextflag,
 
86
                      uint *diff_pos);
 
87
 
 
88
 
 
89
#endif /* _my_compare_h */