~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/blob.h

  • Committer: Brian Aker
  • Date: 2010-04-05 23:46:43 UTC
  • Revision ID: brian@gaz-20100405234643-0he3xnj902rc70r8
Fixing tests to work with PBXT.

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 DRIZZLE_SERVER_FIELD_BLOB
22
 
#define DRIZZLE_SERVER_FIELD_BLOB
 
21
#ifndef DRIZZLED_FIELD_BLOB_H
 
22
#define DRIZZLED_FIELD_BLOB_H
23
23
 
24
24
#include <drizzled/field/str.h>
25
25
 
 
26
#include "drizzled/global_charset_info.h"
 
27
 
26
28
#include <string>
27
29
 
 
30
namespace drizzled
 
31
{
 
32
 
28
33
/**
29
34
 * Class representing a BLOB data type column
30
35
 */
41
46
  using Field::val_int;
42
47
  using Field::val_str;
43
48
 
44
 
 
45
 
  Field_blob(unsigned char *ptr_arg, unsigned char *null_ptr_arg, unsigned char null_bit_arg,
46
 
             enum utype unireg_check_arg, const char *field_name_arg,
47
 
             TableShare *share, uint32_t blob_pack_length, const CHARSET_INFO * const cs);
48
 
  Field_blob(uint32_t len_arg, bool maybe_null_arg, const char *field_name_arg,
 
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,
49
59
             const CHARSET_INFO * const cs)
50
 
    :Field_str((unsigned char*) 0, len_arg, maybe_null_arg ? (unsigned char*) "": 0, 0,
51
 
                   NONE, field_name_arg, 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),
52
66
    packlength(4)
53
67
  {
54
68
    flags|= BLOB_FLAG;
55
69
  }
56
 
  Field_blob(uint32_t len_arg, bool maybe_null_arg, const char *field_name_arg,
57
 
             const CHARSET_INFO * const cs, bool set_packlength)
58
 
    :Field_str((unsigned char*) 0,len_arg, maybe_null_arg ? (unsigned char*) "": 0, 0,
59
 
                   NONE, field_name_arg, cs)
 
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)
60
82
  {
61
83
    flags|= BLOB_FLAG;
62
 
    packlength= 4;
63
84
    if (set_packlength)
64
85
    {
65
86
      uint32_t l_char_length= len_arg/cs->mbmaxlen;
69
90
    }
70
91
  }
71
92
  Field_blob(uint32_t packlength_arg)
72
 
    :Field_str((unsigned char*) 0, 0, (unsigned char*) "", 0, NONE, "temp", system_charset_info),
73
 
    packlength(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
  {}
74
101
  enum_field_types type() const { return DRIZZLE_TYPE_BLOB;}
75
102
  enum ha_base_keytype key_type() const
76
103
    { return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; }
105
132
  */
106
133
  uint32_t pack_length_no_ptr() const
107
134
  { return (uint32_t) (packlength); }
108
 
  uint32_t row_pack_length() { return pack_length_no_ptr(); }
109
135
  uint32_t sort_length() const;
110
136
  virtual uint32_t max_data_length() const
111
137
  {
154
180
      memcpy(ptr,length,packlength);
155
181
      memcpy(ptr+packlength,&data,sizeof(char*));
156
182
    }
157
 
  void set_ptr_offset(my_ptrdiff_t ptr_diff, uint32_t length, unsigned char *data)
 
183
  void set_ptr_offset(ptrdiff_t ptr_diff, uint32_t length, unsigned char *data)
158
184
    {
159
185
      unsigned char *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,unsigned char*);
160
186
      store_length(ptr_ofs, packlength, length);
194
220
  bool has_charset(void) const
195
221
  { return charset() == &my_charset_bin ? false : true; }
196
222
  uint32_t max_display_length();
197
 
  uint32_t is_equal(CreateField *new_field);
198
 
 
199
 
private:
200
 
  int do_save_field_metadata(unsigned char *first_byte);
201
223
};
202
224
 
203
 
#endif
 
225
} /* namespace drizzled */
 
226
 
 
227
#endif /* DRIZZLED_FIELD_BLOB_H */
204
228