~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql/field.h

  • Committer: Mark Atwood
  • Date: 2008-07-01 21:25:46 UTC
  • mto: This revision was merged to the branch mainline in revision 45.
  • Revision ID: mark@localhost.localdomain-20080701212546-jzs7ljtwcp2dcmgd
Remove all OpenSSL and all YaSSL code

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
  void operator=(Field &);
50
50
public:
51
51
  static void *operator new(size_t size) {return sql_alloc(size); }
52
 
  static void operator delete(void *ptr_arg __attribute__((__unused__)),
53
 
                              size_t size __attribute__((__unused__)))
54
 
  { TRASH(ptr_arg, size); }
 
52
  static void operator delete(void *ptr_arg, size_t size) { TRASH(ptr_arg, size); }
55
53
 
56
54
  uchar         *ptr;                   // Position to field in record
57
55
  uchar         *null_ptr;              // Byte where null_bit is
215
213
  virtual enum_field_types type() const =0;
216
214
  virtual enum_field_types real_type() const { return type(); }
217
215
  inline  int cmp(const uchar *str) { return cmp(ptr,str); }
218
 
  virtual int cmp_max(const uchar *a, const uchar *b,
219
 
                      uint max_len __attribute__((__unused__)))
 
216
  virtual int cmp_max(const uchar *a, const uchar *b, uint max_len)
220
217
    { return cmp(a, b); }
221
218
  virtual int cmp(const uchar *,const uchar *)=0;
222
 
  virtual int cmp_binary(const uchar *a,const uchar *b,
223
 
                         uint32  __attribute__((__unused__)) max_length=~0)
 
219
  virtual int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0L)
224
220
  { return memcmp(a,b,pack_length()); }
225
221
  virtual int cmp_offset(uint row_offset)
226
222
  { return cmp(ptr,ptr+row_offset); }
228
224
  { return cmp_binary(ptr, ptr+row_offset); };
229
225
  virtual int key_cmp(const uchar *a,const uchar *b)
230
226
  { return cmp(a, b); }
231
 
  virtual int key_cmp(const uchar *str, uint length __attribute__((__unused__)))
 
227
  virtual int key_cmp(const uchar *str, uint length)
232
228
  { return cmp(ptr,str); }
233
229
  virtual uint decimals() const { return 0; }
234
230
  /*
317
313
    if (null_ptr)
318
314
      null_ptr=ADD_TO_PTR(null_ptr,ptr_diff,uchar*);
319
315
  }
320
 
  virtual void get_image(uchar *buff, uint length,
321
 
                         CHARSET_INFO *cs __attribute__((__unused__)))
 
316
  virtual void get_image(uchar *buff, uint length, CHARSET_INFO *cs)
322
317
    { memcpy(buff,ptr,length); }
323
 
  virtual void set_image(const uchar *buff,uint length,
324
 
                         CHARSET_INFO *cs __attribute__((__unused__)))
 
318
  virtual void set_image(const uchar *buff,uint length, CHARSET_INFO *cs)
325
319
    { memcpy(ptr,buff,length); }
326
320
 
327
321
 
351
345
      Number of copied bytes (excluding padded zero bytes -- see above).
352
346
  */
353
347
 
354
 
  virtual uint get_key_image(uchar *buff, uint length,
355
 
                             imagetype type __attribute__((__unused__)))
 
348
  virtual uint get_key_image(uchar *buff, uint length, imagetype type)
356
349
  {
357
350
    get_image(buff, length, &my_charset_bin);
358
351
    return length;
424
417
  {
425
418
    return unpack(to, from, max_length, low_byte_first);
426
419
  }
427
 
  virtual uint packed_col_length(const uchar *to __attribute__((__unused__)),
428
 
                                 uint length)
 
420
  virtual uint packed_col_length(const uchar *to, uint length)
429
421
  { return length;}
430
422
  virtual uint max_packed_col_length(uint max_length)
431
423
  { return max_length;}
432
424
 
433
 
  virtual int pack_cmp(const uchar *a,const uchar *b,
434
 
                       uint key_length_arg __attribute__((__unused__)),
435
 
                       my_bool insert_or_update __attribute__((__unused__)))
 
425
  virtual int pack_cmp(const uchar *a,const uchar *b, uint key_length_arg,
 
426
                       my_bool insert_or_update)
436
427
  { return cmp(a,b); }
437
 
  virtual int pack_cmp(const uchar *b,
438
 
                       uint key_length_arg __attribute__((__unused__)),
439
 
                       my_bool insert_or_update __attribute__((__unused__)))
 
428
  virtual int pack_cmp(const uchar *b, uint key_length_arg,
 
429
                       my_bool insert_or_update)
440
430
  { return cmp(ptr,b); }
441
431
  uint offset(uchar *record)
442
432
  {
449
439
  virtual CHARSET_INFO *charset(void) const { return &my_charset_bin; }
450
440
  virtual CHARSET_INFO *sort_charset(void) const { return charset(); }
451
441
  virtual bool has_charset(void) const { return FALSE; }
452
 
  virtual void set_charset(CHARSET_INFO *charset_arg __attribute__((__unused__)))
453
 
  { }
 
442
  virtual void set_charset(CHARSET_INFO *charset_arg) { }
454
443
  virtual enum Derivation derivation(void) const
455
444
  { return DERIVATION_IMPLICIT; }
456
 
  virtual void set_derivation(enum Derivation derivation_arg __attribute__((__unused__)))
457
 
  { }
 
445
  virtual void set_derivation(enum Derivation derivation_arg) { }
458
446
  bool set_warning(MYSQL_ERROR::enum_warning_level, unsigned int code,
459
447
                   int cuted_increment);
460
448
  void set_datetime_warning(MYSQL_ERROR::enum_warning_level, uint code, 
561
549
 
562
550
   @returns 0 no bytes written.
563
551
*/
564
 
  virtual int do_save_field_metadata(uchar *metadata_ptr __attribute__((__unused__)))
 
552
  virtual int do_save_field_metadata(uchar *metadata_ptr)
565
553
  { return 0; }
566
554
};
567
555
 
785
773
  uint32 max_display_length() { return 4; }
786
774
 
787
775
  virtual uchar *pack(uchar* to, const uchar *from,
788
 
                      uint max_length __attribute__((__unused__)),
789
 
                      bool low_byte_first __attribute__((__unused__)))
 
776
                      uint max_length, bool low_byte_first)
790
777
  {
791
778
    *to= *from;
792
779
    return to + 1;
793
780
  }
794
781
 
795
782
  virtual const uchar *unpack(uchar* to, const uchar *from,
796
 
                              uint param_data __attribute__((__unused__)),
797
 
                              bool low_byte_first __attribute__((__unused__)))
 
783
                              uint param_data, bool low_byte_first)
798
784
  {
799
785
    *to= *from;
800
786
    return from + 1;
836
822
  uint32 max_display_length() { return 6; }
837
823
 
838
824
  virtual uchar *pack(uchar* to, const uchar *from,
839
 
                      uint max_length __attribute__((__unused__)),
840
 
                      bool low_byte_first __attribute__((__unused__)))
 
825
                      uint max_length, bool low_byte_first)
841
826
  {
842
827
    int16 val;
843
828
#ifdef WORDS_BIGENDIAN
857
842
  }
858
843
 
859
844
  virtual const uchar *unpack(uchar* to, const uchar *from,
860
 
                              uint param_data __attribute__((__unused__)),
861
 
                              bool low_byte_first __attribute__((__unused__)))
 
845
                              uint param_data, bool low_byte_first)
862
846
  {
863
847
    int16 val;
864
848
#ifdef WORDS_BIGENDIAN
953
937
  void sql_type(String &str) const;
954
938
  uint32 max_display_length() { return MY_INT32_NUM_DECIMAL_DIGITS; }
955
939
  virtual uchar *pack(uchar* to, const uchar *from,
956
 
                      uint max_length __attribute__((__unused__)),
957
 
                      bool low_byte_first __attribute__((__unused__)))
 
940
                      uint max_length, bool low_byte_first)
958
941
  {
959
942
    int32 val;
960
943
#ifdef WORDS_BIGENDIAN
974
957
  }
975
958
 
976
959
  virtual const uchar *unpack(uchar* to, const uchar *from,
977
 
                              uint param_data __attribute__((__unused__)),
978
 
                              bool low_byte_first __attribute__((__unused__)))
 
960
                              uint param_data, bool low_byte_first)
979
961
  {
980
962
    int32 val;
981
963
#ifdef WORDS_BIGENDIAN
996
978
};
997
979
 
998
980
 
 
981
#ifdef HAVE_LONG_LONG
999
982
class Field_longlong :public Field_num {
1000
983
public:
1001
984
  Field_longlong(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
1035
1018
  bool can_be_compared_as_longlong() const { return TRUE; }
1036
1019
  uint32 max_display_length() { return 20; }
1037
1020
  virtual uchar *pack(uchar* to, const uchar *from,
1038
 
                      uint max_length __attribute__((__unused__)),
1039
 
                      bool low_byte_first __attribute__((__unused__)))
 
1021
                      uint max_length, bool low_byte_first)
1040
1022
  {
1041
1023
    int64 val;
1042
1024
#ifdef WORDS_BIGENDIAN
1056
1038
  }
1057
1039
 
1058
1040
  virtual const uchar *unpack(uchar* to, const uchar *from,
1059
 
                              uint param_data __attribute__((__unused__)),
1060
 
                              bool low_byte_first __attribute__((__unused__)))
 
1041
                              uint param_data, bool low_byte_first)
1061
1042
  {
1062
1043
    int64 val;
1063
1044
#ifdef WORDS_BIGENDIAN
1076
1057
    return from + sizeof(val);
1077
1058
  }
1078
1059
};
 
1060
#endif
 
1061
 
1079
1062
 
1080
1063
class Field_float :public Field_real {
1081
1064
public:
1164
1147
               unireg_check_arg, field_name_arg, cs)
1165
1148
    {}
1166
1149
  enum_field_types type() const { return MYSQL_TYPE_NULL;}
1167
 
  int  store(const char *to __attribute__((__unused__)),
1168
 
             uint length __attribute__((__unused__)),
1169
 
             CHARSET_INFO *cs __attribute__((__unused__)))
1170
 
  { null[0]=1; return 0; }
1171
 
  int store(double nr __attribute__((__unused__)))
1172
 
  { null[0]=1; return 0; }
1173
 
  int store(longlong nr __attribute__((__unused__)),
1174
 
            bool unsigned_val __attribute__((__unused__)))
1175
 
  { null[0]=1; return 0; }
1176
 
  int store_decimal(const my_decimal *d __attribute__((__unused__)))
1177
 
  { null[0]=1; return 0; }
1178
 
  int reset(void)
1179
 
  { return 0; }
1180
 
  double val_real(void)
1181
 
  { return 0.0;}
1182
 
  longlong val_int(void)
1183
 
  { return 0;}
 
1150
  int  store(const char *to, uint length, CHARSET_INFO *cs)
 
1151
  { null[0]=1; return 0; }
 
1152
  int store(double nr)   { null[0]=1; return 0; }
 
1153
  int store(longlong nr, bool unsigned_val) { null[0]=1; return 0; }
 
1154
  int store_decimal(const my_decimal *d)  { null[0]=1; return 0; }
 
1155
  int reset(void)         { return 0; }
 
1156
  double val_real(void)         { return 0.0;}
 
1157
  longlong val_int(void)        { return 0;}
1184
1158
  my_decimal *val_decimal(my_decimal *) { return 0; }
1185
 
  String *val_str(String *value __attribute__((__unused__)),
1186
 
                  String *value2)
 
1159
  String *val_str(String *value,String *value2)
1187
1160
  { value2->length(0); return value2;}
1188
 
  int cmp(const uchar *a __attribute__((__unused__)),
1189
 
          const uchar *b __attribute__((__unused__))) { return 0;}
1190
 
  void sort_string(uchar *buff __attribute__((__unused__)),
1191
 
                   uint length __attribute__((__unused__)))  {}
 
1161
  int cmp(const uchar *a, const uchar *b) { return 0;}
 
1162
  void sort_string(uchar *buff, uint length)  {}
1192
1163
  uint32 pack_length() const { return 0; }
1193
1164
  void sql_type(String &str) const;
1194
1165
  uint size_of() const { return sizeof(*this); }
1398
1369
    :Field_str((uchar*) 0,19, maybe_null_arg ? (uchar*) "": 0,0,
1399
1370
               NONE, field_name_arg, cs) {}
1400
1371
  enum_field_types type() const { return MYSQL_TYPE_DATETIME;}
 
1372
#ifdef HAVE_LONG_LONG
1401
1373
  enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
 
1374
#endif
1402
1375
  enum Item_result cmp_type () const { return INT_RESULT; }
1403
1376
  uint decimals() const { return DATETIME_DEC; }
1404
1377
  int  store(const char *to,uint length,CHARSET_INFO *charset);
1795
1768
  { return (field_metadata & 0x00ff); }
1796
1769
  uint row_pack_length() { return pack_length(); }
1797
1770
  virtual bool zero_pack() const { return 0; }
1798
 
  bool optimize_range(uint idx __attribute__((__unused__)),
1799
 
                      uint part __attribute__((__unused__)))
1800
 
  { return 0; }
 
1771
  bool optimize_range(uint idx, uint part) { return 0; }
1801
1772
  bool eq_def(Field *field);
1802
1773
  bool has_charset(void) const { return TRUE; }
1803
1774
  /* enum and set are sorted as integers */
1874
1845
  virtual bool str_needs_quotes() { return TRUE; }
1875
1846
  my_decimal *val_decimal(my_decimal *);
1876
1847
  int cmp(const uchar *a, const uchar *b)
1877
 
  {
1878
 
    assert(ptr == a);
 
1848
  { 
 
1849
    DBUG_ASSERT(ptr == a);
1879
1850
    return Field_bit::key_cmp(b, bytes_in_rec+test(bit_len));
1880
1851
  }
1881
1852
  int cmp_binary_offset(uint row_offset)
1885
1856
  { return cmp_binary((uchar *) a, (uchar *) b); }
1886
1857
  int key_cmp(const uchar *str, uint length);
1887
1858
  int cmp_offset(uint row_offset);
1888
 
  void get_image(uchar *buff, uint length,
1889
 
                 CHARSET_INFO *cs __attribute__((__unused__)))
1890
 
  { get_key_image(buff, length, itRAW); }
 
1859
  void get_image(uchar *buff, uint length, CHARSET_INFO *cs)
 
1860
  { get_key_image(buff, length, itRAW); }   
1891
1861
  void set_image(const uchar *buff,uint length, CHARSET_INFO *cs)
1892
1862
  { Field_bit::store((char *) buff, length, cs); }
1893
1863
  uint get_key_image(uchar *buff, uint length, imagetype type);