~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/field.h

  • Committer: Brian Aker
  • Date: 2008-07-22 18:31:32 UTC
  • Revision ID: brian@tangent.org-20080722183132-ne2ntl7g7mdf2eez
uint32 -> uin32_t

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#define DATETIME_DEC                     6
27
27
#define DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE FLOATING_POINT_BUFFER
28
28
 
29
 
const uint32 max_field_size= (uint32) 4294967295U;
 
29
const uint32_t max_field_size= (uint32_t) 4294967295U;
30
30
 
31
31
class Send_field;
32
32
class Protocol;
83
83
  enum imagetype { itRAW, itMBR};
84
84
 
85
85
  utype         unireg_check;
86
 
  uint32        field_length;           // Length of field
87
 
  uint32        flags;
 
86
  uint32_t      field_length;           // Length of field
 
87
  uint32_t      flags;
88
88
  uint16        field_index;            // field number in fields array
89
89
  uchar         null_bit;               // Bit used to test null bit
90
90
  /**
98
98
   */
99
99
  bool is_created_from_null_item;
100
100
 
101
 
  Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
 
101
  Field(uchar *ptr_arg,uint32_t length_arg,uchar *null_ptr_arg,
102
102
        uchar null_bit_arg, utype unireg_check_arg,
103
103
        const char *field_name_arg);
104
104
  virtual ~Field() {}
151
151
    (i.e. it returns the maximum size of the field in a row of the table,
152
152
    which is located in RAM).
153
153
  */
154
 
  virtual uint32 pack_length() const { return (uint32) field_length; }
 
154
  virtual uint32_t pack_length() const { return (uint32_t) field_length; }
155
155
 
156
156
  /*
157
157
    pack_length_in_rec() returns size (in bytes) used to store field data on
158
158
    storage (i.e. it returns the maximal size of the field in a row of the
159
159
    table, which is located on disk).
160
160
  */
161
 
  virtual uint32 pack_length_in_rec() const { return pack_length(); }
 
161
  virtual uint32_t pack_length_in_rec() const { return pack_length(); }
162
162
  virtual int compatible_field_size(uint field_metadata);
163
163
  virtual uint pack_length_from_metadata(uint field_metadata)
164
164
  { return field_metadata; }
182
182
    data_length() return the "real size" of the data in memory.
183
183
    For varstrings, this does _not_ include the length bytes.
184
184
  */
185
 
  virtual uint32 data_length() { return pack_length(); }
 
185
  virtual uint32_t data_length() { return pack_length(); }
186
186
  /*
187
187
    used_length() returns the number of bytes actually used to store the data
188
188
    of the field. So for a varstring it includes both lenght byte(s) and
189
189
    string data, and anything after data_length() bytes are unused.
190
190
  */
191
 
  virtual uint32 used_length() { return pack_length(); }
192
 
  virtual uint32 sort_length() const { return pack_length(); }
 
191
  virtual uint32_t used_length() { return pack_length(); }
 
192
  virtual uint32_t sort_length() const { return pack_length(); }
193
193
 
194
194
  /**
195
195
     Get the maximum size of the data in packed format.
197
197
     @return Maximum data length of the field when packed using the
198
198
     Field::pack() function.
199
199
   */
200
 
  virtual uint32 max_data_length() const {
 
200
  virtual uint32_t max_data_length() const {
201
201
    return pack_length();
202
202
  };
203
203
 
213
213
  virtual bool binary() const { return 1; }
214
214
  virtual bool zero_pack() const { return 1; }
215
215
  virtual enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
216
 
  virtual uint32 key_length() const { return pack_length(); }
 
216
  virtual uint32_t key_length() const { return pack_length(); }
217
217
  virtual enum_field_types type() const =0;
218
218
  virtual enum_field_types real_type() const { return type(); }
219
219
  inline  int cmp(const uchar *str) { return cmp(ptr,str); }
222
222
    { return cmp(a, b); }
223
223
  virtual int cmp(const uchar *,const uchar *)=0;
224
224
  virtual int cmp_binary(const uchar *a,const uchar *b,
225
 
                         uint32  __attribute__((__unused__)) max_length=~0)
 
225
                         uint32_t  __attribute__((__unused__)) max_length=~0)
226
226
  { return memcmp(a,b,pack_length()); }
227
227
  virtual int cmp_offset(uint row_offset)
228
228
  { return cmp(ptr,ptr+row_offset); }
476
476
  }
477
477
 
478
478
  /* maximum possible display length */
479
 
  virtual uint32 max_display_length()= 0;
 
479
  virtual uint32_t max_display_length()= 0;
480
480
 
481
481
  virtual uint is_equal(Create_field *new_field);
482
482
  /* convert decimal to int64_t with overflow check */
483
483
  int64_t convert_decimal2int64_t(const my_decimal *val, bool unsigned_flag,
484
484
                                    int *err);
485
485
  /* The max. number of characters */
486
 
  inline uint32 char_length() const
 
486
  inline uint32_t char_length() const
487
487
  {
488
488
    return field_length / charset()->mbmaxlen;
489
489
  }
545
545
public:
546
546
  const uint8 dec;
547
547
  bool zerofill,unsigned_flag;  // Purify cannot handle bit fields
548
 
  Field_num(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
 
548
  Field_num(uchar *ptr_arg,uint32_t len_arg, uchar *null_ptr_arg,
549
549
            uchar null_bit_arg, utype unireg_check_arg,
550
550
            const char *field_name_arg,
551
551
            uint8 dec_arg, bool zero_arg, bool unsigned_arg);
574
574
  CHARSET_INFO *field_charset;
575
575
  enum Derivation field_derivation;
576
576
public:
577
 
  Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
 
577
  Field_str(uchar *ptr_arg,uint32_t len_arg, uchar *null_ptr_arg,
578
578
            uchar null_bit_arg, utype unireg_check_arg,
579
579
            const char *field_name_arg, CHARSET_INFO *charset);
580
580
  Item_result result_type () const { return STRING_RESULT; }
590
590
  virtual void set_derivation(enum Derivation derivation_arg)
591
591
  { field_derivation= derivation_arg; }
592
592
  bool binary() const { return field_charset == &my_charset_bin; }
593
 
  uint32 max_display_length() { return field_length; }
 
593
  uint32_t max_display_length() { return field_length; }
594
594
  friend class Create_field;
595
595
  my_decimal *val_decimal(my_decimal *);
596
596
  virtual bool str_needs_quotes() { return true; }
597
 
  bool compare_str_field_flags(Create_field *new_field, uint32 flags);
 
597
  bool compare_str_field_flags(Create_field *new_field, uint32_t flags);
598
598
  uint is_equal(Create_field *new_field);
599
599
};
600
600
 
606
606
protected:
607
607
  int report_if_important_data(const char *ptr, const char *end);
608
608
public:
609
 
  Field_longstr(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
 
609
  Field_longstr(uchar *ptr_arg, uint32_t len_arg, uchar *null_ptr_arg,
610
610
                uchar null_bit_arg, utype unireg_check_arg,
611
611
                const char *field_name_arg, CHARSET_INFO *charset_arg)
612
612
    :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
614
614
    {}
615
615
 
616
616
  int store_decimal(const my_decimal *d);
617
 
  uint32 max_data_length() const;
 
617
  uint32_t max_data_length() const;
618
618
};
619
619
 
620
620
/* base class for float and double and decimal (old one) */
622
622
public:
623
623
  my_bool not_fixed;
624
624
 
625
 
  Field_real(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
 
625
  Field_real(uchar *ptr_arg, uint32_t len_arg, uchar *null_ptr_arg,
626
626
             uchar null_bit_arg, utype unireg_check_arg,
627
627
             const char *field_name_arg,
628
628
             uint8 dec_arg, bool zero_arg, bool unsigned_arg)
633
633
  int store_decimal(const my_decimal *);
634
634
  my_decimal *val_decimal(my_decimal *);
635
635
  int truncate(double *nr, double max_length);
636
 
  uint32 max_display_length() { return field_length; }
 
636
  uint32_t max_display_length() { return field_length; }
637
637
  uint size_of() const { return sizeof(*this); }
638
638
  virtual const uchar *unpack(uchar* to, const uchar *from,
639
639
                              uint param_data, bool low_byte_first);
644
644
 
645
645
class Field_tiny :public Field_num {
646
646
public:
647
 
  Field_tiny(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
 
647
  Field_tiny(uchar *ptr_arg, uint32_t len_arg, uchar *null_ptr_arg,
648
648
             uchar null_bit_arg,
649
649
             enum utype unireg_check_arg, const char *field_name_arg,
650
650
             bool zero_arg, bool unsigned_arg)
666
666
  bool send_binary(Protocol *protocol);
667
667
  int cmp(const uchar *,const uchar *);
668
668
  void sort_string(uchar *buff,uint length);
669
 
  uint32 pack_length() const { return 1; }
 
669
  uint32_t pack_length() const { return 1; }
670
670
  void sql_type(String &str) const;
671
 
  uint32 max_display_length() { return 4; }
 
671
  uint32_t max_display_length() { return 4; }
672
672
 
673
673
  virtual uchar *pack(uchar* to, const uchar *from,
674
674
                      uint max_length __attribute__((__unused__)),
693
693
  uint packlength;
694
694
public:
695
695
  TYPELIB *typelib;
696
 
  Field_enum(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
 
696
  Field_enum(uchar *ptr_arg, uint32_t len_arg, uchar *null_ptr_arg,
697
697
             uchar null_bit_arg,
698
698
             enum utype unireg_check_arg, const char *field_name_arg,
699
699
             uint packlength_arg,
718
718
  String *val_str(String*,String *);
719
719
  int cmp(const uchar *,const uchar *);
720
720
  void sort_string(uchar *buff,uint length);
721
 
  uint32 pack_length() const { return (uint32) packlength; }
 
721
  uint32_t pack_length() const { return (uint32_t) packlength; }
722
722
  void store_type(uint64_t value);
723
723
  void sql_type(String &str) const;
724
724
  uint size_of() const { return sizeof(*this); }
760
760
    The value of `length' as set by parser: is the number of characters
761
761
    for most of the types, or of bytes for BLOBs or numeric types.
762
762
  */
763
 
  uint32 char_length;
 
763
  uint32_t char_length;
764
764
  uint  decimals, flags, pack_length, key_length;
765
765
  Field::utype unireg_check;
766
766
  TYPELIB *interval;                    // Which interval to use
787
787
 
788
788
  /* Init for a tmp table field. To be extended if need be. */
789
789
  void init_for_tmp_table(enum_field_types sql_type_arg,
790
 
                          uint32 max_length, uint32 decimals,
 
790
                          uint32_t max_length, uint32_t decimals,
791
791
                          bool maybe_null, bool is_unsigned);
792
792
 
793
793
  bool init(THD *thd, char *field_name, enum_field_types type, char *length,
844
844
};
845
845
 
846
846
 
847
 
Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length,
 
847
Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32_t field_length,
848
848
                  uchar *null_pos, uchar null_bit,
849
849
                  uint pack_flag, enum_field_types field_type,
850
850
                  CHARSET_INFO *cs,
852
852
                  TYPELIB *interval, const char *field_name);
853
853
uint pack_length_to_packflag(uint type);
854
854
enum_field_types get_blob_type_from_length(ulong length);
855
 
uint32 calc_pack_length(enum_field_types type,uint32 length);
 
855
uint32_t calc_pack_length(enum_field_types type,uint32_t length);
856
856
int set_field_to_null(Field *field);
857
857
int set_field_to_null_with_conversions(Field *field, bool no_conversions);
858
858