24
24
gives much more speed.
28
#include <drizzled/error.h>
29
#include <drizzled/table.h>
30
#include <drizzled/session.h>
32
#include <drizzled/field/str.h>
33
#include <drizzled/field/num.h>
34
#include <drizzled/field/blob.h>
35
#include <drizzled/field/enum.h>
36
#include <drizzled/field/null.h>
37
#include <drizzled/field/date.h>
38
#include <drizzled/field/decimal.h>
39
#include <drizzled/field/real.h>
40
#include <drizzled/field/double.h>
41
#include <drizzled/field/long.h>
42
#include <drizzled/field/int64_t.h>
43
#include <drizzled/field/num.h>
44
#include <drizzled/field/timestamp.h>
45
#include <drizzled/field/datetime.h>
46
#include <drizzled/field/varstring.h>
49
static void do_field_eq(CopyField *copy)
51
memcpy(copy->to_ptr, copy->from_ptr, copy->from_length);
54
static void do_field_1(CopyField *copy)
56
copy->to_ptr[0]= copy->from_ptr[0];
59
static void do_field_2(CopyField *copy)
61
copy->to_ptr[0]= copy->from_ptr[0];
62
copy->to_ptr[1]= copy->from_ptr[1];
65
static void do_field_3(CopyField *copy)
67
copy->to_ptr[0]= copy->from_ptr[0];
68
copy->to_ptr[1]= copy->from_ptr[1];
69
copy->to_ptr[2]= copy->from_ptr[2];
72
static void do_field_4(CopyField *copy)
74
copy->to_ptr[0]= copy->from_ptr[0];
75
copy->to_ptr[1]= copy->from_ptr[1];
76
copy->to_ptr[2]= copy->from_ptr[2];
77
copy->to_ptr[3]= copy->from_ptr[3];
80
static void do_field_6(CopyField *copy)
82
copy->to_ptr[0]= copy->from_ptr[0];
83
copy->to_ptr[1]= copy->from_ptr[1];
84
copy->to_ptr[2]= copy->from_ptr[2];
85
copy->to_ptr[3]= copy->from_ptr[3];
86
copy->to_ptr[4]= copy->from_ptr[4];
87
copy->to_ptr[5]= copy->from_ptr[5];
90
static void do_field_8(CopyField *copy)
92
copy->to_ptr[0]= copy->from_ptr[0];
93
copy->to_ptr[1]= copy->from_ptr[1];
94
copy->to_ptr[2]= copy->from_ptr[2];
95
copy->to_ptr[3]= copy->from_ptr[3];
96
copy->to_ptr[4]= copy->from_ptr[4];
97
copy->to_ptr[5]= copy->from_ptr[5];
98
copy->to_ptr[6]= copy->from_ptr[6];
99
copy->to_ptr[7]= copy->from_ptr[7];
103
static void do_field_to_null_str(CopyField *copy)
27
#include "mysql_priv.h"
30
static void do_field_eq(Copy_field *copy)
32
memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
35
static void do_field_1(Copy_field *copy)
37
copy->to_ptr[0]=copy->from_ptr[0];
40
static void do_field_2(Copy_field *copy)
42
copy->to_ptr[0]=copy->from_ptr[0];
43
copy->to_ptr[1]=copy->from_ptr[1];
46
static void do_field_3(Copy_field *copy)
48
copy->to_ptr[0]=copy->from_ptr[0];
49
copy->to_ptr[1]=copy->from_ptr[1];
50
copy->to_ptr[2]=copy->from_ptr[2];
53
static void do_field_4(Copy_field *copy)
55
copy->to_ptr[0]=copy->from_ptr[0];
56
copy->to_ptr[1]=copy->from_ptr[1];
57
copy->to_ptr[2]=copy->from_ptr[2];
58
copy->to_ptr[3]=copy->from_ptr[3];
61
static void do_field_6(Copy_field *copy)
63
copy->to_ptr[0]=copy->from_ptr[0];
64
copy->to_ptr[1]=copy->from_ptr[1];
65
copy->to_ptr[2]=copy->from_ptr[2];
66
copy->to_ptr[3]=copy->from_ptr[3];
67
copy->to_ptr[4]=copy->from_ptr[4];
68
copy->to_ptr[5]=copy->from_ptr[5];
71
static void do_field_8(Copy_field *copy)
73
copy->to_ptr[0]=copy->from_ptr[0];
74
copy->to_ptr[1]=copy->from_ptr[1];
75
copy->to_ptr[2]=copy->from_ptr[2];
76
copy->to_ptr[3]=copy->from_ptr[3];
77
copy->to_ptr[4]=copy->from_ptr[4];
78
copy->to_ptr[5]=copy->from_ptr[5];
79
copy->to_ptr[6]=copy->from_ptr[6];
80
copy->to_ptr[7]=copy->from_ptr[7];
84
static void do_field_to_null_str(Copy_field *copy)
105
86
if (*copy->from_null_ptr & copy->from_bit)
107
memset(copy->to_ptr, 0, copy->from_length);
108
copy->to_null_ptr[0]= 1; // Always bit 1
88
bzero(copy->to_ptr,copy->from_length);
89
copy->to_null_ptr[0]=1; // Always bit 1
112
copy->to_null_ptr[0]= 0;
113
memcpy(copy->to_ptr, copy->from_ptr, copy->from_length);
93
copy->to_null_ptr[0]=0;
94
memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
118
static void do_outer_field_to_null_str(CopyField *copy)
99
static void do_outer_field_to_null_str(Copy_field *copy)
120
101
if (*copy->null_row ||
121
102
(copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit)))
123
memset(copy->to_ptr, 0, copy->from_length);
124
copy->to_null_ptr[0]= 1; // Always bit 1
104
bzero(copy->to_ptr,copy->from_length);
105
copy->to_null_ptr[0]=1; // Always bit 1
128
copy->to_null_ptr[0]= 0;
129
memcpy(copy->to_ptr, copy->from_ptr, copy->from_length);
109
copy->to_null_ptr[0]=0;
110
memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
293
static void do_copy_blob(CopyField *copy)
274
static void do_copy_blob(Copy_field *copy)
295
ulong length= ((Field_blob*) copy->from_field)->get_length();
276
ulong length=((Field_blob*) copy->from_field)->get_length();
296
277
((Field_blob*) copy->to_field)->store_length(length);
297
memcpy(copy->to_ptr, copy->from_ptr, sizeof(char*));
278
memcpy_fixed(copy->to_ptr,copy->from_ptr,sizeof(char*));
300
static void do_conv_blob(CopyField *copy)
281
static void do_conv_blob(Copy_field *copy)
302
283
copy->from_field->val_str(©->tmp);
303
284
((Field_blob *) copy->to_field)->store(copy->tmp.ptr(),
305
copy->tmp.charset());
286
copy->tmp.charset());
308
289
/** Save blob in copy->tmp for GROUP BY. */
310
static void do_save_blob(CopyField *copy)
291
static void do_save_blob(Copy_field *copy)
312
293
char buff[MAX_FIELD_WIDTH];
313
String res(buff, sizeof(buff), copy->tmp.charset());
294
String res(buff,sizeof(buff),copy->tmp.charset());
314
295
copy->from_field->val_str(&res);
315
296
copy->tmp.copy(res);
316
297
((Field_blob *) copy->to_field)->store(copy->tmp.ptr(),
318
copy->tmp.charset());
299
copy->tmp.charset());
322
static void do_field_string(CopyField *copy)
303
static void do_field_string(Copy_field *copy)
324
305
char buff[MAX_FIELD_WIDTH];
325
306
copy->tmp.set_quick(buff,sizeof(buff),copy->tmp.charset());
332
static void do_field_enum(CopyField *copy)
313
static void do_field_enum(Copy_field *copy)
334
315
if (copy->from_field->val_int() == 0)
335
((Field_enum *) copy->to_field)->store_type((uint64_t) 0);
316
((Field_enum *) copy->to_field)->store_type((ulonglong) 0);
337
318
do_field_string(copy);
341
static void do_field_int(CopyField *copy)
343
int64_t value= copy->from_field->val_int();
322
static void do_field_varbinary_pre50(Copy_field *copy)
324
char buff[MAX_FIELD_WIDTH];
325
copy->tmp.set_quick(buff,sizeof(buff),copy->tmp.charset());
326
copy->from_field->val_str(©->tmp);
328
/* Use the same function as in 4.1 to trim trailing spaces */
329
uint length= my_lengthsp_8bit(&my_charset_bin, copy->tmp.c_ptr_quick(),
330
copy->from_field->field_length);
332
copy->to_field->store(copy->tmp.c_ptr_quick(), length,
333
copy->tmp.charset());
337
static void do_field_int(Copy_field *copy)
339
longlong value= copy->from_field->val_int();
344
340
copy->to_field->store(value,
345
341
test(copy->from_field->flags & UNSIGNED_FLAG));
348
static void do_field_real(CopyField *copy)
344
static void do_field_real(Copy_field *copy)
350
346
double value=copy->from_field->val_real();
351
347
copy->to_field->store(value);
355
static void do_field_decimal(CopyField *copy)
351
static void do_field_decimal(Copy_field *copy)
357
353
my_decimal value;
358
354
copy->to_field->store_decimal(copy->from_field->val_decimal(&value));
421
static void do_expand_binary(CopyField *copy)
423
const CHARSET_INFO * const cs= copy->from_field->charset();
424
memcpy(copy->to_ptr, copy->from_ptr, copy->from_length);
425
cs->cset->fill(cs, (char*) copy->to_ptr+copy->from_length,
426
copy->to_length-copy->from_length, '\0');
431
static void do_expand_string(CopyField *copy)
433
const CHARSET_INFO * const cs= copy->from_field->charset();
434
memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
435
cs->cset->fill(cs, (char*) copy->to_ptr+copy->from_length,
436
copy->to_length-copy->from_length, ' ');
440
static void do_varstring1(CopyField *copy)
442
uint32_t length= (uint32_t) *(unsigned char*) copy->from_ptr;
417
static void do_expand_binary(Copy_field *copy)
419
CHARSET_INFO *cs= copy->from_field->charset();
420
memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
421
cs->cset->fill(cs, (char*) copy->to_ptr+copy->from_length,
422
copy->to_length-copy->from_length, '\0');
427
static void do_expand_string(Copy_field *copy)
429
CHARSET_INFO *cs= copy->from_field->charset();
430
memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
431
cs->cset->fill(cs, (char*) copy->to_ptr+copy->from_length,
432
copy->to_length-copy->from_length, ' ');
436
static void do_varstring1(Copy_field *copy)
438
uint length= (uint) *(uchar*) copy->from_ptr;
443
439
if (length > copy->to_length- 1)
445
length= copy->to_length - 1;
441
length=copy->to_length - 1;
446
442
if (copy->from_field->table->in_use->count_cuted_fields)
447
copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
448
ER_WARN_DATA_TRUNCATED, 1);
443
copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
444
WARN_DATA_TRUNCATED, 1);
450
*(unsigned char*) copy->to_ptr= (unsigned char) length;
446
*(uchar*) copy->to_ptr= (uchar) length;
451
447
memcpy(copy->to_ptr+1, copy->from_ptr + 1, length);
455
static void do_varstring1_mb(CopyField *copy)
451
static void do_varstring1_mb(Copy_field *copy)
457
453
int well_formed_error;
458
const CHARSET_INFO * const cs= copy->from_field->charset();
459
uint32_t from_length= (uint32_t) *(unsigned char*) copy->from_ptr;
460
const unsigned char *from_ptr= copy->from_ptr + 1;
461
uint32_t to_char_length= (copy->to_length - 1) / cs->mbmaxlen;
462
uint32_t length= cs->cset->well_formed_len(cs, (char*) from_ptr,
454
CHARSET_INFO *cs= copy->from_field->charset();
455
uint from_length= (uint) *(uchar*) copy->from_ptr;
456
const uchar *from_ptr= copy->from_ptr + 1;
457
uint to_char_length= (copy->to_length - 1) / cs->mbmaxlen;
458
uint length= cs->cset->well_formed_len(cs, (char*) from_ptr,
463
459
(char*) from_ptr + from_length,
464
460
to_char_length, &well_formed_error);
465
461
if (length < from_length)
467
if (current_session->count_cuted_fields)
468
copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
469
ER_WARN_DATA_TRUNCATED, 1);
463
if (current_thd->count_cuted_fields)
464
copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
465
WARN_DATA_TRUNCATED, 1);
471
*copy->to_ptr= (unsigned char) length;
467
*copy->to_ptr= (uchar) length;
472
468
memcpy(copy->to_ptr + 1, from_ptr, length);
476
static void do_varstring2(CopyField *copy)
472
static void do_varstring2(Copy_field *copy)
478
uint32_t length= uint2korr(copy->from_ptr);
474
uint length=uint2korr(copy->from_ptr);
479
475
if (length > copy->to_length- HA_KEY_BLOB_LENGTH)
481
477
length=copy->to_length-HA_KEY_BLOB_LENGTH;
482
478
if (copy->from_field->table->in_use->count_cuted_fields)
483
copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
484
ER_WARN_DATA_TRUNCATED, 1);
479
copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
480
WARN_DATA_TRUNCATED, 1);
486
482
int2store(copy->to_ptr,length);
487
483
memcpy(copy->to_ptr+HA_KEY_BLOB_LENGTH, copy->from_ptr + HA_KEY_BLOB_LENGTH,
492
static void do_varstring2_mb(CopyField *copy)
488
static void do_varstring2_mb(Copy_field *copy)
494
490
int well_formed_error;
495
const CHARSET_INFO * const cs= copy->from_field->charset();
496
uint32_t char_length= (copy->to_length - HA_KEY_BLOB_LENGTH) / cs->mbmaxlen;
497
uint32_t from_length= uint2korr(copy->from_ptr);
498
const unsigned char *from_beg= copy->from_ptr + HA_KEY_BLOB_LENGTH;
499
uint32_t length= cs->cset->well_formed_len(cs, (char*) from_beg,
500
(char*) from_beg + from_length,
501
char_length, &well_formed_error);
491
CHARSET_INFO *cs= copy->from_field->charset();
492
uint char_length= (copy->to_length - HA_KEY_BLOB_LENGTH) / cs->mbmaxlen;
493
uint from_length= uint2korr(copy->from_ptr);
494
const uchar *from_beg= copy->from_ptr + HA_KEY_BLOB_LENGTH;
495
uint length= cs->cset->well_formed_len(cs, (char*) from_beg,
496
(char*) from_beg + from_length,
497
char_length, &well_formed_error);
502
498
if (length < from_length)
504
if (current_session->count_cuted_fields)
505
copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
506
ER_WARN_DATA_TRUNCATED, 1);
500
if (current_thd->count_cuted_fields)
501
copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
502
WARN_DATA_TRUNCATED, 1);
508
504
int2store(copy->to_ptr, length);
509
505
memcpy(copy->to_ptr+HA_KEY_BLOB_LENGTH, from_beg, length);
513
509
/***************************************************************************
514
** The different functions that fills in a CopyField class
510
** The different functions that fills in a Copy_field class
515
511
***************************************************************************/
522
518
The 'to' buffer should have a size of field->pack_length()+1
525
void CopyField::set(unsigned char *to,Field *from)
521
void Copy_field::set(uchar *to,Field *from)
529
from_length= from->pack_length();
525
from_length=from->pack_length();
530
526
if (from->maybe_null())
532
from_null_ptr= from->null_ptr;
533
from_bit= from->null_bit;
534
to_ptr[0]= 1; // Null as default value
535
to_null_ptr= (unsigned char*) to_ptr++;
528
from_null_ptr=from->null_ptr;
529
from_bit= from->null_bit;
530
to_ptr[0]= 1; // Null as default value
531
to_null_ptr= (uchar*) to_ptr++;
537
533
if (from->table->maybe_null)
539
null_row= &from->table->null_row;
540
do_copy= do_outer_field_to_null_str;
535
null_row= &from->table->null_row;
536
do_copy= do_outer_field_to_null_str;
543
do_copy= do_field_to_null_str;
539
do_copy= do_field_to_null_str;
547
to_null_ptr= 0; // For easy debugging
548
do_copy= do_field_eq;
543
to_null_ptr= 0; // For easy debugging
544
do_copy= do_field_eq;
556
552
If 'save\ is set to true and the 'from' is a blob field, do_copy is set to
557
553
do_save_blob rather than do_conv_blob. The only differences between them
560
- do_save_blob allocates and uses an intermediate buffer before calling
561
Field_blob::store. Is this in order to trigger the call to
556
- do_save_blob allocates and uses an intermediate buffer before calling
557
Field_blob::store. Is this in order to trigger the call to
562
558
well_formed_copy_nchars, by changing the pointer copy->tmp.ptr()?
563
559
That call will take place anyway in all known cases.
565
- The above causes a truncation to MAX_FIELD_WIDTH. Is this the intended
561
- The above causes a truncation to MAX_FIELD_WIDTH. Is this the intended
566
562
effect? Truncation is handled by well_formed_copy_nchars anyway.
568
void CopyField::set(Field *to,Field *from,bool save)
564
void Copy_field::set(Field *to,Field *from,bool save)
570
if (to->type() == DRIZZLE_TYPE_NULL)
566
if (to->type() == MYSQL_TYPE_NULL)
572
to_null_ptr= 0; // For easy debugging
568
to_null_ptr=0; // For easy debugging
580
from_length= from->pack_length();
582
to_length= to_field->pack_length();
576
from_length=from->pack_length();
578
to_length=to_field->pack_length();
584
580
// set up null handling
585
from_null_ptr= to_null_ptr= 0;
581
from_null_ptr=to_null_ptr=0;
586
582
if (from->maybe_null())
588
from_null_ptr= from->null_ptr;
589
from_bit= from->null_bit;
584
from_null_ptr= from->null_ptr;
585
from_bit= from->null_bit;
590
586
if (to_field->real_maybe_null())
592
to_null_ptr= to->null_ptr;
593
to_bit= to->null_bit;
588
to_null_ptr= to->null_ptr;
589
to_bit= to->null_bit;
594
590
if (from_null_ptr)
595
do_copy= do_copy_null;
591
do_copy= do_copy_null;
598
null_row= &from->table->null_row;
599
do_copy= do_outer_field_null;
594
null_row= &from->table->null_row;
595
do_copy= do_outer_field_null;
604
if (to_field->type() == DRIZZLE_TYPE_TIMESTAMP)
600
if (to_field->type() == MYSQL_TYPE_TIMESTAMP)
605
601
do_copy= do_copy_timestamp; // Automatic timestamp
606
602
else if (to_field == to_field->table->next_number_field)
607
603
do_copy= do_copy_next_number;
639
635
if (from_length != to_length || !compatible_db_low_byte_first)
641
637
// Correct pointer to point at char pointer
642
to_ptr+= to_length - to->table->s->blob_ptr_size;
638
to_ptr+= to_length - to->table->s->blob_ptr_size;
643
639
from_ptr+= from_length- from->table->s->blob_ptr_size;
644
640
return do_copy_blob;
645
if (to->real_type() == MYSQL_TYPE_BIT ||
646
from->real_type() == MYSQL_TYPE_BIT)
649
648
if (to->result_type() == DECIMAL_RESULT)
650
649
return do_field_decimal;
652
650
// Check if identical fields
653
651
if (from->result_type() == STRING_RESULT)
654
Detect copy from pre 5.0 varbinary to varbinary as of 5.0 and
655
use special copy function that removes trailing spaces and thus
658
if (from->type() == MYSQL_TYPE_VAR_STRING && !from->has_charset() &&
659
to->type() == MYSQL_TYPE_VARCHAR && !to->has_charset())
660
return do_field_varbinary_pre50;
656
663
If we are copying date or datetime's we have to check the dates
657
664
if we don't allow 'all' dates.
659
666
if (to->real_type() != from->real_type() ||
660
667
!compatible_db_low_byte_first ||
661
(((to->table->in_use->variables.sql_mode & (MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) && to->type() == DRIZZLE_TYPE_DATE) || to->type() == DRIZZLE_TYPE_DATETIME))
668
(((to->table->in_use->variables.sql_mode & (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) && to->type() == MYSQL_TYPE_DATE) || to->type() == MYSQL_TYPE_DATETIME))
663
if (from->real_type() == DRIZZLE_TYPE_ENUM)
665
if (to->result_type() != STRING_RESULT)
667
return do_field_int; // Convert SET to number
670
return do_field_string;
670
if (from->real_type() == MYSQL_TYPE_ENUM ||
671
from->real_type() == MYSQL_TYPE_SET)
672
if (to->result_type() != STRING_RESULT)
673
return do_field_int; // Convert SET to number
674
return do_field_string;
674
if (to->real_type() == DRIZZLE_TYPE_ENUM)
676
if (to->real_type() == MYSQL_TYPE_ENUM ||
677
to->real_type() == MYSQL_TYPE_SET)
676
if (!to->eq_def(from))
679
if (!to->eq_def(from))
678
if (from->real_type() == DRIZZLE_TYPE_ENUM &&
679
to->real_type() == DRIZZLE_TYPE_ENUM)
681
if (from->real_type() == MYSQL_TYPE_ENUM &&
682
to->real_type() == MYSQL_TYPE_ENUM)
680
683
return do_field_enum;
682
685
return do_field_string;
685
688
else if (to->charset() != from->charset())
686
return do_field_string;
687
else if (to->real_type() == DRIZZLE_TYPE_VARCHAR)
689
return do_field_string;
690
else if (to->real_type() == MYSQL_TYPE_VARCHAR)
689
692
if (((Field_varstring*) to)->length_bytes !=
690
693
((Field_varstring*) from)->length_bytes)
692
694
return do_field_string;
695
695
if (to_length != from_length)
697
696
return (((Field_varstring*) to)->length_bytes == 1 ?
698
697
(from->charset()->mbmaxlen == 1 ? do_varstring1 :
699
698
do_varstring1_mb) :
700
699
(from->charset()->mbmaxlen == 1 ? do_varstring2 :
701
700
do_varstring2_mb));
704
702
else if (to_length < from_length)
706
return (from->charset()->mbmaxlen == 1 ?
703
return (from->charset()->mbmaxlen == 1 ?
707
704
do_cut_string : do_cut_string_complex);
709
705
else if (to_length > from_length)
711
707
if (to->charset() == &my_charset_bin)
757
753
int field_conv(Field *to,Field *from)
759
755
if (to->real_type() == from->real_type() &&
760
!(to->type() == DRIZZLE_TYPE_BLOB && to->table->copy_blobs))
756
!(to->type() == MYSQL_TYPE_BLOB && to->table->copy_blobs))
762
758
/* Please god, will someone rewrite this to be readable :( */
763
if (to->pack_length() == from->pack_length() &&
764
!(to->flags & UNSIGNED_FLAG && !(from->flags & UNSIGNED_FLAG)) &&
765
to->real_type() != DRIZZLE_TYPE_ENUM &&
766
(to->real_type() != DRIZZLE_TYPE_DECIMAL || (to->field_length == from->field_length && (((Field_num*)to)->dec == ((Field_num*)from)->dec))) &&
759
if (to->pack_length() == from->pack_length() &&
760
!(to->flags & UNSIGNED_FLAG && !(from->flags & UNSIGNED_FLAG)) &&
761
to->real_type() != MYSQL_TYPE_ENUM &&
762
to->real_type() != MYSQL_TYPE_SET && to->real_type() != MYSQL_TYPE_BIT &&
763
(to->real_type() != MYSQL_TYPE_NEWDECIMAL || (to->field_length == from->field_length && (((Field_num*)to)->dec == ((Field_num*)from)->dec))) &&
767
764
from->charset() == to->charset() &&
768
765
to->table->s->db_low_byte_first == from->table->s->db_low_byte_first &&
769
(!(to->table->in_use->variables.sql_mode & (MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) || (to->type() != DRIZZLE_TYPE_DATE && to->type() != DRIZZLE_TYPE_DATETIME)) &&
770
(from->real_type() != DRIZZLE_TYPE_VARCHAR || ((Field_varstring*)from)->length_bytes == ((Field_varstring*)to)->length_bytes))
766
(!(to->table->in_use->variables.sql_mode & (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) || (to->type() != MYSQL_TYPE_DATE && to->type() != MYSQL_TYPE_DATETIME)) &&
767
(from->real_type() != MYSQL_TYPE_VARCHAR || ((Field_varstring*)from)->length_bytes == ((Field_varstring*)to)->length_bytes))
771
768
{ // Identical fields
772
770
/* This may happen if one does 'UPDATE ... SET x=x' */
773
771
if (to->ptr != from->ptr)
774
773
memcpy(to->ptr,from->ptr,to->pack_length());
778
if (to->type() == DRIZZLE_TYPE_BLOB)
777
if (to->type() == MYSQL_TYPE_BLOB)
779
778
{ // Be sure the value is stored
780
779
Field_blob *blob=(Field_blob*) to;
781
780
from->val_str(&blob->value);