~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_unique.c

code clean move Item_func_abs, Item_func_int_exp, Item_func_ln, Item_func_log to functions directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
/* Functions to check if a row is unique */
17
17
 
18
 
#include "myisam_priv.h"
19
 
#include "drizzled/charset_info.h"
20
 
 
21
 
using namespace drizzled;
22
 
 
23
 
bool mi_check_unique(MI_INFO *info,
24
 
                     MI_UNIQUEDEF *def,
25
 
                     unsigned char *record,
26
 
                     internal::ha_checksum unique_hash,
27
 
                     internal::my_off_t disk_pos)
 
18
#include "myisamdef.h"
 
19
#include <mystrings/m_ctype.h>
 
20
 
 
21
bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, unsigned char *record,
 
22
                        ha_checksum unique_hash, my_off_t disk_pos)
28
23
{
29
 
  internal::my_off_t lastpos=info->lastpos;
 
24
  my_off_t lastpos=info->lastpos;
30
25
  MI_KEYDEF *key= &info->s->keyinfo[def->key];
31
26
  unsigned char *key_buff=info->lastkey2;
32
27
 
49
44
    if (info->lastpos != disk_pos &&
50
45
        !(*info->s->compare_unique)(info,def,record,info->lastpos))
51
46
    {
52
 
      errno=HA_ERR_FOUND_DUPP_UNIQUE;
 
47
      my_errno=HA_ERR_FOUND_DUPP_UNIQUE;
53
48
      info->errkey= (int) def->key;
54
49
      info->dupp_key_pos= info->lastpos;
55
50
      info->page_changed=1;                     /* Can't optimize read next */
76
71
    Add support for bit fields
77
72
*/
78
73
 
79
 
internal::ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const unsigned char *record)
 
74
ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const unsigned char *record)
80
75
{
81
76
  const unsigned char *pos, *end;
82
 
  internal::ha_checksum crc= 0;
 
77
  ha_checksum crc= 0;
83
78
  uint32_t seed1=0, seed2= 4;
84
79
  HA_KEYSEG *keyseg;
85
80
 
98
93
          done)
99
94
        */
100
95
        crc=((crc << 8) + 511+
101
 
             (crc >> (8*sizeof(internal::ha_checksum)-8)));
 
96
             (crc >> (8*sizeof(ha_checksum)-8)));
102
97
        continue;
103
98
      }
104
99
    }
131
126
      while (pos != end)
132
127
        crc=((crc << 8) +
133
128
             (((unsigned char)  *(unsigned char*) pos++))) +
134
 
          (crc >> (8*sizeof(internal::ha_checksum)-8));
 
129
          (crc >> (8*sizeof(ha_checksum)-8));
135
130
  }
136
131
  return crc;
137
132
}
157
152
  for (keyseg=def->seg ; keyseg < def->end ; keyseg++)
158
153
  {
159
154
    enum ha_base_keytype type=(enum ha_base_keytype) keyseg->type;
160
 
    uint16_t a_length, b_length;
 
155
    uint32_t a_length, b_length;
161
156
    a_length= b_length= keyseg->length;
162
157
 
163
158
    /* If part is NULL it's regarded as different */