21
21
#ifndef DRIZZLE_SERVER_FIELD_BLOB
22
22
#define DRIZZLE_SERVER_FIELD_BLOB
24
#include <drizzled/field/longstr.h>
24
28
class Field_blob :public Field_longstr {
26
30
uint32_t packlength;
27
31
String value; // For temporaries
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),
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);
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;
81
Return the packed length without the pointer size added.
96
Return the packed length without the pointer size added.
83
98
This is used to determine the size of the actual data in the row
98
113
#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);
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,
106
121
inline void store_length(uint32_t number)
108
123
store_length(ptr, packlength, number);
112
Return the packed length plus the length of the data.
127
Return the packed length plus the length of the data.
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.
117
132
@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);}
134
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); }
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)
149
162
set_ptr_offset(0, length, data);
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); }
193
208
int do_save_field_metadata(unsigned char *first_byte);