1
/* - mode: c++ c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 MySQL
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
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
24
#include <drizzled/field/str.h>
30
class Field_varstring :public Field_str {
40
The maximum space available in a Field_varstring, in bytes. See
43
static const uint32_t MAX_SIZE;
45
/* Store number of bytes used to store length (1 or 2) */
46
uint32_t length_bytes;
48
Field_varstring(unsigned char *ptr_arg,
50
uint32_t length_bytes_arg,
51
unsigned char *null_ptr_arg,
52
unsigned char null_bit_arg,
53
const char *field_name_arg,
55
const CHARSET_INFO * const cs);
56
Field_varstring(uint32_t len_arg,
58
const char *field_name_arg,
60
const CHARSET_INFO * const cs);
62
enum_field_types type() const { return DRIZZLE_TYPE_VARCHAR; }
63
enum ha_base_keytype key_type() const;
64
bool zero_pack() const { return 0; }
65
int reset(void) { memset(ptr, 0, field_length+length_bytes); return 0; }
66
uint32_t pack_length() const { return (uint32_t) field_length+length_bytes; }
67
uint32_t pack_length_no_ptr() const { return length_bytes; }
68
uint32_t key_length() const { return (uint32_t) field_length; }
69
uint32_t sort_length() const
71
return (uint32_t) field_length + (field_charset == &my_charset_bin ?
74
int store(const char *to,uint32_t length, const CHARSET_INFO * const charset);
77
int store(int64_t nr, bool unsigned_val);
78
int store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */
79
double val_real(void);
80
int64_t val_int(void);
81
String *val_str(String*,String *);
82
inline String *val_str(String *str) { return val_str(str, str); }
83
my_decimal *val_decimal(my_decimal *);
84
int cmp_max(const unsigned char *, const unsigned char *, uint32_t max_length);
85
inline int cmp(const unsigned char *str) { return cmp(ptr,str); }
86
int cmp(const unsigned char *a,const unsigned char *b)
88
return cmp_max(a, b, UINT32_MAX);
90
void sort_string(unsigned char *buff,uint32_t length);
91
uint32_t get_key_image(unsigned char *buff,uint32_t length);
92
uint32_t get_key_image(std::basic_string <unsigned char> &buff, uint32_t length);
93
void set_key_image(const unsigned char *buff,uint32_t length);
94
void sql_type(String &str) const;
95
virtual unsigned char *pack(unsigned char *to,
96
const unsigned char *from,
100
virtual const unsigned char *unpack(unsigned char* to,
101
const unsigned char *from,
103
bool low_byte_first);
105
int cmp_binary(const unsigned char *a,const unsigned char *b, uint32_t max_length=UINT32_MAX);
106
int key_cmp(const unsigned char *,const unsigned char*);
107
int key_cmp(const unsigned char *str, uint32_t length);
108
uint32_t max_packed_col_length(uint32_t max_length);
109
uint32_t used_length();
110
uint32_t size_of() const { return sizeof(*this); }
111
enum_field_types real_type() const { return DRIZZLE_TYPE_VARCHAR; }
112
bool has_charset(void) const
113
{ return charset() == &my_charset_bin ? false : true; }
114
Field *new_field(memory::Root *root, Table *new_table, bool keep_type);
115
Field *new_key_field(memory::Root *root, Table *new_table,
116
unsigned char *new_ptr, unsigned char *new_null_ptr,
117
uint32_t new_null_bit);
120
} /* namespace drizzled */
122
#endif /* DRIZZLED_FIELD_VARSTRING_H */