~jaypipes/drizzle/split-xa-resource-manager

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_key.cc

  • Committer: Jay Pipes
  • Date: 2010-02-06 01:51:20 UTC
  • mfrom: (1273.1.10 build)
  • Revision ID: jpipes@serialcoder-20100206015120-as4vb638inbzrb59
Merge trunk changes and resolve conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
            do {                                                            \
30
30
              if (length > char_length)                                     \
31
31
                char_length= my_charpos(cs, pos, pos+length, char_length);  \
32
 
              set_if_smaller(char_length,length);                           \
 
32
              drizzled::set_if_smaller(char_length,length);                           \
33
33
            } while(0)
34
34
 
35
35
static int _mi_put_key_in_record(MI_INFO *info,uint32_t keynr,unsigned char *record);
50
50
*/
51
51
 
52
52
uint32_t _mi_make_key(register MI_INFO *info, uint32_t keynr, unsigned char *key,
53
 
                  const unsigned char *record, my_off_t filepos)
 
53
                      const unsigned char *record, drizzled::internal::my_off_t filepos)
54
54
{
55
55
  unsigned char *pos;
56
56
  unsigned char *start;
59
59
  start=key;
60
60
  for (keyseg=info->s->keyinfo[keynr].seg ; keyseg->type ;keyseg++)
61
61
  {
62
 
    enum ha_base_keytype type=(enum ha_base_keytype) keyseg->type;
 
62
    enum drizzled::ha_base_keytype type=(enum drizzled::ha_base_keytype) keyseg->type;
63
63
    uint32_t length=keyseg->length;
64
64
    uint32_t char_length;
65
 
    const CHARSET_INFO * const cs=keyseg->charset;
 
65
    const drizzled::CHARSET_INFO * const cs=keyseg->charset;
66
66
 
67
67
    if (keyseg->null_bit)
68
68
    {
95
95
      uint32_t tmp_length= (pack_length == 1 ? (uint) *(unsigned char*) pos :
96
96
                        uint2korr(pos));
97
97
      pos+= pack_length;                        /* Skip VARCHAR length */
98
 
      set_if_smaller(length,tmp_length);
 
98
      drizzled::set_if_smaller(length,tmp_length);
99
99
      FIX_LENGTH(cs, pos, length, char_length);
100
100
      store_key_length_inc(key,char_length);
101
101
      memcpy(key, pos, char_length);
106
106
    {
107
107
      uint32_t tmp_length=_mi_calc_blob_length(keyseg->bit_start,pos);
108
108
      memcpy(&pos, pos+keyseg->bit_start, sizeof(char*));
109
 
      set_if_smaller(length,tmp_length);
 
109
      drizzled::set_if_smaller(length,tmp_length);
110
110
      FIX_LENGTH(cs, pos, length, char_length);
111
111
      store_key_length_inc(key,char_length);
112
112
      memcpy(key, pos, char_length);
115
115
    }
116
116
    else if (keyseg->flag & HA_SWAP_KEY)
117
117
    {                                           /* Numerical column */
118
 
      if (type == HA_KEYTYPE_DOUBLE)
 
118
      if (type == drizzled::HA_KEYTYPE_DOUBLE)
119
119
      {
120
120
        double nr;
121
121
        float8get(nr,pos);
163
163
*/
164
164
 
165
165
uint32_t _mi_pack_key(register MI_INFO *info, uint32_t keynr, unsigned char *key, unsigned char *old,
166
 
                  key_part_map keypart_map, HA_KEYSEG **last_used_keyseg)
 
166
                      drizzled::key_part_map keypart_map, HA_KEYSEG **last_used_keyseg)
167
167
{
168
168
  unsigned char *start_key=key;
169
169
  HA_KEYSEG *keyseg;
174
174
  for (keyseg= info->s->keyinfo[keynr].seg ; keyseg->type && keypart_map;
175
175
       old+= keyseg->length, keyseg++)
176
176
  {
177
 
    enum ha_base_keytype type= (enum ha_base_keytype) keyseg->type;
 
177
    enum drizzled::ha_base_keytype type= (enum drizzled::ha_base_keytype) keyseg->type;
178
178
    uint32_t length= keyseg->length;
179
179
    uint32_t char_length;
180
180
    unsigned char *pos;
181
 
    const CHARSET_INFO * const cs=keyseg->charset;
 
181
    const drizzled::CHARSET_INFO * const cs=keyseg->charset;
182
182
    keypart_map>>= 1;
183
183
    if (keyseg->null_bit)
184
184
    {
195
195
    {
196
196
      unsigned char *end=pos+length;
197
197
 
198
 
      if (type != HA_KEYTYPE_BINARY)
 
198
      if (type != drizzled::HA_KEYTYPE_BINARY)
199
199
      {
200
200
        while (end > pos && end[-1] == ' ')
201
201
          end--;
212
212
      /* Length of key-part used with mi_rkey() always 2 */
213
213
      uint32_t tmp_length=uint2korr(pos);
214
214
      pos+=2;
215
 
      set_if_smaller(length,tmp_length);        /* Safety */
 
215
      drizzled::set_if_smaller(length,tmp_length);      /* Safety */
216
216
      FIX_LENGTH(cs, pos, length, char_length);
217
217
      store_key_length_inc(key,char_length);
218
218
      old+=2;                                   /* Skip length */
372
372
 
373
373
        /* Here when key reads are used */
374
374
 
375
 
int _mi_read_key_record(MI_INFO *info, my_off_t filepos, unsigned char *buf)
 
375
int _mi_read_key_record(MI_INFO *info, drizzled::internal::my_off_t filepos, unsigned char *buf)
376
376
{
377
377
  fast_mi_writeinfo(info);
378
378
  if (filepos != HA_OFFSET_ERROR)
444
444
  const unsigned char *key= (unsigned char*) record + keyseg->start;
445
445
 
446
446
  switch (keyseg->type) {
447
 
  case HA_KEYTYPE_BINARY:
 
447
  case drizzled::HA_KEYTYPE_BINARY:
448
448
    value=(uint64_t)  *(unsigned char*) key;
449
449
    break;
450
 
  case HA_KEYTYPE_LONG_INT:
 
450
  case drizzled::HA_KEYTYPE_LONG_INT:
451
451
    s_value= (int64_t) sint4korr(key);
452
452
    break;
453
 
  case HA_KEYTYPE_ULONG_INT:
 
453
  case drizzled::HA_KEYTYPE_ULONG_INT:
454
454
    value=(uint64_t) uint4korr(key);
455
455
    break;
456
 
  case HA_KEYTYPE_UINT24:
 
456
  case drizzled::HA_KEYTYPE_UINT24:
457
457
    value=(uint64_t) uint3korr(key);
458
458
    break;
459
 
  case HA_KEYTYPE_DOUBLE:                       /* This shouldn't be used */
 
459
  case drizzled::HA_KEYTYPE_DOUBLE:                       /* This shouldn't be used */
460
460
  {
461
461
    double f_1;
462
462
    float8get(f_1,key);
464
464
    value = (f_1 < 0.0) ? 0 : (uint64_t) f_1;
465
465
    break;
466
466
  }
467
 
  case HA_KEYTYPE_LONGLONG:
 
467
  case drizzled::HA_KEYTYPE_LONGLONG:
468
468
    s_value= sint8korr(key);
469
469
    break;
470
 
  case HA_KEYTYPE_ULONGLONG:
 
470
  case drizzled::HA_KEYTYPE_ULONGLONG:
471
471
    value= uint8korr(key);
472
472
    break;
473
473
  default: