~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/blob.h

  • Committer: Monty Taylor
  • Date: 2009-03-08 23:45:12 UTC
  • mto: (923.2.1 mordred)
  • mto: This revision was merged to the branch mainline in revision 921.
  • Revision ID: mordred@inaugust.com-20090308234512-tqkygxtu1iaig23s
Removed C99 isnan() usage, which allows us to remove the util/math.{cc,h} workarounds. Yay for standards!

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#ifndef DRIZZLE_SERVER_FIELD_BLOB
22
22
#define DRIZZLE_SERVER_FIELD_BLOB
23
23
 
 
24
#include <drizzled/field/longstr.h>
 
25
 
 
26
#include <string>
 
27
 
24
28
class Field_blob :public Field_longstr {
25
29
protected:
26
30
  uint32_t packlength;
27
31
  String value;                         // For temporaries
28
32
public:
 
33
 
 
34
  using Field::store;
 
35
  using Field::cmp;
 
36
  using Field::pack;
 
37
  using Field::unpack;
 
38
  using Field::val_int;
 
39
  using Field::val_str;
 
40
 
 
41
 
29
42
  Field_blob(unsigned char *ptr_arg, unsigned char *null_ptr_arg, unsigned char null_bit_arg,
30
43
             enum utype unireg_check_arg, const char *field_name_arg,
31
44
             TABLE_SHARE *share, uint32_t blob_pack_length, const CHARSET_INFO * const cs);
32
 
  Field_blob(uint32_t len_arg,bool maybe_null_arg, const char *field_name_arg,
 
45
  Field_blob(uint32_t len_arg, bool maybe_null_arg, const char *field_name_arg,
33
46
             const CHARSET_INFO * const cs)
34
47
    :Field_longstr((unsigned char*) 0, len_arg, maybe_null_arg ? (unsigned char*) "": 0, 0,
35
48
                   NONE, field_name_arg, cs),
37
50
  {
38
51
    flags|= BLOB_FLAG;
39
52
  }
40
 
  Field_blob(uint32_t len_arg,bool maybe_null_arg, const char *field_name_arg,
 
53
  Field_blob(uint32_t len_arg, bool maybe_null_arg, const char *field_name_arg,
41
54
             const CHARSET_INFO * const cs, bool set_packlength)
42
55
    :Field_longstr((unsigned char*) 0,len_arg, maybe_null_arg ? (unsigned char*) "": 0, 0,
43
56
                   NONE, field_name_arg, cs)
58
71
  enum_field_types type() const { return DRIZZLE_TYPE_BLOB;}
59
72
  enum ha_base_keytype key_type() const
60
73
    { return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; }
61
 
  int  store(const char *to,uint32_t length, const CHARSET_INFO * const charset);
 
74
  int  store(const char *to,uint32_t length,
 
75
             const CHARSET_INFO * const charset);
62
76
  int  store(double nr);
63
77
  int  store(int64_t nr, bool unsigned_val);
 
78
 
64
79
  double val_real(void);
65
80
  int64_t val_int(void);
66
81
  String *val_str(String*,String *);
74
89
  int key_cmp(const unsigned char *str, uint32_t length);
75
90
  uint32_t key_length() const { return 0; }
76
91
  void sort_string(unsigned char *buff,uint32_t length);
77
 
  uint32_t pack_length() const
78
 
  { return (uint32_t) (packlength+table->s->blob_ptr_size); }
 
92
  uint32_t pack_length() const;
 
93
 
79
94
 
80
95
  /**
81
 
     Return the packed length without the pointer size added. 
 
96
     Return the packed length without the pointer size added.
82
97
 
83
98
     This is used to determine the size of the actual data in the row
84
99
     buffer.
98
113
#ifndef WORDS_BIGENDIAN
99
114
  static
100
115
#endif
101
 
  void store_length(unsigned char *i_ptr, uint32_t i_packlength, uint32_t i_number, bool low_byte_first);
102
 
  void store_length(unsigned char *i_ptr, uint32_t i_packlength, uint32_t i_number)
103
 
  {
104
 
    store_length(i_ptr, i_packlength, i_number, table->s->db_low_byte_first);
105
 
  }
 
116
  void store_length(unsigned char *i_ptr, uint32_t i_packlength,
 
117
                    uint32_t i_number, bool low_byte_first);
 
118
  void store_length(unsigned char *i_ptr, uint32_t i_packlength,
 
119
                    uint32_t i_number);
 
120
 
106
121
  inline void store_length(uint32_t number)
107
122
  {
108
123
    store_length(ptr, packlength, number);
109
124
  }
110
125
 
111
126
  /**
112
 
     Return the packed length plus the length of the data. 
 
127
     Return the packed length plus the length of the data.
113
128
 
114
 
     This is used to determine the size of the data plus the 
 
129
     This is used to determine the size of the data plus the
115
130
     packed length portion in the row data.
116
131
 
117
132
     @returns The length in the row plus the size of the data.
118
133
  */
119
 
  uint32_t get_packed_size(const unsigned char *ptr_arg, bool low_byte_first)
120
 
    {return packlength + get_length(ptr_arg, packlength, low_byte_first);}
 
134
  uint32_t get_packed_size(const unsigned char *ptr_arg, bool low_byte_first);
121
135
 
122
 
  inline uint32_t get_length(uint32_t row_offset= 0)
123
 
  { return get_length(ptr+row_offset, this->packlength, table->s->db_low_byte_first); }
124
 
  uint32_t get_length(const unsigned char *ptr, uint32_t packlength, bool low_byte_first);
125
 
  uint32_t get_length(const unsigned char *ptr_arg)
126
 
  { return get_length(ptr_arg, this->packlength, table->s->db_low_byte_first); }
 
136
  uint32_t get_length(uint32_t row_offset= 0);
 
137
  uint32_t get_length(const unsigned char *ptr, uint32_t packlength,
 
138
                      bool low_byte_first);
 
139
  uint32_t get_length(const unsigned char *ptr_arg);
127
140
  void put_length(unsigned char *pos, uint32_t length);
128
141
  inline void get_ptr(unsigned char **str)
129
142
    {
149
162
      set_ptr_offset(0, length, data);
150
163
    }
151
164
  uint32_t get_key_image(unsigned char *buff,uint32_t length, imagetype type);
 
165
  uint32_t get_key_image(std::basic_string<unsigned char> &buff,
 
166
                        uint32_t length, imagetype type);
152
167
  void set_key_image(const unsigned char *buff,uint32_t length);
153
168
  void sql_type(String &str) const;
154
169
  inline bool copy()
187
202
  { return charset() == &my_charset_bin ? false : true; }
188
203
  uint32_t max_display_length();
189
204
  uint32_t is_equal(Create_field *new_field);
190
 
  inline bool in_read_set() { return bitmap_is_set(table->read_set, field_index); }
191
 
  inline bool in_write_set() { return bitmap_is_set(table->write_set, field_index); }
 
205
  bool in_read_set();
 
206
  bool in_write_set();
192
207
private:
193
208
  int do_save_field_metadata(unsigned char *first_byte);
194
209
};