~xnox/ubuntu/saucy/drizzle/merge

« back to all changes in this revision

Viewing changes to .pc/debian-changes-2010.12.06-0ubuntu4/drizzled/field/blob.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2011-01-01 13:55:03 UTC
  • Revision ID: james.westby@ubuntu.com-20110101135503-x2ub1akxoisgwi6z
Tags: 2010.12.06-0ubuntu4
* Fixed missing build depends.
* Added Lee to uploaders.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* - mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 MySQL
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 */
 
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"
 
27
 
 
28
#include <string>
 
29
 
 
30
namespace drizzled
 
31
{
 
32
 
 
33
/**
 
34
 * Class representing a BLOB data type column
 
35
 */
 
36
class Field_blob :public Field_str {
 
37
protected:
 
38
  String value;                         // For temporaries
 
39
public:
 
40
 
 
41
  using Field::store;
 
42
  using Field::cmp;
 
43
  using Field::pack;
 
44
  using Field::unpack;
 
45
  using Field::val_int;
 
46
  using Field::val_str;
 
47
 
 
48
  Field_blob(unsigned char *ptr_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_blob(uint32_t len_arg,
 
55
             bool maybe_null_arg,
 
56
             const char *field_name_arg,
 
57
             const CHARSET_INFO * const cs)
 
58
    :Field_str((unsigned char*) NULL,
 
59
               len_arg,
 
60
               maybe_null_arg ? (unsigned char *) "": 0,
 
61
               0,
 
62
               field_name_arg,
 
63
               cs)
 
64
  {
 
65
    flags|= BLOB_FLAG;
 
66
  }
 
67
 
 
68
  enum_field_types type() const { return DRIZZLE_TYPE_BLOB;}
 
69
  enum ha_base_keytype key_type() const
 
70
    { return binary() ? HA_KEYTYPE_VARBINARY2 : HA_KEYTYPE_VARTEXT2; }
 
71
  int  store(const char *to,uint32_t length,
 
72
             const CHARSET_INFO * const charset);
 
73
  int  store(double nr);
 
74
  int  store(int64_t nr, bool unsigned_val);
 
75
 
 
76
  double val_real(void);
 
77
  int64_t val_int(void);
 
78
  String *val_str(String*,String *);
 
79
  my_decimal *val_decimal(my_decimal *);
 
80
  int cmp_max(const unsigned char *, const unsigned char *, uint32_t max_length);
 
81
  int cmp(const unsigned char *a,const unsigned char *b)
 
82
    { return cmp_max(a, b, UINT32_MAX); }
 
83
  int cmp(const unsigned char *a, uint32_t a_length, const unsigned char *b, uint32_t b_length);
 
84
  int cmp_binary(const unsigned char *a,const unsigned char *b, uint32_t max_length=UINT32_MAX);
 
85
  int key_cmp(const unsigned char *,const unsigned char*);
 
86
  int key_cmp(const unsigned char *str, uint32_t length);
 
87
  uint32_t key_length() const { return 0; }
 
88
  void sort_string(unsigned char *buff,uint32_t length);
 
89
  uint32_t pack_length() const;
 
90
 
 
91
 
 
92
  /**
 
93
     Return the packed length without the pointer size added.
 
94
 
 
95
     This is used to determine the size of the actual data in the row
 
96
     buffer.
 
97
 
 
98
     @returns The length of the raw data itself without the pointer.
 
99
  */
 
100
  uint32_t pack_length_no_ptr() const
 
101
  { return (uint32_t) (sizeof(uint32_t)); }
 
102
 
 
103
  uint32_t sort_length() const;
 
104
  virtual uint32_t max_data_length() const
 
105
  {
 
106
    return (uint32_t) (((uint64_t) 1 << 32) -1);
 
107
  }
 
108
  int reset(void) { memset(ptr, 0, sizeof(uint32_t)+sizeof(unsigned char*)); return 0; }
 
109
  void reset_fields() { memset(&value, 0, sizeof(value)); }
 
110
#ifndef WORDS_BIGENDIAN
 
111
  static
 
112
#endif
 
113
  void store_length(unsigned char *i_ptr, uint32_t i_number, bool low_byte_first);
 
114
  void store_length(unsigned char *i_ptr, uint32_t i_number);
 
115
 
 
116
  inline void store_length(uint32_t number)
 
117
  {
 
118
    store_length(ptr, number);
 
119
  }
 
120
 
 
121
  /**
 
122
     Return the packed length plus the length of the data.
 
123
 
 
124
     This is used to determine the size of the data plus the
 
125
     packed length portion in the row data.
 
126
 
 
127
     @returns The length in the row plus the size of the data.
 
128
  */
 
129
  uint32_t get_packed_size(const unsigned char *ptr_arg, bool low_byte_first);
 
130
 
 
131
  uint32_t get_length(uint32_t row_offset= 0);
 
132
  uint32_t get_length(const unsigned char *ptr, bool low_byte_first);
 
133
  uint32_t get_length(const unsigned char *ptr_arg);
 
134
  void put_length(unsigned char *pos, uint32_t length);
 
135
  inline void get_ptr(unsigned char **str)
 
136
    {
 
137
      memcpy(str,ptr+sizeof(uint32_t),sizeof(unsigned char*));
 
138
    }
 
139
  inline void get_ptr(unsigned char **str, uint32_t row_offset)
 
140
    {
 
141
      memcpy(str,ptr+sizeof(uint32_t)+row_offset,sizeof(char*));
 
142
    }
 
143
  inline void set_ptr(unsigned char *length, unsigned char *data)
 
144
    {
 
145
      memcpy(ptr,length,sizeof(uint32_t));
 
146
      memcpy(ptr+sizeof(uint32_t),&data,sizeof(char*));
 
147
    }
 
148
  void set_ptr_offset(ptrdiff_t ptr_diff, uint32_t length, unsigned char *data)
 
149
    {
 
150
      unsigned char *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,unsigned char*);
 
151
      store_length(ptr_ofs, length);
 
152
      memcpy(ptr_ofs+sizeof(uint32_t),&data,sizeof(char*));
 
153
    }
 
154
  inline void set_ptr(uint32_t length, unsigned char *data)
 
155
    {
 
156
      set_ptr_offset(0, length, data);
 
157
    }
 
158
  uint32_t get_key_image(unsigned char *buff,uint32_t length);
 
159
  uint32_t get_key_image(std::basic_string<unsigned char> &buff, uint32_t length);
 
160
  void set_key_image(const unsigned char *buff,uint32_t length);
 
161
  void sql_type(String &str) const;
 
162
  inline bool copy()
 
163
  {
 
164
    unsigned char *tmp;
 
165
    get_ptr(&tmp);
 
166
    if (value.copy((char*) tmp, get_length(), charset()))
 
167
    {
 
168
      Field_blob::reset();
 
169
      return 1;
 
170
    }
 
171
    tmp=(unsigned char*) value.ptr();
 
172
    memcpy(ptr+sizeof(uint32_t),&tmp,sizeof(char*));
 
173
    return 0;
 
174
  }
 
175
  virtual unsigned char *pack(unsigned char *to, const unsigned char *from,
 
176
                      uint32_t max_length, bool low_byte_first);
 
177
  unsigned char *pack_key(unsigned char *to, const unsigned char *from,
 
178
                  uint32_t max_length, bool low_byte_first);
 
179
  virtual const unsigned char *unpack(unsigned char *to, const unsigned char *from,
 
180
                              uint32_t , bool low_byte_first);
 
181
  void free() { value.free(); }
 
182
  inline void clear_temporary() { memset(&value, 0, sizeof(value)); }
 
183
  friend int field_conv(Field *to,Field *from);
 
184
  uint32_t size_of() const { return sizeof(*this); }
 
185
  bool has_charset(void) const
 
186
  { return charset() == &my_charset_bin ? false : true; }
 
187
  uint32_t max_display_length();
 
188
};
 
189
 
 
190
} /* namespace drizzled */
 
191
 
 
192
#endif /* DRIZZLED_FIELD_BLOB_H */
 
193