24
24
gives much more speed.
29
28
#include <drizzled/error.h>
30
29
#include <drizzled/table.h>
31
30
#include <drizzled/session.h>
32
#include <drizzled/current_session.h>
34
#include <drizzled/copy_field.h>
32
#include <drizzled/field/str.h>
33
#include <drizzled/field/num.h>
35
34
#include <drizzled/field/blob.h>
35
#include <drizzled/field/enum.h>
36
#include <drizzled/field/null.h>
36
37
#include <drizzled/field/date.h>
37
#include <drizzled/field/datetime.h>
38
38
#include <drizzled/field/decimal.h>
39
#include <drizzled/field/real.h>
39
40
#include <drizzled/field/double.h>
40
#include <drizzled/field/enum.h>
41
#include <drizzled/field/epoch.h>
42
41
#include <drizzled/field/int32.h>
43
42
#include <drizzled/field/int64.h>
44
#include <drizzled/field/null.h>
45
#include <drizzled/field/num.h>
46
#include <drizzled/field/num.h>
47
#include <drizzled/field/real.h>
48
#include <drizzled/field/str.h>
43
#include <drizzled/field/num.h>
44
#include <drizzled/field/epoch.h>
45
#include <drizzled/field/datetime.h>
49
46
#include <drizzled/field/varstring.h>
192
189
when set to NULL (TIMESTAMP fields which allow setting to NULL
193
190
are handled by first check).
195
if (field->is_timestamp())
192
if (field->type() == DRIZZLE_TYPE_TIMESTAMP)
197
194
((field::Epoch::pointer) field)->set_time();
198
195
return 0; // Ok to set time to NULL
387
384
static void do_cut_string(CopyField *copy)
389
386
const CHARSET_INFO * const cs= copy->from_field->charset();
390
memcpy(copy->to_ptr, copy->from_ptr, copy->to_length);
387
memcpy(copy->to_ptr,copy->from_ptr,copy->to_length);
392
389
/* Check if we loosed any important characters */
393
390
if (cs->cset->scan(cs,
465
462
length= copy->to_length - 1;
466
463
if (copy->from_field->getTable()->in_use->count_cuted_fields)
468
464
copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
469
465
ER_WARN_DATA_TRUNCATED, 1);
472
467
*(unsigned char*) copy->to_ptr= (unsigned char) length;
473
468
memcpy(copy->to_ptr+1, copy->from_ptr + 1, length);
487
482
if (length < from_length)
489
484
if (current_session->count_cuted_fields)
491
485
copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
492
486
ER_WARN_DATA_TRUNCATED, 1);
495
488
*copy->to_ptr= (unsigned char) length;
496
489
memcpy(copy->to_ptr + 1, from_ptr, length);
505
498
length=copy->to_length-HA_KEY_BLOB_LENGTH;
506
499
if (copy->from_field->getTable()->in_use->count_cuted_fields)
508
500
copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
509
501
ER_WARN_DATA_TRUNCATED, 1);
512
503
int2store(copy->to_ptr,length);
513
504
memcpy(copy->to_ptr+HA_KEY_BLOB_LENGTH, copy->from_ptr + HA_KEY_BLOB_LENGTH,
528
519
if (length < from_length)
530
521
if (current_session->count_cuted_fields)
532
522
copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
533
523
ER_WARN_DATA_TRUNCATED, 1);
536
525
int2store(copy->to_ptr, length);
537
526
memcpy(copy->to_ptr+HA_KEY_BLOB_LENGTH, from_beg, length);
675
664
if (from_length != to_length || !compatible_db_low_byte_first)
677
666
// Correct pointer to point at char pointer
678
to_ptr+= to_length - to->getTable()->getShare()->sizeBlobPtr();
679
from_ptr+= from_length- from->getTable()->getShare()->sizeBlobPtr();
667
to_ptr+= to_length - to->getTable()->getShare()->blob_ptr_size;
668
from_ptr+= from_length- from->getTable()->getShare()->blob_ptr_size;
680
669
return do_copy_blob;
859
848
return to->store(result.c_ptr_quick(),result.length(),from->charset());
861
850
else if (from->result_type() == REAL_RESULT)
863
851
return to->store(from->val_real());
865
852
else if (from->result_type() == DECIMAL_RESULT)
867
854
type::Decimal buff;
868
855
return to->store_decimal(from->val_decimal(&buff));
872
858
return to->store(from->val_int(), test(from->flags & UNSIGNED_FLAG));
876
861
} /* namespace drizzled */