~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/varstring.h

  • Committer: devananda
  • Date: 2009-07-01 17:38:47 UTC
  • mto: (1093.1.7 captain)
  • mto: This revision was merged to the branch mainline in revision 1095.
  • Revision ID: devananda.vdv@gmail.com-20090701173847-3n3mbtessg5ff35e
refactored function/benchmark into plugin/benchmark

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
 
21
#ifndef DRIZZLE_SERVER_FIELD_VARSTRING
 
22
#define DRIZZLE_SERVER_FIELD_VARSTRING
23
23
 
24
24
#include <drizzled/field/str.h>
25
25
#include <string>
26
26
 
27
 
namespace drizzled
28
 
{
29
 
 
30
27
class Field_varstring :public Field_str {
31
28
public:
32
29
 
41
38
    length_bytes.
42
39
  */
43
40
  static const uint32_t MAX_SIZE;
44
 
private:
45
41
  /* Store number of bytes used to store length (1 or 2) */
46
42
  uint32_t length_bytes;
47
 
public:
48
43
  Field_varstring(unsigned char *ptr_arg,
49
 
                  uint32_t len_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,
54
 
                  const CHARSET_INFO * const cs);
55
 
  Field_varstring(uint32_t len_arg,
56
 
                  bool maybe_null_arg,
57
 
                  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);
59
51
 
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; }
65
 
  uint32_t pack_length_no_ptr() const { return length_bytes; }
66
58
  uint32_t key_length() const { return (uint32_t) field_length; }
67
59
  uint32_t sort_length() const
68
60
  {
69
61
    return (uint32_t) field_length + (field_charset == &my_charset_bin ?
70
 
                                      length_bytes : 0);
 
62
                                    length_bytes : 0);
71
63
  }
72
64
  int  store(const char *to,uint32_t length, const CHARSET_INFO * const charset);
73
65
 
90
82
  uint32_t get_key_image(std::basic_string <unsigned char> &buff, uint32_t length);
91
83
  void set_key_image(const unsigned char *buff,uint32_t length);
92
84
  void sql_type(String &str) const;
93
 
  virtual unsigned char *pack(unsigned char *to,
 
85
  virtual unsigned char *pack(unsigned char *to, 
94
86
                              const unsigned char *from,
95
87
                              uint32_t max_length,
96
88
                              bool low_byte_first);
97
89
 
 
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,
 
93
                                         uint32_t max_length,
 
94
                                         bool low_byte_first);
98
95
  virtual const unsigned char *unpack(unsigned char* to,
99
96
                                      const unsigned char *from,
100
97
                                      uint32_t param_data,
101
98
                                      bool low_byte_first);
102
 
 
 
99
 
 
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);
103
105
  int cmp_binary(const unsigned char *a,const unsigned char *b, uint32_t max_length=UINT32_MAX);
104
106
  int key_cmp(const unsigned char *,const unsigned char*);
105
107
  int key_cmp(const unsigned char *str, uint32_t length);
 
108
  uint32_t packed_col_length(const unsigned char *to, uint32_t length);
106
109
  uint32_t max_packed_col_length(uint32_t max_length);
 
110
  uint32_t data_length();
107
111
  uint32_t used_length();
108
112
  uint32_t size_of() const { return sizeof(*this); }
109
113
  enum_field_types real_type() const { return DRIZZLE_TYPE_VARCHAR; }
110
114
  bool has_charset(void) const
111
115
  { return charset() == &my_charset_bin ? false : true; }
112
 
  Field *new_field(memory::Root *root, Table *new_table, bool keep_type);
113
 
  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,
114
118
                       unsigned char *new_ptr, unsigned char *new_null_ptr,
115
119
                       uint32_t new_null_bit);
 
120
  uint32_t is_equal(CreateField *new_field);
 
121
  void hash(uint32_t *nr, uint32_t *nr2);
 
122
private:
 
123
  int do_save_field_metadata(unsigned char *first_byte);
116
124
};
117
125
 
118
 
} /* namespace drizzled */
119
 
 
120
 
#endif /* DRIZZLED_FIELD_VARSTRING_H */
 
126
#endif
121
127