~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/mi_key.cc

Small fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
/* Functions to handle keys */
17
17
 
18
 
#include "myisamdef.h"
 
18
#include "myisam_priv.h"
19
19
#include <mystrings/m_ctype.h>
20
20
#ifdef HAVE_IEEEFP_H
21
21
#include <ieeefp.h>
76
76
                  length);
77
77
 
78
78
    pos= (unsigned char*) record+keyseg->start;
79
 
    if (type == HA_KEYTYPE_BIT)
80
 
    {
81
 
      if (keyseg->bit_length)
82
 
      {
83
 
        unsigned char bits= get_rec_bits((unsigned char*) record + keyseg->bit_pos,
84
 
                                 keyseg->bit_start, keyseg->bit_length);
85
 
        *key++= bits;
86
 
        length--;
87
 
      }
88
 
      memcpy(key, pos, length);
89
 
      key+= length;
90
 
      continue;
91
 
    }
 
79
 
92
80
    if (keyseg->flag & HA_SPACE_PACK)
93
81
    {
94
 
      if (type != HA_KEYTYPE_NUM)
95
 
      {
96
 
        length= cs->cset->lengthsp(cs, (char*) pos, length);
97
 
      }
98
 
      else
99
 
      {
100
 
        unsigned char *end= pos + length;
101
 
        while (pos < end && pos[0] == ' ')
102
 
          pos++;
103
 
        length=(uint) (end-pos);
104
 
      }
 
82
      length= cs->cset->lengthsp(cs, (char*) pos, length);
 
83
 
105
84
      FIX_LENGTH(cs, pos, length, char_length);
106
85
      store_key_length_inc(key,char_length);
107
86
      memcpy(key, pos, char_length);
135
114
    else if (keyseg->flag & HA_SWAP_KEY)
136
115
    {                                           /* Numerical column */
137
116
#ifdef HAVE_ISNAN
138
 
      if (type == HA_KEYTYPE_FLOAT)
139
 
      {
140
 
        float nr;
141
 
        float4get(nr,pos);
142
 
        if (isnan(nr))
143
 
        {
144
 
          /* Replace NAN with zero */
145
 
          memset(key, 0, length);
146
 
          key+=length;
147
 
          continue;
148
 
        }
149
 
      }
150
 
      else if (type == HA_KEYTYPE_DOUBLE)
 
117
      if (type == HA_KEYTYPE_DOUBLE)
151
118
      {
152
119
        double nr;
153
120
        float8get(nr,pos);
227
194
    if (keyseg->flag & HA_SPACE_PACK)
228
195
    {
229
196
      unsigned char *end=pos+length;
230
 
      if (type == HA_KEYTYPE_NUM)
231
 
      {
232
 
        while (pos < end && pos[0] == ' ')
233
 
          pos++;
234
 
      }
235
 
      else if (type != HA_KEYTYPE_BINARY)
 
197
 
 
198
      if (type != HA_KEYTYPE_BINARY)
236
199
      {
237
200
        while (end > pos && end[-1] == ' ')
238
201
          end--;
319
282
      }
320
283
      record[keyseg->null_pos]&= ~keyseg->null_bit;
321
284
    }
322
 
    if (keyseg->type == HA_KEYTYPE_BIT)
323
 
    {
324
 
      uint32_t length= keyseg->length;
325
285
 
326
 
      if (keyseg->bit_length)
327
 
      {
328
 
        unsigned char bits= *key++;
329
 
        set_rec_bits(bits, record + keyseg->bit_pos, keyseg->bit_start,
330
 
                     keyseg->bit_length);
331
 
        length--;
332
 
      }
333
 
      else
334
 
      {
335
 
        clr_rec_bits(record + keyseg->bit_pos, keyseg->bit_start,
336
 
                     keyseg->bit_length);
337
 
      }
338
 
      memcpy(record + keyseg->start, key, length);
339
 
      key+= length;
340
 
      continue;
341
 
    }
342
286
    if (keyseg->flag & HA_SPACE_PACK)
343
287
    {
344
288
      uint32_t length;
348
292
        goto err;
349
293
#endif
350
294
      pos= record+keyseg->start;
351
 
      if (keyseg->type != (int) HA_KEYTYPE_NUM)
352
 
      {
353
 
        memcpy(pos, key, length);
354
 
        keyseg->charset->cset->fill(keyseg->charset,
355
 
                                    (char*) pos + length,
356
 
                                    keyseg->length - length,
357
 
                                    ' ');
358
 
      }
359
 
      else
360
 
      {
361
 
        memset(pos, ' ', keyseg->length-length);
362
 
        memcpy(pos+keyseg->length-length, key, length);
363
 
      }
 
295
 
 
296
      memcpy(pos, key, length);
 
297
      keyseg->charset->cset->fill(keyseg->charset,
 
298
                                  (char*) pos + length,
 
299
                                  keyseg->length - length,
 
300
                                  ' ');
364
301
      key+=length;
365
302
      continue;
366
303
    }
507
444
  const unsigned char *key= (unsigned char*) record + keyseg->start;
508
445
 
509
446
  switch (keyseg->type) {
510
 
  case HA_KEYTYPE_INT8:
511
 
    s_value= (int64_t) *(char*)key;
512
 
    break;
513
447
  case HA_KEYTYPE_BINARY:
514
448
    value=(uint64_t)  *(unsigned char*) key;
515
449
    break;
516
 
  case HA_KEYTYPE_SHORT_INT:
517
 
    s_value= (int64_t) sint2korr(key);
518
 
    break;
519
 
  case HA_KEYTYPE_USHORT_INT:
520
 
    value=(uint64_t) uint2korr(key);
521
 
    break;
522
450
  case HA_KEYTYPE_LONG_INT:
523
451
    s_value= (int64_t) sint4korr(key);
524
452
    break;
525
453
  case HA_KEYTYPE_ULONG_INT:
526
454
    value=(uint64_t) uint4korr(key);
527
455
    break;
528
 
  case HA_KEYTYPE_INT24:
529
 
    s_value= (int64_t) sint3korr(key);
530
 
    break;
531
456
  case HA_KEYTYPE_UINT24:
532
457
    value=(uint64_t) uint3korr(key);
533
458
    break;
534
 
  case HA_KEYTYPE_FLOAT:                        /* This shouldn't be used */
535
 
  {
536
 
    float f_1;
537
 
    float4get(f_1,key);
538
 
    /* Ignore negative values */
539
 
    value = (f_1 < (float) 0.0) ? 0 : (uint64_t) f_1;
540
 
    break;
541
 
  }
542
459
  case HA_KEYTYPE_DOUBLE:                       /* This shouldn't be used */
543
460
  {
544
461
    double f_1;