~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/varstring.h

code clean move Item_func_abs, Item_func_int_exp, Item_func_ln, Item_func_log to functions directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#ifndef DRIZZLED_FIELD_VARSTRING_H
22
 
#define DRIZZLED_FIELD_VARSTRING_H
23
 
 
24
 
#include <drizzled/field/str.h>
25
 
#include <string>
26
 
 
27
 
namespace drizzled
28
 
{
29
 
 
30
 
class Field_varstring :public Field_str {
 
21
#ifndef DRIZZLE_SERVER_FIELD_VARSTRING
 
22
#define DRIZZLE_SERVER_FIELD_VARSTRING
 
23
 
 
24
class Field_varstring :public Field_longstr {
31
25
public:
32
 
 
33
 
  using Field::store;
34
 
  using Field::pack;
35
 
  using Field::unpack;
36
 
  using Field::val_int;
37
 
  using Field::val_str;
38
 
 
39
26
  /*
40
27
    The maximum space available in a Field_varstring, in bytes. See
41
28
    length_bytes.
44
31
  /* Store number of bytes used to store length (1 or 2) */
45
32
  uint32_t length_bytes;
46
33
  Field_varstring(unsigned char *ptr_arg,
47
 
                  uint32_t len_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,
52
 
                  TableShare *share,
53
 
                  const CHARSET_INFO * const cs);
54
 
  Field_varstring(uint32_t len_arg,
55
 
                  bool maybe_null_arg,
56
 
                  const char *field_name_arg,
57
 
                  TableShare *share,
58
 
                  const CHARSET_INFO * const cs);
 
34
                  uint32_t len_arg, uint32_t length_bytes_arg,
 
35
                  unsigned char *null_ptr_arg, unsigned char null_bit_arg,
 
36
                  enum utype unireg_check_arg, const char *field_name_arg,
 
37
                  TABLE_SHARE *share, const CHARSET_INFO * const cs)
 
38
    :Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
 
39
                   unireg_check_arg, field_name_arg, cs),
 
40
     length_bytes(length_bytes_arg)
 
41
  {
 
42
    share->varchar_fields++;
 
43
  }
 
44
  Field_varstring(uint32_t len_arg,bool maybe_null_arg,
 
45
                  const char *field_name_arg,
 
46
                  TABLE_SHARE *share, const CHARSET_INFO * const cs)
 
47
    :Field_longstr((unsigned char*) 0,len_arg, maybe_null_arg ? (unsigned char*) "": 0, 0,
 
48
                   NONE, field_name_arg, cs),
 
49
     length_bytes(len_arg < 256 ? 1 :2)
 
50
  {
 
51
    share->varchar_fields++;
 
52
  }
59
53
 
60
54
  enum_field_types type() const { return DRIZZLE_TYPE_VARCHAR; }
61
55
  enum ha_base_keytype key_type() const;
 
56
  uint32_t row_pack_length() { return field_length; }
62
57
  bool zero_pack() const { return 0; }
63
58
  int  reset(void) { memset(ptr, 0, field_length+length_bytes); return 0; }
64
59
  uint32_t pack_length() const { return (uint32_t) field_length+length_bytes; }
69
64
                                    length_bytes : 0);
70
65
  }
71
66
  int  store(const char *to,uint32_t length, const CHARSET_INFO * const charset);
72
 
 
73
 
 
74
67
  int  store(int64_t nr, bool unsigned_val);
75
68
  int  store(double nr) { return Field_str::store(nr); } /* QQ: To be deleted */
76
69
  double val_real(void);
77
70
  int64_t val_int(void);
78
71
  String *val_str(String*,String *);
79
 
  inline String *val_str(String *str) { return val_str(str, str); }
80
72
  my_decimal *val_decimal(my_decimal *);
81
73
  int cmp_max(const unsigned char *, const unsigned char *, uint32_t max_length);
82
 
  inline  int cmp(const unsigned char *str) { return cmp(ptr,str); }
83
74
  int cmp(const unsigned char *a,const unsigned char *b)
84
75
  {
85
76
    return cmp_max(a, b, UINT32_MAX);
86
77
  }
87
78
  void sort_string(unsigned char *buff,uint32_t length);
88
 
  uint32_t get_key_image(unsigned char *buff,uint32_t length);
89
 
  uint32_t get_key_image(std::basic_string <unsigned char> &buff, uint32_t length);
 
79
  uint32_t get_key_image(unsigned char *buff,uint32_t length, imagetype type);
90
80
  void set_key_image(const unsigned char *buff,uint32_t length);
91
81
  void sql_type(String &str) const;
92
 
  virtual unsigned char *pack(unsigned char *to,
93
 
                              const unsigned char *from,
94
 
                              uint32_t max_length,
95
 
                              bool low_byte_first);
96
 
 
97
 
  virtual const unsigned char *unpack(unsigned char* to,
98
 
                                      const unsigned char *from,
99
 
                                      uint32_t param_data,
100
 
                                      bool low_byte_first);
101
 
 
 
82
  virtual unsigned char *pack(unsigned char *to, const unsigned char *from,
 
83
                      uint32_t max_length, bool low_byte_first);
 
84
  unsigned char *pack_key(unsigned char *to, const unsigned char *from, uint32_t max_length, bool low_byte_first);
 
85
  unsigned char *pack_key_from_key_image(unsigned char* to, const unsigned char *from,
 
86
                                 uint32_t max_length, bool low_byte_first);
 
87
  virtual const unsigned char *unpack(unsigned char* to, const unsigned char *from,
 
88
                              uint32_t param_data, bool low_byte_first);
 
89
  const unsigned char *unpack_key(unsigned char* to, const unsigned char *from,
 
90
                          uint32_t max_length, bool low_byte_first);
 
91
  int pack_cmp(const unsigned char *a, const unsigned char *b, uint32_t key_length,
 
92
               bool insert_or_update);
 
93
  int pack_cmp(const unsigned char *b, uint32_t key_length,bool insert_or_update);
102
94
  int cmp_binary(const unsigned char *a,const unsigned char *b, uint32_t max_length=UINT32_MAX);
103
95
  int key_cmp(const unsigned char *,const unsigned char*);
104
96
  int key_cmp(const unsigned char *str, uint32_t length);
 
97
  uint32_t packed_col_length(const unsigned char *to, uint32_t length);
105
98
  uint32_t max_packed_col_length(uint32_t max_length);
 
99
  uint32_t data_length();
106
100
  uint32_t used_length();
107
101
  uint32_t size_of() const { return sizeof(*this); }
108
102
  enum_field_types real_type() const { return DRIZZLE_TYPE_VARCHAR; }
109
103
  bool has_charset(void) const
110
104
  { 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,
 
105
  Field *new_field(MEM_ROOT *root, Table *new_table, bool keep_type);
 
106
  Field *new_key_field(MEM_ROOT *root, Table *new_table,
113
107
                       unsigned char *new_ptr, unsigned char *new_null_ptr,
114
108
                       uint32_t new_null_bit);
 
109
  uint32_t is_equal(Create_field *new_field);
 
110
  void hash(uint32_t *nr, uint32_t *nr2);
 
111
private:
 
112
  int do_save_field_metadata(unsigned char *first_byte);
115
113
};
116
114
 
117
 
} /* namespace drizzled */
118
 
 
119
 
#endif /* DRIZZLED_FIELD_VARSTRING_H */
 
115
#endif
120
116