~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/varstring.cc

  • Committer: Monty Taylor
  • Date: 2008-12-06 07:22:02 UTC
  • mto: (656.1.7 devel) (660.1.5 codestyle)
  • mto: This revision was merged to the branch mainline in revision 665.
  • Revision ID: monty@inaugust.com-20081206072202-2g25o9doqr1l8euu
OOOh doggie. Got rid of my_alloca.

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:
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)))