~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field_conv.cc

  • Committer: Brian Aker
  • Date: 2011-01-08 10:35:13 UTC
  • mfrom: (2057.2.9 timestamp)
  • Revision ID: brian@tangent.org-20110108103513-3wuo8tsyajjcxjrg
Merge in fractional seconds to timestamp.

Show diffs side-by-side

added added

removed removed

Lines of Context:
189
189
    when set to NULL (TIMESTAMP fields which allow setting to NULL
190
190
    are handled by first check).
191
191
  */
192
 
  if (field->type() == DRIZZLE_TYPE_TIMESTAMP)
 
192
  if (field->is_timestamp())
193
193
  {
194
194
    ((field::Epoch::pointer) field)->set_time();
195
195
    return 0;                                   // Ok to set time to NULL
384
384
static void do_cut_string(CopyField *copy)
385
385
{
386
386
  const CHARSET_INFO * const cs= copy->from_field->charset();
387
 
  memcpy(copy->to_ptr,copy->from_ptr,copy->to_length);
 
387
  memcpy(copy->to_ptr, copy->from_ptr, copy->to_length);
388
388
 
389
389
  /* Check if we loosed any important characters */
390
390
  if (cs->cset->scan(cs,
461
461
  {
462
462
    length= copy->to_length - 1;
463
463
    if (copy->from_field->getTable()->in_use->count_cuted_fields)
 
464
    {
464
465
      copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
465
466
                                  ER_WARN_DATA_TRUNCATED, 1);
 
467
    }
466
468
  }
467
469
  *(unsigned char*) copy->to_ptr= (unsigned char) length;
468
470
  memcpy(copy->to_ptr+1, copy->from_ptr + 1, length);
482
484
  if (length < from_length)
483
485
  {
484
486
    if (current_session->count_cuted_fields)
 
487
    {
485
488
      copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
486
489
                                  ER_WARN_DATA_TRUNCATED, 1);
 
490
    }
487
491
  }
488
492
  *copy->to_ptr= (unsigned char) length;
489
493
  memcpy(copy->to_ptr + 1, from_ptr, length);
497
501
  {
498
502
    length=copy->to_length-HA_KEY_BLOB_LENGTH;
499
503
    if (copy->from_field->getTable()->in_use->count_cuted_fields)
 
504
    {
500
505
      copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
501
506
                                  ER_WARN_DATA_TRUNCATED, 1);
 
507
    }
502
508
  }
503
509
  int2store(copy->to_ptr,length);
504
510
  memcpy(copy->to_ptr+HA_KEY_BLOB_LENGTH, copy->from_ptr + HA_KEY_BLOB_LENGTH,
519
525
  if (length < from_length)
520
526
  {
521
527
    if (current_session->count_cuted_fields)
 
528
    {
522
529
      copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
523
530
                                  ER_WARN_DATA_TRUNCATED, 1);
 
531
    }
524
532
  }
525
533
  int2store(copy->to_ptr, length);
526
534
  memcpy(copy->to_ptr+HA_KEY_BLOB_LENGTH, from_beg, length);
620
628
    }
621
629
    else
622
630
    {
623
 
      if (to_field->type() == DRIZZLE_TYPE_TIMESTAMP)
 
631
      if (to_field->is_timestamp())
624
632
      {
625
633
        do_copy= do_copy_timestamp;               // Automatic timestamp
626
634
      }
848
856
    return to->store(result.c_ptr_quick(),result.length(),from->charset());
849
857
  }
850
858
  else if (from->result_type() == REAL_RESULT)
 
859
  {
851
860
    return to->store(from->val_real());
 
861
  }
852
862
  else if (from->result_type() == DECIMAL_RESULT)
853
863
  {
854
864
    type::Decimal buff;
855
865
    return to->store_decimal(from->val_decimal(&buff));
856
866
  }
857
867
  else
 
868
  {
858
869
    return to->store(from->val_int(), test(from->flags & UNSIGNED_FLAG));
 
870
  }
859
871
}
860
872
 
861
873
} /* namespace drizzled */