18
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#ifndef DRIZZLE_SERVER_FIELD_BLOB
22
#define DRIZZLE_SERVER_FIELD_BLOB
24
class Field_blob :public Field_longstr {
21
#ifndef DRIZZLED_FIELD_BLOB_H
22
#define DRIZZLED_FIELD_BLOB_H
24
#include <drizzled/field/str.h>
29
* Class representing a BLOB data type column
31
class Field_blob :public Field_str {
26
33
uint32_t packlength;
27
34
String value; // For temporaries
29
45
Field_blob(unsigned char *ptr_arg, unsigned char *null_ptr_arg, unsigned char null_bit_arg,
30
46
enum utype unireg_check_arg, const char *field_name_arg,
31
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,
47
TableShare *share, uint32_t blob_pack_length, const CHARSET_INFO * const cs);
48
Field_blob(uint32_t len_arg, bool maybe_null_arg, const char *field_name_arg,
33
49
const CHARSET_INFO * const cs)
34
:Field_longstr((unsigned char*) 0, len_arg, maybe_null_arg ? (unsigned char*) "": 0, 0,
50
:Field_str((unsigned char*) 0, len_arg, maybe_null_arg ? (unsigned char*) "": 0, 0,
35
51
NONE, field_name_arg, cs),
40
Field_blob(uint32_t len_arg,bool maybe_null_arg, const char *field_name_arg,
56
Field_blob(uint32_t len_arg, bool maybe_null_arg, const char *field_name_arg,
41
57
const CHARSET_INFO * const cs, bool set_packlength)
42
:Field_longstr((unsigned char*) 0,len_arg, maybe_null_arg ? (unsigned char*) "": 0, 0,
58
:Field_str((unsigned char*) 0,len_arg, maybe_null_arg ? (unsigned char*) "": 0, 0,
43
59
NONE, field_name_arg, cs)
55
71
Field_blob(uint32_t packlength_arg)
56
:Field_longstr((unsigned char*) 0, 0, (unsigned char*) "", 0, NONE, "temp", system_charset_info),
72
:Field_str((unsigned char*) 0, 0, (unsigned char*) "", 0, NONE, "temp", system_charset_info),
57
73
packlength(packlength_arg) {}
58
74
enum_field_types type() const { return DRIZZLE_TYPE_BLOB;}
59
75
enum ha_base_keytype key_type() const
60
76
{ return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; }
61
int store(const char *to,uint32_t length, const CHARSET_INFO * const charset);
77
int store(const char *to,uint32_t length,
78
const CHARSET_INFO * const charset);
62
79
int store(double nr);
63
80
int store(int64_t nr, bool unsigned_val);
64
82
double val_real(void);
65
83
int64_t val_int(void);
66
84
String *val_str(String*,String *);
74
92
int key_cmp(const unsigned char *str, uint32_t length);
75
93
uint32_t key_length() const { return 0; }
76
94
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); }
95
uint32_t pack_length() const;
81
Return the packed length without the pointer size added.
99
Return the packed length without the pointer size added.
83
101
This is used to determine the size of the actual data in the row
98
116
#ifndef WORDS_BIGENDIAN
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)
104
store_length(i_ptr, i_packlength, i_number, table->s->db_low_byte_first);
119
void store_length(unsigned char *i_ptr, uint32_t i_packlength,
120
uint32_t i_number, bool low_byte_first);
121
void store_length(unsigned char *i_ptr, uint32_t i_packlength,
106
124
inline void store_length(uint32_t number)
108
126
store_length(ptr, packlength, number);
112
Return the packed length plus the length of the data.
130
Return the packed length plus the length of the data.
114
This is used to determine the size of the data plus the
132
This is used to determine the size of the data plus the
115
133
packed length portion in the row data.
117
135
@returns The length in the row plus the size of the data.
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);}
137
uint32_t get_packed_size(const unsigned char *ptr_arg, bool low_byte_first);
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); }
139
uint32_t get_length(uint32_t row_offset= 0);
140
uint32_t get_length(const unsigned char *ptr, uint32_t packlength,
141
bool low_byte_first);
142
uint32_t get_length(const unsigned char *ptr_arg);
127
143
void put_length(unsigned char *pos, uint32_t length);
128
144
inline void get_ptr(unsigned char **str)
138
154
memcpy(ptr,length,packlength);
139
155
memcpy(ptr+packlength,&data,sizeof(char*));
141
void set_ptr_offset(my_ptrdiff_t ptr_diff, uint32_t length, unsigned char *data)
157
void set_ptr_offset(ptrdiff_t ptr_diff, uint32_t length, unsigned char *data)
143
159
unsigned char *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,unsigned char*);
144
160
store_length(ptr_ofs, packlength, length);
149
165
set_ptr_offset(0, length, data);
151
uint32_t get_key_image(unsigned char *buff,uint32_t length, imagetype type);
167
uint32_t get_key_image(unsigned char *buff,uint32_t length);
168
uint32_t get_key_image(std::basic_string<unsigned char> &buff, uint32_t length);
152
169
void set_key_image(const unsigned char *buff,uint32_t length);
153
170
void sql_type(String &str) const;
154
171
inline bool copy()
168
185
uint32_t max_length, bool low_byte_first);
169
186
unsigned char *pack_key(unsigned char *to, const unsigned char *from,
170
187
uint32_t max_length, bool low_byte_first);
171
unsigned char *pack_key_from_key_image(unsigned char* to, const unsigned char *from,
172
uint32_t max_length, bool low_byte_first);
173
188
virtual const unsigned char *unpack(unsigned char *to, const unsigned char *from,
174
189
uint32_t param_data, bool low_byte_first);
175
const unsigned char *unpack_key(unsigned char* to, const unsigned char *from,
176
uint32_t max_length, bool low_byte_first);
177
int pack_cmp(const unsigned char *a, const unsigned char *b, uint32_t key_length,
178
bool insert_or_update);
179
int pack_cmp(const unsigned char *b, uint32_t key_length,bool insert_or_update);
180
uint32_t packed_col_length(const unsigned char *col_ptr, uint32_t length);
181
uint32_t max_packed_col_length(uint32_t max_length);
182
190
void free() { value.free(); }
183
191
inline void clear_temporary() { memset(&value, 0, sizeof(value)); }
184
192
friend int field_conv(Field *to,Field *from);
186
194
bool has_charset(void) const
187
195
{ return charset() == &my_charset_bin ? false : true; }
188
196
uint32_t max_display_length();
189
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); }
197
uint32_t is_equal(CreateField *new_field);
193
200
int do_save_field_metadata(unsigned char *first_byte);
203
#endif /* DRIZZLED_FIELD_BLOB_H */