~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field_conv.cc

  • Committer: Brian Aker
  • Date: 2010-12-15 21:28:47 UTC
  • mto: This revision was merged to the branch mainline in revision 1998.
  • Revision ID: brian@tangent.org-20101215212847-c52kuprsbrcm8sfk
Update name usage for user defined objects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include <drizzled/field/decimal.h>
39
39
#include <drizzled/field/real.h>
40
40
#include <drizzled/field/double.h>
41
 
#include <drizzled/field/int32.h>
42
 
#include <drizzled/field/int64.h>
 
41
#include <drizzled/field/long.h>
 
42
#include <drizzled/field/int64_t.h>
43
43
#include <drizzled/field/num.h>
44
44
#include <drizzled/field/timestamp.h>
45
45
#include <drizzled/field/datetime.h>
307
307
 
308
308
static void do_conv_blob(CopyField *copy)
309
309
{
310
 
  copy->from_field->val_str_internal(&copy->tmp);
 
310
  copy->from_field->val_str(&copy->tmp);
311
311
  ((Field_blob *) copy->to_field)->store(copy->tmp.ptr(),
312
312
                                         copy->tmp.length(),
313
313
                                         copy->tmp.charset());
319
319
{
320
320
  char buff[MAX_FIELD_WIDTH];
321
321
  String res(buff, sizeof(buff), copy->tmp.charset());
322
 
  copy->from_field->val_str_internal(&res);
 
322
  copy->from_field->val_str(&res);
323
323
  copy->tmp.copy(res);
324
324
  ((Field_blob *) copy->to_field)->store(copy->tmp.ptr(),
325
325
                                         copy->tmp.length(),
331
331
{
332
332
  char buff[MAX_FIELD_WIDTH];
333
333
  copy->tmp.set_quick(buff,sizeof(buff),copy->tmp.charset());
334
 
  copy->from_field->val_str_internal(&copy->tmp);
 
334
  copy->from_field->val_str(&copy->tmp);
335
335
  copy->to_field->store(copy->tmp.c_ptr_quick(),copy->tmp.length(),
336
336
                        copy->tmp.charset());
337
337
}
682
682
          {
683
683
            return do_field_int;  // Convert SET to number
684
684
          }
685
 
 
 
685
          
686
686
          return do_field_string;
687
687
        }
688
688
      }
689
 
 
 
689
      
690
690
      if (to->real_type() == DRIZZLE_TYPE_ENUM)
691
691
      {
692
692
        if (!to->eq_def(from))
703
703
      else if (to->real_type() == DRIZZLE_TYPE_VARCHAR)
704
704
      {
705
705
        /* Field_blob is not part of the Field_varstring hierarchy,
706
 
          and casting to varstring for calling pack_length_no_ptr()
707
 
          is always incorrect. Previously the below comparison has
708
 
          always evaluated to false as pack_length_no_ptr() for BLOB
709
 
          will return 4 and varstring can only be <= 2.
710
 
          If your brain slightly bleeds as to why this worked for
711
 
          so many years, you are in no way alone.
 
706
           and casting to varstring for calling pack_length_no_ptr()
 
707
           is always incorrect. Previously the below comparison has
 
708
           always evaluated to false as pack_length_no_ptr() for BLOB
 
709
           will return 4 and varstring can only be <= 2.
 
710
           If your brain slightly bleeds as to why this worked for
 
711
           so many years, you are in no way alone.
712
712
        */
713
713
        if (from->flags & BLOB_FLAG)
714
714
          return do_field_string;
718
718
        {
719
719
          return do_field_string;
720
720
        }
721
 
 
 
721
        
722
722
        if (to_length != from_length)
723
723
        {
724
724
          return (((Field_varstring*) to)->pack_length_no_ptr() == 1 ?
725
725
                  (from->charset()->mbmaxlen == 1 ? do_varstring1 :
726
 
                   do_varstring1_mb) :
 
726
                                                    do_varstring1_mb) :
727
727
                  (from->charset()->mbmaxlen == 1 ? do_varstring2 :
728
 
                   do_varstring2_mb));
 
728
                                                    do_varstring2_mb));
729
729
        }
730
730
      }
731
731
      else if (to_length < from_length)
805
805
  if (to->type() == DRIZZLE_TYPE_BLOB)
806
806
  {                                             // Be sure the value is stored
807
807
    Field_blob *blob=(Field_blob*) to;
808
 
    from->val_str_internal(&blob->value);
 
808
    from->val_str(&blob->value);
809
809
    /*
810
810
      Copy value if copy_blobs is set, or source is not a string and
811
811
      we have a pointer to its internal string conversion buffer.
829
829
  {
830
830
    char buff[MAX_FIELD_WIDTH];
831
831
    String result(buff,sizeof(buff),from->charset());
832
 
    from->val_str_internal(&result);
 
832
    from->val_str(&result);
833
833
    /*
834
834
      We use c_ptr_quick() here to make it easier if to is a float/double
835
835
      as the conversion routines will do a copy of the result doesn't