~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/blob.h

  • Committer: Monty Taylor
  • Date: 2009-04-14 19:16:51 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 994.
  • Revision ID: mordred@inaugust.com-20090414191651-ltbww6hpqks8k7qk
Clarified instructions in README.

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_BLOB_H
22
 
#define DRIZZLED_FIELD_BLOB_H
23
 
 
24
 
#include <drizzled/field/str.h>
25
 
 
26
 
#include "drizzled/global_charset_info.h"
 
21
#ifndef DRIZZLE_SERVER_FIELD_BLOB
 
22
#define DRIZZLE_SERVER_FIELD_BLOB
 
23
 
 
24
#include <drizzled/field/longstr.h>
27
25
 
28
26
#include <string>
29
27
 
30
 
namespace drizzled
31
 
{
32
 
 
33
 
/**
34
 
 * Class representing a BLOB data type column
35
 
 */
36
 
class Field_blob :public Field_str {
 
28
class Field_blob :public Field_longstr {
37
29
protected:
38
30
  uint32_t packlength;
39
31
  String value;                         // For temporaries
46
38
  using Field::val_int;
47
39
  using Field::val_str;
48
40
 
49
 
  Field_blob(unsigned char *ptr_arg,
50
 
             unsigned char *null_ptr_arg,
51
 
             unsigned char null_bit_arg,
52
 
             const char *field_name_arg,
53
 
             TableShare *share,
54
 
             uint32_t blob_pack_length,
55
 
             const CHARSET_INFO * const cs);
56
 
  Field_blob(uint32_t len_arg,
57
 
             bool maybe_null_arg,
58
 
             const char *field_name_arg,
 
41
 
 
42
  Field_blob(unsigned char *ptr_arg, unsigned char *null_ptr_arg, unsigned char null_bit_arg,
 
43
             enum utype unireg_check_arg, const char *field_name_arg,
 
44
             TABLE_SHARE *share, uint32_t blob_pack_length, const CHARSET_INFO * const cs);
 
45
  Field_blob(uint32_t len_arg, bool maybe_null_arg, const char *field_name_arg,
59
46
             const CHARSET_INFO * const cs)
60
 
    :Field_str((unsigned char*) NULL,
61
 
               len_arg,
62
 
               maybe_null_arg ? (unsigned char *) "": 0,
63
 
               0,
64
 
               field_name_arg,
65
 
               cs),
 
47
    :Field_longstr((unsigned char*) 0, len_arg, maybe_null_arg ? (unsigned char*) "": 0, 0,
 
48
                   NONE, field_name_arg, cs),
66
49
    packlength(4)
67
50
  {
68
51
    flags|= BLOB_FLAG;
69
52
  }
70
 
  Field_blob(uint32_t len_arg,
71
 
             bool maybe_null_arg,
72
 
             const char *field_name_arg,
73
 
             const CHARSET_INFO * const cs,
74
 
             bool set_packlength)
75
 
    :Field_str((unsigned char*) NULL,
76
 
               len_arg,
77
 
               maybe_null_arg ? (unsigned char*) "": 0,
78
 
               0,
79
 
               field_name_arg,
80
 
               cs),
81
 
    packlength(4)
 
53
  Field_blob(uint32_t len_arg, bool maybe_null_arg, const char *field_name_arg,
 
54
             const CHARSET_INFO * const cs, bool set_packlength)
 
55
    :Field_longstr((unsigned char*) 0,len_arg, maybe_null_arg ? (unsigned char*) "": 0, 0,
 
56
                   NONE, field_name_arg, cs)
82
57
  {
83
58
    flags|= BLOB_FLAG;
 
59
    packlength= 4;
84
60
    if (set_packlength)
85
61
    {
86
62
      uint32_t l_char_length= len_arg/cs->mbmaxlen;
90
66
    }
91
67
  }
92
68
  Field_blob(uint32_t packlength_arg)
93
 
    :Field_str((unsigned char*) 0,
94
 
               0,
95
 
               (unsigned char*) "",
96
 
               0,
97
 
               "temp",
98
 
               system_charset_info),
99
 
    packlength(packlength_arg) 
100
 
  {}
 
69
    :Field_longstr((unsigned char*) 0, 0, (unsigned char*) "", 0, NONE, "temp", system_charset_info),
 
70
    packlength(packlength_arg) {}
101
71
  enum_field_types type() const { return DRIZZLE_TYPE_BLOB;}
102
72
  enum ha_base_keytype key_type() const
103
73
    { return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; }
132
102
  */
133
103
  uint32_t pack_length_no_ptr() const
134
104
  { return (uint32_t) (packlength); }
 
105
  uint32_t row_pack_length() { return pack_length_no_ptr(); }
135
106
  uint32_t sort_length() const;
136
107
  virtual uint32_t max_data_length() const
137
108
  {
180
151
      memcpy(ptr,length,packlength);
181
152
      memcpy(ptr+packlength,&data,sizeof(char*));
182
153
    }
183
 
  void set_ptr_offset(ptrdiff_t ptr_diff, uint32_t length, unsigned char *data)
 
154
  void set_ptr_offset(my_ptrdiff_t ptr_diff, uint32_t length, unsigned char *data)
184
155
    {
185
156
      unsigned char *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,unsigned char*);
186
157
      store_length(ptr_ofs, packlength, length);
190
161
    {
191
162
      set_ptr_offset(0, length, data);
192
163
    }
193
 
  uint32_t get_key_image(unsigned char *buff,uint32_t length);
194
 
  uint32_t get_key_image(std::basic_string<unsigned char> &buff, uint32_t length);
 
164
  uint32_t get_key_image(unsigned char *buff,uint32_t length, imagetype type);
 
165
  uint32_t get_key_image(std::basic_string<unsigned char> &buff,
 
166
                        uint32_t length, imagetype type);
195
167
  void set_key_image(const unsigned char *buff,uint32_t length);
196
168
  void sql_type(String &str) const;
197
169
  inline bool copy()
220
192
  bool has_charset(void) const
221
193
  { return charset() == &my_charset_bin ? false : true; }
222
194
  uint32_t max_display_length();
 
195
  uint32_t is_equal(Create_field *new_field);
 
196
  bool in_read_set();
 
197
  bool in_write_set();
 
198
private:
 
199
  int do_save_field_metadata(unsigned char *first_byte);
223
200
};
224
201
 
225
 
} /* namespace drizzled */
226
 
 
227
 
#endif /* DRIZZLED_FIELD_BLOB_H */
 
202
#endif
228
203