~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/varstring.h

  • Committer: Monty Taylor
  • Date: 2008-12-17 04:54:32 UTC
  • mto: (685.1.38 devel) (713.1.1 devel)
  • mto: This revision was merged to the branch mainline in revision 713.
  • Revision ID: monty@inaugust.com-20081217045432-dw4425razy7do46i
Fixed bool. No more sql_mode.

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