~jaypipes/drizzle/new-test-runner

« back to all changes in this revision

Viewing changes to drizzled/field/varstring.cc

  • Committer: Jay Pipes
  • Date: 2008-12-11 17:52:34 UTC
  • mfrom: (482.16.152 testable)
  • Revision ID: jpipes@serialcoder-20081211175234-uqsfvmgxejvmellq
merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include <drizzled/table.h>
25
25
#include <drizzled/session.h>
26
26
 
 
27
#include <string>
 
28
 
 
29
using namespace std;
 
30
 
27
31
/****************************************************************************
28
32
  VARCHAR type
29
33
  Data in field->ptr is stored as:
211
215
  local_char_length= my_charpos(field_charset, ptr + length_bytes,
212
216
                          ptr + length_bytes + length, local_char_length);
213
217
  set_if_smaller(length, local_char_length);
214
 
  return field_charset->coll->strnncollsp(field_charset, 
 
218
  return field_charset->coll->strnncollsp(field_charset,
215
219
                                          ptr + length_bytes,
216
220
                                          length,
217
221
                                          key_ptr+
252
256
      mi_int2store(to+length-2, tot_length);
253
257
    length-= length_bytes;
254
258
  }
255
 
 
 
259
 
256
260
  tot_length= my_strnxfrm(field_charset,
257
261
                          to, length, ptr + length_bytes,
258
262
                          tot_length);
414
418
 
415
419
   @note
416
420
   The string length is always packed little-endian.
417
 
  
 
421
 
418
422
   @param   to         Destination of the data
419
423
   @param   from       Source of the data
420
424
   @param   param_data Length bytes from the master's field data
427
431
                        bool low_byte_first __attribute__((unused)))
428
432
{
429
433
  uint32_t length;
430
 
  uint32_t l_bytes= (param_data && (param_data < field_length)) ? 
 
434
  uint32_t l_bytes= (param_data && (param_data < field_length)) ?
431
435
                (param_data <= 255) ? 1 : 2 : length_bytes;
432
436
  if (l_bytes == 1)
433
437
  {
514
518
  return (max_length > 255 ? 2 : 1)+max_length;
515
519
}
516
520
 
 
521
uint32_t Field_varstring::get_key_image(basic_string<unsigned char> &buff,
 
522
                                        uint32_t length, imagetype)
 
523
{
 
524
  /* Key is always stored with 2 bytes */
 
525
  const uint32_t key_len= 2;
 
526
  uint32_t f_length=  length_bytes == 1 ? (uint) *ptr : uint2korr(ptr);
 
527
  uint32_t local_char_length= length / field_charset->mbmaxlen;
 
528
  unsigned char *pos= ptr+length_bytes;
 
529
  local_char_length= my_charpos(field_charset, pos, pos + f_length,
 
530
                                local_char_length);
 
531
  set_if_smaller(f_length, local_char_length);
 
532
  unsigned char len_buff[key_len];
 
533
  int2store(len_buff,f_length);
 
534
  buff.append(len_buff);
 
535
  buff.append(pos, f_length);
 
536
  if (f_length < length)
 
537
  {
 
538
    /*
 
539
      Must clear this as we do a memcmp in opt_range.cc to detect
 
540
      identical keys
 
541
    */
 
542
    buff.append(length-f_length, 0);
 
543
  }
 
544
  return key_len+f_length;
 
545
}
 
546
 
 
547
 
517
548
uint32_t Field_varstring::get_key_image(unsigned char *buff,
518
549
                                    uint32_t length,
519
550
                                    imagetype type __attribute__((unused)))