24
24
gives much more speed.
27
#include <drizzled/server_includes.h>
28
29
#include <drizzled/error.h>
29
30
#include <drizzled/table.h>
30
31
#include <drizzled/session.h>
32
#include <drizzled/current_session.h>
32
#include <drizzled/field/str.h>
33
#include <drizzled/field/longstr.h>
34
#include <drizzled/field/num.h>
34
#include <drizzled/copy_field.h>
35
35
#include <drizzled/field/blob.h>
36
#include <drizzled/field/date.h>
37
#include <drizzled/field/datetime.h>
38
#include <drizzled/field/decimal.h>
39
#include <drizzled/field/double.h>
36
40
#include <drizzled/field/enum.h>
41
#include <drizzled/field/epoch.h>
42
#include <drizzled/field/int32.h>
43
#include <drizzled/field/int64.h>
37
44
#include <drizzled/field/null.h>
38
#include <drizzled/field/date.h>
39
#include <drizzled/field/fdecimal.h>
45
#include <drizzled/field/num.h>
46
#include <drizzled/field/num.h>
40
47
#include <drizzled/field/real.h>
41
#include <drizzled/field/double.h>
42
#include <drizzled/field/long.h>
43
#include <drizzled/field/int64_t.h>
44
#include <drizzled/field/num.h>
45
#include <drizzled/field/timetype.h>
46
#include <drizzled/field/timestamp.h>
47
#include <drizzled/field/datetime.h>
48
#include <drizzled/field/fstring.h>
48
#include <drizzled/field/str.h>
49
49
#include <drizzled/field/varstring.h>
52
static void do_field_eq(Copy_field *copy)
54
memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
57
static void do_field_1(Copy_field *copy)
59
copy->to_ptr[0]=copy->from_ptr[0];
62
static void do_field_2(Copy_field *copy)
64
copy->to_ptr[0]=copy->from_ptr[0];
65
copy->to_ptr[1]=copy->from_ptr[1];
68
static void do_field_3(Copy_field *copy)
70
copy->to_ptr[0]=copy->from_ptr[0];
71
copy->to_ptr[1]=copy->from_ptr[1];
72
copy->to_ptr[2]=copy->from_ptr[2];
75
static void do_field_4(Copy_field *copy)
77
copy->to_ptr[0]=copy->from_ptr[0];
78
copy->to_ptr[1]=copy->from_ptr[1];
79
copy->to_ptr[2]=copy->from_ptr[2];
80
copy->to_ptr[3]=copy->from_ptr[3];
83
static void do_field_6(Copy_field *copy)
85
copy->to_ptr[0]=copy->from_ptr[0];
86
copy->to_ptr[1]=copy->from_ptr[1];
87
copy->to_ptr[2]=copy->from_ptr[2];
88
copy->to_ptr[3]=copy->from_ptr[3];
89
copy->to_ptr[4]=copy->from_ptr[4];
90
copy->to_ptr[5]=copy->from_ptr[5];
93
static void do_field_8(Copy_field *copy)
95
copy->to_ptr[0]=copy->from_ptr[0];
96
copy->to_ptr[1]=copy->from_ptr[1];
97
copy->to_ptr[2]=copy->from_ptr[2];
98
copy->to_ptr[3]=copy->from_ptr[3];
99
copy->to_ptr[4]=copy->from_ptr[4];
100
copy->to_ptr[5]=copy->from_ptr[5];
101
copy->to_ptr[6]=copy->from_ptr[6];
102
copy->to_ptr[7]=copy->from_ptr[7];
106
static void do_field_to_null_str(Copy_field *copy)
50
#include <drizzled/util/test.h>
51
#include <drizzled/system_variables.h>
55
static void do_field_eq(CopyField *copy)
57
memcpy(copy->to_ptr, copy->from_ptr, copy->from_length);
60
static void do_field_1(CopyField *copy)
62
copy->to_ptr[0]= copy->from_ptr[0];
65
static void do_field_2(CopyField *copy)
67
copy->to_ptr[0]= copy->from_ptr[0];
68
copy->to_ptr[1]= copy->from_ptr[1];
71
static void do_field_3(CopyField *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];
78
static void do_field_4(CopyField *copy)
80
copy->to_ptr[0]= copy->from_ptr[0];
81
copy->to_ptr[1]= copy->from_ptr[1];
82
copy->to_ptr[2]= copy->from_ptr[2];
83
copy->to_ptr[3]= copy->from_ptr[3];
86
static void do_field_6(CopyField *copy)
88
copy->to_ptr[0]= copy->from_ptr[0];
89
copy->to_ptr[1]= copy->from_ptr[1];
90
copy->to_ptr[2]= copy->from_ptr[2];
91
copy->to_ptr[3]= copy->from_ptr[3];
92
copy->to_ptr[4]= copy->from_ptr[4];
93
copy->to_ptr[5]= copy->from_ptr[5];
96
static void do_field_8(CopyField *copy)
98
copy->to_ptr[0]= copy->from_ptr[0];
99
copy->to_ptr[1]= copy->from_ptr[1];
100
copy->to_ptr[2]= copy->from_ptr[2];
101
copy->to_ptr[3]= copy->from_ptr[3];
102
copy->to_ptr[4]= copy->from_ptr[4];
103
copy->to_ptr[5]= copy->from_ptr[5];
104
copy->to_ptr[6]= copy->from_ptr[6];
105
copy->to_ptr[7]= copy->from_ptr[7];
109
static void do_field_to_null_str(CopyField *copy)
108
111
if (*copy->from_null_ptr & copy->from_bit)
110
113
memset(copy->to_ptr, 0, copy->from_length);
111
copy->to_null_ptr[0]=1; // Always bit 1
114
copy->to_null_ptr[0]= 1; // Always bit 1
115
copy->to_null_ptr[0]=0;
116
memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
118
copy->to_null_ptr[0]= 0;
119
memcpy(copy->to_ptr, copy->from_ptr, copy->from_length);
121
static void do_outer_field_to_null_str(Copy_field *copy)
124
static void do_outer_field_to_null_str(CopyField *copy)
123
126
if (*copy->null_row ||
124
127
(copy->from_null_ptr && (*copy->from_null_ptr & copy->from_bit)))
126
129
memset(copy->to_ptr, 0, copy->from_length);
127
copy->to_null_ptr[0]=1; // Always bit 1
130
copy->to_null_ptr[0]= 1; // Always bit 1
131
copy->to_null_ptr[0]=0;
132
memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
134
copy->to_null_ptr[0]= 0;
135
memcpy(copy->to_ptr, copy->from_ptr, copy->from_length);
189
193
when set to NULL (TIMESTAMP fields which allow setting to NULL
190
194
are handled by first check).
192
if (field->type() == DRIZZLE_TYPE_TIMESTAMP)
196
if (field->is_timestamp())
194
((Field_timestamp*) field)->set_time();
198
((field::Epoch::pointer) field)->set_time();
195
199
return 0; // Ok to set time to NULL
198
if (field == field->table->next_number_field)
203
if (field == field->getTable()->next_number_field)
200
field->table->auto_increment_field_not_null= false;
205
field->getTable()->auto_increment_field_not_null= false;
201
206
return 0; // field is set in fill_record()
203
if (field->table->in_use->count_cuted_fields == CHECK_FIELD_WARN)
209
if (field->getTable()->in_use->count_cuted_fields == CHECK_FIELD_WARN)
205
211
field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_BAD_NULL_ERROR, 1);
208
if (!field->table->in_use->no_errors)
215
if (!field->getTable()->in_use->no_errors)
209
216
my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name);
214
static void do_skip(Copy_field *copy __attribute__((unused)))
222
static void do_skip(CopyField *)
219
static void do_copy_null(Copy_field *copy)
227
static void do_copy_null(CopyField *copy)
221
229
if (*copy->from_null_ptr & copy->from_bit)
223
*copy->to_null_ptr|=copy->to_bit;
231
*copy->to_null_ptr|= copy->to_bit;
224
232
copy->to_field->reset();
269
283
/* timestamp and next_number has special handling in case of NULL values */
271
static void do_copy_timestamp(Copy_field *copy)
285
static void do_copy_timestamp(CopyField *copy)
273
287
if (*copy->from_null_ptr & copy->from_bit)
275
289
/* Same as in set_field_to_null_with_conversions() */
276
((Field_timestamp*) copy->to_field)->set_time();
290
((field::Epoch::pointer) copy->to_field)->set_time();
279
294
(copy->do_copy2)(copy);
283
static void do_copy_next_number(Copy_field *copy)
299
static void do_copy_next_number(CopyField *copy)
285
301
if (*copy->from_null_ptr & copy->from_bit)
287
303
/* Same as in set_field_to_null_with_conversions() */
288
copy->to_field->table->auto_increment_field_not_null= false;
304
copy->to_field->getTable()->auto_increment_field_not_null= false;
289
305
copy->to_field->reset();
292
309
(copy->do_copy2)(copy);
296
static void do_copy_blob(Copy_field *copy)
314
static void do_copy_blob(CopyField *copy)
298
ulong length=((Field_blob*) copy->from_field)->get_length();
316
ulong length= ((Field_blob*) copy->from_field)->get_length();
299
317
((Field_blob*) copy->to_field)->store_length(length);
300
memcpy(copy->to_ptr,copy->from_ptr,sizeof(char*));
318
memcpy(copy->to_ptr, copy->from_ptr, sizeof(char*));
303
static void do_conv_blob(Copy_field *copy)
321
static void do_conv_blob(CopyField *copy)
305
copy->from_field->val_str(©->tmp);
323
copy->from_field->val_str_internal(©->tmp);
306
324
((Field_blob *) copy->to_field)->store(copy->tmp.ptr(),
308
copy->tmp.charset());
326
copy->tmp.charset());
311
329
/** Save blob in copy->tmp for GROUP BY. */
313
static void do_save_blob(Copy_field *copy)
331
static void do_save_blob(CopyField *copy)
315
333
char buff[MAX_FIELD_WIDTH];
316
String res(buff,sizeof(buff),copy->tmp.charset());
317
copy->from_field->val_str(&res);
334
String res(buff, sizeof(buff), copy->tmp.charset());
335
copy->from_field->val_str_internal(&res);
318
336
copy->tmp.copy(res);
319
337
((Field_blob *) copy->to_field)->store(copy->tmp.ptr(),
321
copy->tmp.charset());
339
copy->tmp.charset());
325
static void do_field_string(Copy_field *copy)
343
static void do_field_string(CopyField *copy)
327
345
char buff[MAX_FIELD_WIDTH];
328
346
copy->tmp.set_quick(buff,sizeof(buff),copy->tmp.charset());
329
copy->from_field->val_str(©->tmp);
330
copy->to_field->store(copy->tmp.c_ptr_quick(),copy->tmp.length(),
331
copy->tmp.charset());
347
copy->from_field->val_str_internal(©->tmp);
348
copy->to_field->store(copy->tmp.data(),copy->tmp.length(), copy->tmp.charset());
335
static void do_field_enum(Copy_field *copy)
352
static void do_field_enum(CopyField *copy)
337
354
if (copy->from_field->val_int() == 0)
338
355
((Field_enum *) copy->to_field)->store_type((uint64_t) 0);
424
static void do_expand_binary(Copy_field *copy)
426
const CHARSET_INFO * const cs= copy->from_field->charset();
427
memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
428
cs->cset->fill(cs, (char*) copy->to_ptr+copy->from_length,
429
copy->to_length-copy->from_length, '\0');
434
static void do_expand_string(Copy_field *copy)
436
const CHARSET_INFO * const cs= copy->from_field->charset();
437
memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
438
cs->cset->fill(cs, (char*) copy->to_ptr+copy->from_length,
439
copy->to_length-copy->from_length, ' ');
443
static void do_varstring1(Copy_field *copy)
445
uint32_t length= (uint) *(unsigned char*) copy->from_ptr;
441
static void do_expand_binary(CopyField *copy)
443
const charset_info_st * const cs= copy->from_field->charset();
444
memcpy(copy->to_ptr, copy->from_ptr, copy->from_length);
445
cs->cset->fill(cs, (char*) copy->to_ptr+copy->from_length,
446
copy->to_length-copy->from_length, '\0');
451
static void do_expand_string(CopyField *copy)
453
const charset_info_st * const cs= copy->from_field->charset();
454
memcpy(copy->to_ptr,copy->from_ptr,copy->from_length);
455
cs->cset->fill(cs, (char*) copy->to_ptr+copy->from_length,
456
copy->to_length-copy->from_length, ' ');
460
static void do_varstring1(CopyField *copy)
462
uint32_t length= (uint32_t) *(unsigned char*) copy->from_ptr;
446
463
if (length > copy->to_length- 1)
448
length=copy->to_length - 1;
449
if (copy->from_field->table->in_use->count_cuted_fields)
465
length= copy->to_length - 1;
466
if (copy->from_field->getTable()->in_use->count_cuted_fields)
450
468
copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
451
469
ER_WARN_DATA_TRUNCATED, 1);
453
472
*(unsigned char*) copy->to_ptr= (unsigned char) length;
454
473
memcpy(copy->to_ptr+1, copy->from_ptr + 1, length);
458
static void do_varstring1_mb(Copy_field *copy)
477
static void do_varstring1_mb(CopyField *copy)
460
479
int well_formed_error;
461
const CHARSET_INFO * const cs= copy->from_field->charset();
462
uint32_t from_length= (uint) *(unsigned char*) copy->from_ptr;
480
const charset_info_st * const cs= copy->from_field->charset();
481
uint32_t from_length= (uint32_t) *(unsigned char*) copy->from_ptr;
463
482
const unsigned char *from_ptr= copy->from_ptr + 1;
464
483
uint32_t to_char_length= (copy->to_length - 1) / cs->mbmaxlen;
465
484
uint32_t length= cs->cset->well_formed_len(cs, (char*) from_ptr,
468
487
if (length < from_length)
470
489
if (current_session->count_cuted_fields)
471
491
copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
472
492
ER_WARN_DATA_TRUNCATED, 1);
474
495
*copy->to_ptr= (unsigned char) length;
475
496
memcpy(copy->to_ptr + 1, from_ptr, length);
479
static void do_varstring2(Copy_field *copy)
500
static void do_varstring2(CopyField *copy)
481
uint32_t length=uint2korr(copy->from_ptr);
502
uint32_t length= uint2korr(copy->from_ptr);
482
503
if (length > copy->to_length- HA_KEY_BLOB_LENGTH)
484
505
length=copy->to_length-HA_KEY_BLOB_LENGTH;
485
if (copy->from_field->table->in_use->count_cuted_fields)
506
if (copy->from_field->getTable()->in_use->count_cuted_fields)
486
508
copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
487
509
ER_WARN_DATA_TRUNCATED, 1);
489
512
int2store(copy->to_ptr,length);
490
513
memcpy(copy->to_ptr+HA_KEY_BLOB_LENGTH, copy->from_ptr + HA_KEY_BLOB_LENGTH,
495
static void do_varstring2_mb(Copy_field *copy)
518
static void do_varstring2_mb(CopyField *copy)
497
520
int well_formed_error;
498
const CHARSET_INFO * const cs= copy->from_field->charset();
521
const charset_info_st * const cs= copy->from_field->charset();
499
522
uint32_t char_length= (copy->to_length - HA_KEY_BLOB_LENGTH) / cs->mbmaxlen;
500
523
uint32_t from_length= uint2korr(copy->from_ptr);
501
524
const unsigned char *from_beg= copy->from_ptr + HA_KEY_BLOB_LENGTH;
502
525
uint32_t length= cs->cset->well_formed_len(cs, (char*) from_beg,
503
(char*) from_beg + from_length,
504
char_length, &well_formed_error);
526
(char*) from_beg + from_length,
527
char_length, &well_formed_error);
505
528
if (length < from_length)
507
530
if (current_session->count_cuted_fields)
508
532
copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
509
533
ER_WARN_DATA_TRUNCATED, 1);
511
536
int2store(copy->to_ptr, length);
512
537
memcpy(copy->to_ptr+HA_KEY_BLOB_LENGTH, from_beg, length);
516
541
/***************************************************************************
517
** The different functions that fills in a Copy_field class
542
** The different functions that fills in a CopyField class
518
543
***************************************************************************/
525
550
The 'to' buffer should have a size of field->pack_length()+1
528
void Copy_field::set(unsigned char *to,Field *from)
553
void CopyField::set(unsigned char *to,Field *from)
532
from_length=from->pack_length();
557
from_length= from->pack_length();
533
558
if (from->maybe_null())
535
from_null_ptr=from->null_ptr;
536
from_bit= from->null_bit;
537
to_ptr[0]= 1; // Null as default value
538
to_null_ptr= (unsigned char*) to_ptr++;
540
if (from->table->maybe_null)
560
from_null_ptr= from->null_ptr;
561
from_bit= from->null_bit;
562
to_ptr[0]= 1; // Null as default value
563
to_null_ptr= (unsigned char*) to_ptr++;
565
if (from->getTable()->maybe_null)
542
null_row= &from->table->null_row;
543
do_copy= do_outer_field_to_null_str;
567
null_row= &from->getTable()->null_row;
568
do_copy= do_outer_field_to_null_str;
546
do_copy= do_field_to_null_str;
571
do_copy= do_field_to_null_str;
550
to_null_ptr= 0; // For easy debugging
551
do_copy= do_field_eq;
575
to_null_ptr= 0; // For easy debugging
576
do_copy= do_field_eq;
559
584
If 'save\ is set to true and the 'from' is a blob field, do_copy is set to
560
585
do_save_blob rather than do_conv_blob. The only differences between them
563
- do_save_blob allocates and uses an intermediate buffer before calling
564
Field_blob::store. Is this in order to trigger the call to
588
- do_save_blob allocates and uses an intermediate buffer before calling
589
Field_blob::store. Is this in order to trigger the call to
565
590
well_formed_copy_nchars, by changing the pointer copy->tmp.ptr()?
566
591
That call will take place anyway in all known cases.
568
- The above causes a truncation to MAX_FIELD_WIDTH. Is this the intended
593
- The above causes a truncation to MAX_FIELD_WIDTH. Is this the intended
569
594
effect? Truncation is handled by well_formed_copy_nchars anyway.
571
void Copy_field::set(Field *to,Field *from,bool save)
596
void CopyField::set(Field *to,Field *from,bool save)
573
598
if (to->type() == DRIZZLE_TYPE_NULL)
575
to_null_ptr=0; // For easy debugging
600
to_null_ptr= 0; // For easy debugging
583
from_length=from->pack_length();
585
to_length=to_field->pack_length();
608
from_length= from->pack_length();
610
to_length= to_field->pack_length();
587
612
// set up null handling
588
from_null_ptr=to_null_ptr=0;
613
from_null_ptr= to_null_ptr= 0;
589
614
if (from->maybe_null())
591
from_null_ptr= from->null_ptr;
592
from_bit= from->null_bit;
616
from_null_ptr= from->null_ptr;
617
from_bit= from->null_bit;
593
618
if (to_field->real_maybe_null())
595
to_null_ptr= to->null_ptr;
596
to_bit= to->null_bit;
620
to_null_ptr= to->null_ptr;
621
to_bit= to->null_bit;
597
622
if (from_null_ptr)
598
do_copy= do_copy_null;
624
do_copy= do_copy_null;
601
null_row= &from->table->null_row;
602
do_copy= do_outer_field_null;
628
null_row= &from->getTable()->null_row;
629
do_copy= do_outer_field_null;
607
if (to_field->type() == DRIZZLE_TYPE_TIMESTAMP)
634
if (to_field->is_timestamp())
608
636
do_copy= do_copy_timestamp; // Automatic timestamp
609
else if (to_field == to_field->table->next_number_field)
638
else if (to_field == to_field->getTable()->next_number_field)
610
640
do_copy= do_copy_next_number;
612
644
do_copy= do_copy_not_null;
615
648
else if (to_field->real_maybe_null())
617
to_null_ptr= to->null_ptr;
618
to_bit= to->null_bit;
650
to_null_ptr= to->null_ptr;
651
to_bit= to->null_bit;
619
652
do_copy= do_copy_maybe_null;
624
657
if ((to->flags & BLOB_FLAG) && save)
625
658
do_copy2= do_save_blob;
627
660
do_copy2= get_copy_func(to,from);
628
if (!do_copy) // Not null
661
if (!do_copy) // Not null
633
Copy_field::Copy_func *
634
Copy_field::get_copy_func(Field *to,Field *from)
666
CopyField::Copy_func *
667
CopyField::get_copy_func(Field *to,Field *from)
636
bool compatible_db_low_byte_first= (to->table->s->db_low_byte_first ==
637
from->table->s->db_low_byte_first);
669
bool compatible_db_low_byte_first= (to->getTable()->getShare()->db_low_byte_first ==
670
from->getTable()->getShare()->db_low_byte_first);
638
671
if (to->flags & BLOB_FLAG)
640
673
if (!(from->flags & BLOB_FLAG) || from->charset() != to->charset())
681
721
else if (to->charset() != from->charset())
682
return do_field_string;
722
return do_field_string;
683
723
else if (to->real_type() == DRIZZLE_TYPE_VARCHAR)
685
if (((Field_varstring*) to)->length_bytes !=
686
((Field_varstring*) from)->length_bytes)
687
return do_field_string;
725
/* Field_blob is not part of the Field_varstring hierarchy,
726
and casting to varstring for calling pack_length_no_ptr()
727
is always incorrect. Previously the below comparison has
728
always evaluated to false as pack_length_no_ptr() for BLOB
729
will return 4 and varstring can only be <= 2.
730
If your brain slightly bleeds as to why this worked for
731
so many years, you are in no way alone.
733
if (from->flags & BLOB_FLAG)
734
return do_field_string;
736
if ((static_cast<Field_varstring*>(to))->pack_length_no_ptr() !=
737
(static_cast<Field_varstring*>(from))->pack_length_no_ptr())
739
return do_field_string;
688
742
if (to_length != from_length)
689
return (((Field_varstring*) to)->length_bytes == 1 ?
744
return (((Field_varstring*) to)->pack_length_no_ptr() == 1 ?
690
745
(from->charset()->mbmaxlen == 1 ? do_varstring1 :
692
747
(from->charset()->mbmaxlen == 1 ? do_varstring2 :
695
751
else if (to_length < from_length)
696
return (from->charset()->mbmaxlen == 1 ?
753
return (from->charset()->mbmaxlen == 1 ?
697
754
do_cut_string : do_cut_string_complex);
698
756
else if (to_length > from_length)
700
758
if (to->charset() == &my_charset_bin)
743
804
int field_conv(Field *to,Field *from)
745
806
if (to->real_type() == from->real_type() &&
746
!(to->type() == DRIZZLE_TYPE_BLOB && to->table->copy_blobs))
807
!(to->type() == DRIZZLE_TYPE_BLOB && to->getTable()->copy_blobs))
748
809
/* Please god, will someone rewrite this to be readable :( */
749
if (to->pack_length() == from->pack_length() &&
750
!(to->flags & UNSIGNED_FLAG && !(from->flags & UNSIGNED_FLAG)) &&
751
to->real_type() != DRIZZLE_TYPE_ENUM &&
752
(to->real_type() != DRIZZLE_TYPE_NEWDECIMAL || (to->field_length == from->field_length && (((Field_num*)to)->dec == ((Field_num*)from)->dec))) &&
810
if (to->pack_length() == from->pack_length() &&
811
!(to->flags & UNSIGNED_FLAG && !(from->flags & UNSIGNED_FLAG)) &&
812
to->real_type() != DRIZZLE_TYPE_ENUM &&
813
(to->real_type() != DRIZZLE_TYPE_DECIMAL || (to->field_length == from->field_length && (((Field_num*)to)->dec == ((Field_num*)from)->dec))) &&
753
814
from->charset() == to->charset() &&
754
to->table->s->db_low_byte_first == from->table->s->db_low_byte_first &&
755
(!(to->table->in_use->variables.sql_mode & (MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) || (to->type() != DRIZZLE_TYPE_DATE && to->type() != DRIZZLE_TYPE_DATETIME)) &&
756
(from->real_type() != DRIZZLE_TYPE_VARCHAR || ((Field_varstring*)from)->length_bytes == ((Field_varstring*)to)->length_bytes))
815
to->getTable()->getShare()->db_low_byte_first == from->getTable()->getShare()->db_low_byte_first &&
816
(!(to->getTable()->in_use->variables.sql_mode & (MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) || (to->type() != DRIZZLE_TYPE_DATE && to->type() != DRIZZLE_TYPE_DATETIME)) &&
817
(from->real_type() != DRIZZLE_TYPE_VARCHAR || ((Field_varstring*)from)->pack_length_no_ptr() == ((Field_varstring*)to)->pack_length_no_ptr()))
757
818
{ // Identical fields
759
819
/* This may happen if one does 'UPDATE ... SET x=x' */
760
820
if (to->ptr != from->ptr)
762
821
memcpy(to->ptr,from->ptr,to->pack_length());