~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field.cc

  • Committer: Brian Aker
  • Date: 2008-11-12 01:27:19 UTC
  • Revision ID: brian@tangent.org-20081112012719-rz97qt34iii2f73o
Next pass in removing/standardizing replication

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "sql_select.h"
29
29
#include <errno.h>
30
30
#include <drizzled/error.h>
31
 
#include <drizzled/virtual_column_info.h>
32
 
#include <drizzled/field/str.h>
33
 
#include <drizzled/field/longstr.h>
34
 
#include <drizzled/field/num.h>
35
 
#include <drizzled/field/blob.h>
36
 
#include <drizzled/field/enum.h>
37
 
#include <drizzled/field/null.h>
38
 
#include <drizzled/field/date.h>
39
 
#include <drizzled/field/fdecimal.h>
40
 
#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>
49
 
#include <drizzled/field/varstring.h>
50
31
 
51
32
 
52
33
/*****************************************************************************
80
61
    DRIZZLE_TYPE_VARCHAR,
81
62
    //DRIZZLE_TYPE_DATETIME
82
63
    DRIZZLE_TYPE_VARCHAR,
83
 
    //DRIZZLE_TYPE_DATE
 
64
    //DRIZZLE_TYPE_NEWDATE
84
65
    DRIZZLE_TYPE_VARCHAR,
85
66
    //DRIZZLE_TYPE_VARCHAR
86
67
    DRIZZLE_TYPE_VARCHAR,
111
92
    DRIZZLE_TYPE_VARCHAR,
112
93
    //DRIZZLE_TYPE_DATETIME
113
94
    DRIZZLE_TYPE_VARCHAR,
114
 
    //DRIZZLE_TYPE_DATE
 
95
    //DRIZZLE_TYPE_NEWDATE
115
96
    DRIZZLE_TYPE_VARCHAR,
116
97
    //DRIZZLE_TYPE_VARCHAR
117
98
    DRIZZLE_TYPE_VARCHAR,
142
123
    DRIZZLE_TYPE_VARCHAR,
143
124
    //DRIZZLE_TYPE_DATETIME
144
125
    DRIZZLE_TYPE_VARCHAR,
145
 
    //DRIZZLE_TYPE_DATE
 
126
    //DRIZZLE_TYPE_NEWDATE
146
127
    DRIZZLE_TYPE_VARCHAR,
147
128
    //DRIZZLE_TYPE_VARCHAR
148
129
    DRIZZLE_TYPE_VARCHAR,
173
154
    DRIZZLE_TYPE_TIME,
174
155
    //DRIZZLE_TYPE_DATETIME
175
156
    DRIZZLE_TYPE_DATETIME,
176
 
    //DRIZZLE_TYPE_DATE
177
 
    DRIZZLE_TYPE_DATE,
 
157
    //DRIZZLE_TYPE_NEWDATE
 
158
    DRIZZLE_TYPE_NEWDATE,
178
159
    //DRIZZLE_TYPE_VARCHAR
179
160
    DRIZZLE_TYPE_VARCHAR,
180
161
    //DRIZZLE_TYPE_VIRTUAL
204
185
    DRIZZLE_TYPE_DATETIME,
205
186
    //DRIZZLE_TYPE_DATETIME
206
187
    DRIZZLE_TYPE_DATETIME,
207
 
    //DRIZZLE_TYPE_DATE
208
 
    DRIZZLE_TYPE_DATE,
 
188
    //DRIZZLE_TYPE_NEWDATE
 
189
    DRIZZLE_TYPE_NEWDATE,
209
190
    //DRIZZLE_TYPE_VARCHAR
210
191
    DRIZZLE_TYPE_VARCHAR,
211
192
    //DRIZZLE_TYPE_VIRTUAL
235
216
    DRIZZLE_TYPE_VARCHAR,
236
217
    //DRIZZLE_TYPE_DATETIME
237
218
    DRIZZLE_TYPE_VARCHAR,
238
 
    //DRIZZLE_TYPE_DATE
239
 
    DRIZZLE_TYPE_DATE,
 
219
    //DRIZZLE_TYPE_NEWDATE
 
220
    DRIZZLE_TYPE_NEWDATE,
240
221
    //DRIZZLE_TYPE_VARCHAR
241
222
    DRIZZLE_TYPE_VARCHAR,
242
223
    //DRIZZLE_TYPE_VIRTUAL
266
247
    DRIZZLE_TYPE_TIME,
267
248
    //DRIZZLE_TYPE_DATETIME
268
249
    DRIZZLE_TYPE_DATETIME,
269
 
    //DRIZZLE_TYPE_DATE
270
 
    DRIZZLE_TYPE_DATE,
 
250
    //DRIZZLE_TYPE_NEWDATE
 
251
    DRIZZLE_TYPE_NEWDATE,
271
252
    //DRIZZLE_TYPE_VARCHAR
272
253
    DRIZZLE_TYPE_VARCHAR,
273
254
    //DRIZZLE_TYPE_VIRTUAL
297
278
    DRIZZLE_TYPE_DATETIME,
298
279
    //DRIZZLE_TYPE_DATETIME
299
280
    DRIZZLE_TYPE_DATETIME,
300
 
    //DRIZZLE_TYPE_DATE
301
 
    DRIZZLE_TYPE_DATE,
 
281
    //DRIZZLE_TYPE_NEWDATE
 
282
    DRIZZLE_TYPE_NEWDATE,
302
283
    //DRIZZLE_TYPE_VARCHAR
303
284
    DRIZZLE_TYPE_VARCHAR,
304
285
    //DRIZZLE_TYPE_VIRTUAL
310
291
    //DRIZZLE_TYPE_BLOB
311
292
    DRIZZLE_TYPE_BLOB,
312
293
  },
313
 
  /* DRIZZLE_TYPE_DATE -> */
 
294
  /* DRIZZLE_TYPE_NEWDATE -> */
314
295
  {
315
296
    //DRIZZLE_TYPE_TINY
316
297
    DRIZZLE_TYPE_VARCHAR,
319
300
    //DRIZZLE_TYPE_DOUBLE
320
301
    DRIZZLE_TYPE_VARCHAR,
321
302
    //DRIZZLE_TYPE_NULL
322
 
    DRIZZLE_TYPE_DATE,
 
303
    DRIZZLE_TYPE_NEWDATE,
323
304
    //DRIZZLE_TYPE_TIMESTAMP
324
305
    DRIZZLE_TYPE_DATETIME,
325
306
    //DRIZZLE_TYPE_LONGLONG
328
309
    DRIZZLE_TYPE_DATETIME,
329
310
    //DRIZZLE_TYPE_DATETIME
330
311
    DRIZZLE_TYPE_DATETIME,
331
 
    //DRIZZLE_TYPE_DATE
332
 
    DRIZZLE_TYPE_DATE,
 
312
    //DRIZZLE_TYPE_NEWDATE
 
313
    DRIZZLE_TYPE_NEWDATE,
333
314
    //DRIZZLE_TYPE_VARCHAR
334
315
    DRIZZLE_TYPE_VARCHAR,
335
316
    //DRIZZLE_TYPE_VIRTUAL
359
340
    DRIZZLE_TYPE_VARCHAR,
360
341
    //DRIZZLE_TYPE_DATETIME
361
342
    DRIZZLE_TYPE_VARCHAR,
362
 
    //DRIZZLE_TYPE_DATE
 
343
    //DRIZZLE_TYPE_NEWDATE
363
344
    DRIZZLE_TYPE_VARCHAR,
364
345
    //DRIZZLE_TYPE_VARCHAR
365
346
    DRIZZLE_TYPE_VARCHAR,
390
371
    DRIZZLE_TYPE_VIRTUAL,
391
372
    //DRIZZLE_TYPE_DATETIME
392
373
    DRIZZLE_TYPE_VIRTUAL,
393
 
    //DRIZZLE_TYPE_DATE
 
374
    //DRIZZLE_TYPE_NEWDATE
394
375
    DRIZZLE_TYPE_VIRTUAL,
395
376
    //DRIZZLE_TYPE_VARCHAR
396
377
    DRIZZLE_TYPE_VIRTUAL,
421
402
    DRIZZLE_TYPE_VARCHAR,
422
403
    //DRIZZLE_TYPE_DATETIME
423
404
    DRIZZLE_TYPE_VARCHAR,
424
 
    //DRIZZLE_TYPE_DATE
 
405
    //DRIZZLE_TYPE_NEWDATE
425
406
    DRIZZLE_TYPE_VARCHAR,
426
407
    //DRIZZLE_TYPE_VARCHAR
427
408
    DRIZZLE_TYPE_VARCHAR,
452
433
    DRIZZLE_TYPE_VARCHAR,
453
434
    //DRIZZLE_TYPE_DATETIME
454
435
    DRIZZLE_TYPE_VARCHAR,
455
 
    //DRIZZLE_TYPE_DATE
 
436
    //DRIZZLE_TYPE_NEWDATE
456
437
    DRIZZLE_TYPE_VARCHAR,
457
438
    //DRIZZLE_TYPE_VARCHAR
458
439
    DRIZZLE_TYPE_VARCHAR,
483
464
    DRIZZLE_TYPE_BLOB,
484
465
    //DRIZZLE_TYPE_DATETIME
485
466
    DRIZZLE_TYPE_BLOB,
486
 
    //DRIZZLE_TYPE_DATE
 
467
    //DRIZZLE_TYPE_NEWDATE
487
468
    DRIZZLE_TYPE_BLOB,
488
469
    //DRIZZLE_TYPE_VARCHAR
489
470
    DRIZZLE_TYPE_BLOB,
535
516
  STRING_RESULT,
536
517
  //DRIZZLE_TYPE_DATETIME
537
518
  STRING_RESULT,
538
 
  //DRIZZLE_TYPE_DATE
 
519
  //DRIZZLE_TYPE_NEWDATE
539
520
  STRING_RESULT,
540
521
  //DRIZZLE_TYPE_VARCHAR
541
522
  STRING_RESULT,
574
555
}
575
556
 
576
557
 
 
558
/**
 
559
  Detect Item_result by given field type of UNION merge result.
 
560
 
 
561
  @param field_type  given field type
 
562
 
 
563
  @return
 
564
    Item_result (type of internal MySQL expression result)
 
565
*/
 
566
 
577
567
Item_result Field::result_merge_type(enum_field_types field_type)
578
568
{
579
569
  assert(field_type <= DRIZZLE_TYPE_MAX);
580
570
  return field_types_result_type[field_type];
581
571
}
582
572
 
583
 
 
584
 
bool Field::eq(Field *field)
585
 
{
586
 
  return (ptr == field->ptr && null_ptr == field->null_ptr &&
587
 
          null_bit == field->null_bit);
588
 
}
589
 
 
590
 
 
591
 
uint32_t Field::pack_length() const
592
 
{
593
 
  return field_length;
594
 
}
595
 
 
596
 
 
597
 
uint32_t Field::pack_length_in_rec() const
598
 
{
599
 
  return pack_length();
600
 
}
601
 
 
602
 
 
603
 
uint32_t Field::pack_length_from_metadata(uint32_t field_metadata)
604
 
{
605
 
  return field_metadata;
606
 
}
607
 
 
608
 
 
609
 
uint32_t Field::row_pack_length()
610
 
{
611
 
  return 0;
612
 
}
613
 
 
614
 
 
615
 
int Field::save_field_metadata(unsigned char *first_byte)
616
 
{
617
 
  return do_save_field_metadata(first_byte);
618
 
}
619
 
 
620
 
 
621
 
uint32_t Field::data_length()
622
 
{
623
 
  return pack_length();
624
 
}
625
 
 
626
 
 
627
 
uint32_t Field::used_length()
628
 
{
629
 
  return pack_length();
630
 
}
631
 
 
632
 
 
633
 
uint32_t Field::sort_length() const
634
 
{
635
 
  return pack_length();
636
 
}
637
 
 
638
 
 
639
 
uint32_t Field::max_data_length() const
640
 
{
641
 
  return pack_length();
642
 
}
643
 
 
644
 
 
645
 
int Field::reset(void)
646
 
{
647
 
  memset(ptr, 0, pack_length());
648
 
  return 0;
649
 
}
650
 
 
651
 
 
652
 
void Field::reset_fields()
653
 
{}
654
 
 
655
 
 
656
 
void Field::set_default()
657
 
{
658
 
  my_ptrdiff_t l_offset= (my_ptrdiff_t) (table->getDefaultValues() - table->record[0]);
659
 
  memcpy(ptr, ptr + l_offset, pack_length());
660
 
  if (null_ptr)
661
 
    *null_ptr= ((*null_ptr & (unsigned char) ~null_bit) | (null_ptr[l_offset] & null_bit));
662
 
}
663
 
 
664
 
 
665
 
bool Field::binary() const
666
 
{
667
 
  return 1;
668
 
}
669
 
 
670
 
 
671
 
bool Field::zero_pack() const
672
 
{
673
 
  return 1;
674
 
}
675
 
 
676
 
 
677
 
enum ha_base_keytype Field::key_type() const
678
 
{
679
 
  return HA_KEYTYPE_BINARY;
680
 
}
681
 
 
682
 
 
683
 
uint32_t Field::key_length() const
684
 
{
685
 
  return pack_length();
686
 
}
687
 
 
688
 
 
689
 
enum_field_types Field::real_type() const
690
 
{
691
 
  return type();
692
 
}
693
 
 
694
 
 
695
 
int Field::cmp_max(const unsigned char *a, const unsigned char *b, uint32_t)
696
 
{
697
 
  return cmp(a, b);
698
 
}
699
 
 
700
 
 
701
 
int Field::cmp_binary(const unsigned char *a,const unsigned char *b, uint32_t)
702
 
{
703
 
  return memcmp(a,b,pack_length());
704
 
}
705
 
 
706
 
 
707
 
int Field::cmp_offset(uint32_t row_offset)
708
 
{
709
 
  return cmp(ptr,ptr+row_offset);
710
 
}
711
 
 
712
 
 
713
 
int Field::cmp_binary_offset(uint32_t row_offset)
714
 
{
715
 
  return cmp_binary(ptr, ptr+row_offset);
716
 
}
717
 
 
718
 
 
719
 
int Field::key_cmp(const unsigned char *a,const unsigned char *b)
720
 
{
721
 
  return cmp(a, b);
722
 
}
723
 
 
724
 
 
725
 
int Field::key_cmp(const unsigned char *str, uint32_t)
726
 
{
727
 
  return cmp(ptr,str);
728
 
}
729
 
 
730
 
 
731
 
uint32_t Field::decimals() const
732
 
{
733
 
  return 0;
734
 
}
735
 
 
736
 
 
737
 
bool Field::is_null(my_ptrdiff_t row_offset)
738
 
{
739
 
  return null_ptr ?
740
 
    (null_ptr[row_offset] & null_bit ? true : false) :
741
 
    table->null_row;
742
 
}
743
 
 
744
 
 
745
 
bool Field::is_real_null(my_ptrdiff_t row_offset)
746
 
{
747
 
  return null_ptr ? (null_ptr[row_offset] & null_bit ? true : false) : false;
748
 
}
749
 
 
750
 
 
751
 
bool Field::is_null_in_record(const unsigned char *record)
752
 
{
753
 
  if (!null_ptr)
754
 
    return false;
755
 
  return test(record[(uint32_t) (null_ptr -table->record[0])] &
756
 
              null_bit);
757
 
}
758
 
 
759
 
 
760
 
bool Field::is_null_in_record_with_offset(my_ptrdiff_t offset)
761
 
{
762
 
  if (!null_ptr)
763
 
    return false;
764
 
  return test(null_ptr[offset] & null_bit);
765
 
}
766
 
 
767
 
 
768
 
void Field::set_null(my_ptrdiff_t row_offset)
769
 
{
770
 
  if (null_ptr)
771
 
    null_ptr[row_offset]|= null_bit;
772
 
}
773
 
 
774
 
 
775
 
void Field::set_notnull(my_ptrdiff_t row_offset)
776
 
{
777
 
  if (null_ptr)
778
 
    null_ptr[row_offset]&= (unsigned char) ~null_bit;
779
 
}
780
 
 
781
 
 
782
 
bool Field::maybe_null(void)
783
 
{
784
 
  return null_ptr != 0 || table->maybe_null;
785
 
}
786
 
 
787
 
 
788
 
bool Field::real_maybe_null(void)
789
 
{
790
 
  return null_ptr != 0;
791
 
}
792
 
 
793
 
 
794
 
size_t Field::last_null_byte() const
795
 
{
796
 
  size_t bytes= do_last_null_byte();
797
 
  assert(bytes <= table->getNullBytes());
798
 
  return bytes;
799
 
}
800
 
 
801
 
 
802
573
/*****************************************************************************
803
574
  Static help functions
804
575
*****************************************************************************/
805
576
 
 
577
 
 
578
/**
 
579
  Check whether a field type can be partially indexed by a key.
 
580
 
 
581
  This is a static method, rather than a virtual function, because we need
 
582
  to check the type of a non-Field in mysql_alter_table().
 
583
 
 
584
  @param type  field type
 
585
 
 
586
  @retval
 
587
    true  Type can have a prefixed key
 
588
  @retval
 
589
    false Type can not have a prefixed key
 
590
*/
 
591
 
806
592
bool Field::type_can_have_key_part(enum enum_field_types type)
807
593
{
808
594
  switch (type) {
843
629
}
844
630
 
845
631
 
846
 
void Field::init(Table *table_arg)
847
 
{
848
 
  orig_table= table= table_arg;
849
 
  table_name= &table_arg->alias;
850
 
}
851
 
 
852
 
 
853
632
#ifdef NOT_USED
854
633
static bool test_if_real(const char *str,int length, const CHARSET_INFO * const cs)
855
634
{
930
709
 
931
710
/// This is used as a table name when the table structure is not set up
932
711
Field::Field(unsigned char *ptr_arg,uint32_t length_arg,unsigned char *null_ptr_arg,
933
 
             unsigned char null_bit_arg,
934
 
             utype unireg_check_arg, const char *field_name_arg)
 
712
             unsigned char null_bit_arg,
 
713
             utype unireg_check_arg, const char *field_name_arg)
935
714
  :ptr(ptr_arg), null_ptr(null_ptr_arg),
936
715
   table(0), orig_table(0), table_name(0),
937
716
   field_name(field_name_arg),
938
717
   key_start(0), part_of_key(0), part_of_key_not_clustered(0),
939
718
   part_of_sortkey(0), unireg_check(unireg_check_arg),
940
 
   field_length(length_arg), null_bit(null_bit_arg),
 
719
   field_length(length_arg), null_bit(null_bit_arg), 
941
720
   is_created_from_null_item(false),
942
721
   vcol_info(NULL), is_stored(true)
943
722
{
977
756
  memcpy(ptr,ptr+row_offset,pack_length());
978
757
  if (null_ptr)
979
758
  {
980
 
    *null_ptr= (unsigned char) ((null_ptr[0] &
981
 
                                 (unsigned char) ~(uint32_t) null_bit) |
982
 
                                (null_ptr[row_offset] &
983
 
                                 (unsigned char) null_bit));
 
759
    *null_ptr= (unsigned char) ((null_ptr[0] & (unsigned char) ~(uint32_t) null_bit) | (null_ptr[row_offset] & (unsigned char) null_bit));
984
760
  }
985
761
}
986
762
 
998
774
   Check to see if field size is compatible with destination.
999
775
 
1000
776
   This method is used in row-based replication to verify that the slave's
1001
 
   field size is less than or equal to the master's field size. The
 
777
   field size is less than or equal to the master's field size. The 
1002
778
   encoded field metadata (from the master or source) is decoded and compared
1003
 
   to the size of this field (the slave or destination).
 
779
   to the size of this field (the slave or destination). 
1004
780
 
1005
781
   @param   field_metadata   Encoded size in field metadata
1006
782
 
1015
791
}
1016
792
 
1017
793
 
1018
 
int Field::store(const char *to, uint32_t length,
1019
 
                 const CHARSET_INFO * const cs,
 
794
int Field::store(const char *to, uint32_t length, const CHARSET_INFO * const cs,
1020
795
                 enum_check_fields check_level)
1021
796
{
1022
797
  int res;
1075
850
  return to+length;
1076
851
}
1077
852
 
1078
 
 
1079
 
unsigned char *Field::pack(unsigned char *to, const unsigned char *from)
1080
 
{
1081
 
  unsigned char *result= this->pack(to, from, UINT32_MAX,
1082
 
                                    table->s->db_low_byte_first);
1083
 
  return(result);
1084
 
}
1085
 
 
1086
 
 
1087
853
/**
1088
854
   Unpack a field from row data.
1089
855
 
1146
912
}
1147
913
 
1148
914
 
1149
 
const unsigned char *Field::unpack(unsigned char* to,
1150
 
                                   const unsigned char *from)
1151
 
{
1152
 
  const unsigned char *result= unpack(to, from, 0U,
1153
 
                                      table->s->db_low_byte_first);
1154
 
  return(result);
1155
 
}
1156
 
 
1157
 
 
1158
 
uint32_t Field::packed_col_length(const unsigned char *, uint32_t length)
1159
 
{
1160
 
  return length;
1161
 
}
1162
 
 
1163
 
 
1164
 
int Field::pack_cmp(const unsigned char *a, const unsigned char *b,
1165
 
                    uint32_t, bool)
1166
 
{
1167
 
  return cmp(a,b);
1168
 
}
1169
 
 
1170
 
 
1171
 
int Field::pack_cmp(const unsigned char *b, uint32_t, bool)
1172
 
{
1173
 
  return cmp(ptr,b);
1174
 
}
1175
 
 
1176
 
 
1177
915
my_decimal *Field::val_decimal(my_decimal *)
1178
916
{
1179
917
  /* This never have to be called */
1347
1085
}
1348
1086
 
1349
1087
 
 
1088
/*
 
1089
  Report "not well formed" or "cannot convert" error
 
1090
  after storing a character string info a field.
 
1091
 
 
1092
  SYNOPSIS
 
1093
    check_string_copy_error()
 
1094
    field                    - Field
 
1095
    well_formed_error_pos    - where not well formed data was first met
 
1096
    cannot_convert_error_pos - where a not-convertable character was first met
 
1097
    end                      - end of the string
 
1098
    cs                       - character set of the string
 
1099
 
 
1100
  NOTES
 
1101
    As of version 5.0 both cases return the same error:
 
1102
 
 
1103
      "Invalid string value: 'xxx' for column 't' at row 1"
 
1104
 
 
1105
  Future versions will possibly introduce a new error message:
 
1106
 
 
1107
      "Cannot convert character string: 'xxx' for column 't' at row 1"
 
1108
 
 
1109
  RETURN
 
1110
    false - If errors didn't happen
 
1111
    true  - If an error happened
 
1112
*/
 
1113
 
 
1114
bool
 
1115
check_string_copy_error(Field_str *field,
 
1116
                        const char *well_formed_error_pos,
 
1117
                        const char *cannot_convert_error_pos,
 
1118
                        const char *end,
 
1119
                        const CHARSET_INFO * const cs)
 
1120
{
 
1121
  const char *pos, *end_orig;
 
1122
  char tmp[64], *t;
 
1123
  
 
1124
  if (!(pos= well_formed_error_pos) &&
 
1125
      !(pos= cannot_convert_error_pos))
 
1126
    return false;
 
1127
 
 
1128
  end_orig= end;
 
1129
  set_if_smaller(end, pos + 6);
 
1130
 
 
1131
  for (t= tmp; pos < end; pos++)
 
1132
  {
 
1133
    /*
 
1134
      If the source string is ASCII compatible (mbminlen==1)
 
1135
      and the source character is in ASCII printable range (0x20..0x7F),
 
1136
      then display the character as is.
 
1137
      
 
1138
      Otherwise, if the source string is not ASCII compatible (e.g. UCS2),
 
1139
      or the source character is not in the printable range,
 
1140
      then print the character using HEX notation.
 
1141
    */
 
1142
    if (((unsigned char) *pos) >= 0x20 &&
 
1143
        ((unsigned char) *pos) <= 0x7F &&
 
1144
        cs->mbminlen == 1)
 
1145
    {
 
1146
      *t++= *pos;
 
1147
    }
 
1148
    else
 
1149
    {
 
1150
      *t++= '\\';
 
1151
      *t++= 'x';
 
1152
      *t++= _dig_vec_upper[((unsigned char) *pos) >> 4];
 
1153
      *t++= _dig_vec_upper[((unsigned char) *pos) & 15];
 
1154
    }
 
1155
  }
 
1156
  if (end_orig > end)
 
1157
  {
 
1158
    *t++= '.';
 
1159
    *t++= '.';
 
1160
    *t++= '.';
 
1161
  }
 
1162
  *t= '\0';
 
1163
  push_warning_printf(field->table->in_use, 
 
1164
                      field->table->in_use->abort_on_warning ?
 
1165
                      DRIZZLE_ERROR::WARN_LEVEL_ERROR :
 
1166
                      DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
1167
                      ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, 
 
1168
                      ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
 
1169
                      "string", tmp, field->field_name,
 
1170
                      (uint32_t) field->table->in_use->row_count);
 
1171
  return true;
 
1172
}
 
1173
 
1350
1174
uint32_t Field::is_equal(Create_field *new_field)
1351
1175
{
1352
1176
  return (new_field->sql_type == real_type());
1690
1514
                                              Field::NONE));
1691
1515
    }
1692
1516
    break;
1693
 
  case DRIZZLE_TYPE_DATE:
 
1517
  case DRIZZLE_TYPE_NEWDATE:
1694
1518
    length= 10;
1695
1519
    break;
1696
1520
  case DRIZZLE_TYPE_TIME:
1758
1582
  switch (type) {
1759
1583
  case DRIZZLE_TYPE_VARCHAR:     return (length + (length < 256 ? 1: 2));
1760
1584
  case DRIZZLE_TYPE_TINY        : return 1;
1761
 
  case DRIZZLE_TYPE_DATE:
 
1585
  case DRIZZLE_TYPE_NEWDATE:
1762
1586
  case DRIZZLE_TYPE_TIME:   return 3;
1763
1587
  case DRIZZLE_TYPE_TIMESTAMP:
1764
1588
  case DRIZZLE_TYPE_LONG        : return 4;
1809
1633
  }
1810
1634
 
1811
1635
  switch (field_type) {
1812
 
  case DRIZZLE_TYPE_DATE:
 
1636
  case DRIZZLE_TYPE_NEWDATE:
1813
1637
  case DRIZZLE_TYPE_TIME:
1814
1638
  case DRIZZLE_TYPE_DATETIME:
1815
1639
  case DRIZZLE_TYPE_TIMESTAMP:
1880
1704
    return new Field_timestamp(ptr,field_length, null_pos, null_bit,
1881
1705
                               unireg_check, field_name, share,
1882
1706
                               field_charset);
1883
 
  case DRIZZLE_TYPE_DATE:
1884
 
    return new Field_date(ptr,null_pos,null_bit,
 
1707
  case DRIZZLE_TYPE_NEWDATE:
 
1708
    return new Field_newdate(ptr,null_pos,null_bit,
1885
1709
                             unireg_check, field_name, field_charset);
1886
1710
  case DRIZZLE_TYPE_TIME:
1887
1711
    return new Field_time(ptr,null_pos,null_bit,
2110
1934
                                 field_name);
2111
1935
  }
2112
1936
}
2113