18
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#ifndef DRIZZLED_FIELD_VARSTRING_H
22
#define DRIZZLED_FIELD_VARSTRING_H
21
#ifndef DRIZZLE_SERVER_FIELD_VARSTRING
22
#define DRIZZLE_SERVER_FIELD_VARSTRING
24
24
#include <drizzled/field/str.h>
30
27
class Field_varstring :public Field_str {
44
41
/* Store number of bytes used to store length (1 or 2) */
45
42
uint32_t length_bytes;
46
43
Field_varstring(unsigned char *ptr_arg,
48
uint32_t length_bytes_arg,
49
unsigned char *null_ptr_arg,
50
unsigned char null_bit_arg,
51
const char *field_name_arg,
53
const CHARSET_INFO * const cs);
54
Field_varstring(uint32_t len_arg,
56
const char *field_name_arg,
58
const CHARSET_INFO * const cs);
44
uint32_t len_arg, uint32_t length_bytes_arg,
45
unsigned char *null_ptr_arg, unsigned char null_bit_arg,
46
enum utype unireg_check_arg, const char *field_name_arg,
47
TableShare *share, const CHARSET_INFO * const cs);
48
Field_varstring(uint32_t len_arg,bool maybe_null_arg,
49
const char *field_name_arg,
50
TableShare *share, const CHARSET_INFO * const cs);
60
52
enum_field_types type() const { return DRIZZLE_TYPE_VARCHAR; }
61
53
enum ha_base_keytype key_type() const;
54
uint32_t row_pack_length() { return field_length; }
62
55
bool zero_pack() const { return 0; }
63
56
int reset(void) { memset(ptr, 0, field_length+length_bytes); return 0; }
64
57
uint32_t pack_length() const { return (uint32_t) field_length+length_bytes; }
89
82
uint32_t get_key_image(std::basic_string <unsigned char> &buff, uint32_t length);
90
83
void set_key_image(const unsigned char *buff,uint32_t length);
91
84
void sql_type(String &str) const;
92
virtual unsigned char *pack(unsigned char *to,
85
virtual unsigned char *pack(unsigned char *to,
93
86
const unsigned char *from,
94
87
uint32_t max_length,
95
88
bool low_byte_first);
90
unsigned char *pack_key(unsigned char *to, const unsigned char *from, uint32_t max_length, bool low_byte_first);
91
unsigned char *pack_key_from_key_image(unsigned char* to,
92
const unsigned char *from,
97
95
virtual const unsigned char *unpack(unsigned char* to,
98
96
const unsigned char *from,
99
97
uint32_t param_data,
100
98
bool low_byte_first);
100
const unsigned char *unpack_key(unsigned char* to, const unsigned char *from,
101
uint32_t max_length, bool low_byte_first);
102
int pack_cmp(const unsigned char *a, const unsigned char *b, uint32_t key_length,
103
bool insert_or_update);
104
int pack_cmp(const unsigned char *b, uint32_t key_length,bool insert_or_update);
102
105
int cmp_binary(const unsigned char *a,const unsigned char *b, uint32_t max_length=UINT32_MAX);
103
106
int key_cmp(const unsigned char *,const unsigned char*);
104
107
int key_cmp(const unsigned char *str, uint32_t length);
108
uint32_t packed_col_length(const unsigned char *to, uint32_t length);
105
109
uint32_t max_packed_col_length(uint32_t max_length);
110
uint32_t data_length();
106
111
uint32_t used_length();
107
112
uint32_t size_of() const { return sizeof(*this); }
108
113
enum_field_types real_type() const { return DRIZZLE_TYPE_VARCHAR; }
109
114
bool has_charset(void) const
110
115
{ return charset() == &my_charset_bin ? false : true; }
111
Field *new_field(memory::Root *root, Table *new_table, bool keep_type);
112
Field *new_key_field(memory::Root *root, Table *new_table,
116
Field *new_field(MEM_ROOT *root, Table *new_table, bool keep_type);
117
Field *new_key_field(MEM_ROOT *root, Table *new_table,
113
118
unsigned char *new_ptr, unsigned char *new_null_ptr,
114
119
uint32_t new_null_bit);
120
uint32_t is_equal(CreateField *new_field);
121
void hash(uint32_t *nr, uint32_t *nr2);
123
int do_save_field_metadata(unsigned char *first_byte);
117
} /* namespace drizzled */
119
#endif /* DRIZZLED_FIELD_VARSTRING_H */