~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/blob.cc

Refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
 
21
21
 
22
 
#include "config.h"
 
22
#include <config.h>
23
23
#include <drizzled/field/blob.h>
24
24
#include <drizzled/table.h>
25
25
#include <drizzled/session.h>
26
 
#include "plugin/myisam/myisam.h"
 
26
#include <plugin/myisam/myisam.h>
 
27
#include <drizzled/system_variables.h>
27
28
 
28
29
#include <string>
29
30
#include <algorithm>
51
52
                       unsigned char null_bit_arg,
52
53
                                   const char *field_name_arg,
53
54
                       TableShare *share,
54
 
                       const CHARSET_INFO * const cs)
 
55
                       const charset_info_st * const cs)
55
56
  :Field_str(ptr_arg,
56
57
             blob_pack_length_to_max_length(sizeof(uint32_t)),
57
58
             null_ptr_arg,
90
91
 
91
92
 
92
93
uint32_t Field_blob::get_length(const unsigned char *pos,
93
 
                                bool low_byte_first)
 
94
                                bool low_byte_first) const
94
95
{
95
96
#ifndef WORDS_BIGENDIAN
96
97
  (void)low_byte_first;
113
114
}
114
115
 
115
116
 
116
 
uint32_t Field_blob::get_length(uint32_t row_offset)
 
117
uint32_t Field_blob::get_length(uint32_t row_offset) const
117
118
{
118
119
  return get_length(ptr+row_offset,
119
120
                    getTable()->getShare()->db_low_byte_first);
120
121
}
121
122
 
122
123
 
123
 
uint32_t Field_blob::get_length(const unsigned char *ptr_arg)
 
124
uint32_t Field_blob::get_length(const unsigned char *ptr_arg) const
124
125
{
125
126
  return get_length(ptr_arg, getTable()->getShare()->db_low_byte_first);
126
127
}
141
142
}
142
143
 
143
144
 
144
 
int Field_blob::store(const char *from,uint32_t length, const CHARSET_INFO * const cs)
 
145
int Field_blob::store(const char *from,uint32_t length, const charset_info_st * const cs)
145
146
{
146
147
  uint32_t copy_length, new_length;
147
148
  const char *well_formed_error_pos;
208
209
 
209
210
int Field_blob::store(double nr)
210
211
{
211
 
  const CHARSET_INFO * const cs=charset();
 
212
  const charset_info_st * const cs=charset();
212
213
  ASSERT_COLUMN_MARKED_FOR_WRITE;
213
214
  value.set_real(nr, NOT_FIXED_DEC, cs);
214
215
  return Field_blob::store(value.ptr(),(uint32_t) value.length(), cs);
217
218
 
218
219
int Field_blob::store(int64_t nr, bool unsigned_val)
219
220
{
220
 
  const CHARSET_INFO * const cs=charset();
 
221
  const charset_info_st * const cs=charset();
221
222
  ASSERT_COLUMN_MARKED_FOR_WRITE;
222
223
  value.set_int(nr, unsigned_val, cs);
223
224
  return Field_blob::store(value.ptr(), (uint32_t) value.length(), cs);
224
225
}
225
226
 
226
227
 
227
 
double Field_blob::val_real(void)
 
228
double Field_blob::val_real(void) const
228
229
{
229
230
  int not_used;
230
231
  char *end_not_used, *blob;
231
232
  uint32_t length;
232
 
  const CHARSET_INFO *cs;
 
233
  const charset_info_st *cs;
233
234
 
234
235
  ASSERT_COLUMN_MARKED_FOR_READ;
235
236
 
242
243
}
243
244
 
244
245
 
245
 
int64_t Field_blob::val_int(void)
 
246
int64_t Field_blob::val_int(void) const
246
247
{
247
248
  int not_used;
248
249
  char *blob;
252
253
  memcpy(&blob,ptr+sizeof(uint32_t),sizeof(char*));
253
254
  if (!blob)
254
255
    return 0;
255
 
  uint32_t length=get_length(ptr);
 
256
  uint32_t length= get_length(ptr);
256
257
  return my_strntoll(charset(),blob,length,10,NULL,&not_used);
257
258
}
258
259
 
259
 
String *Field_blob::val_str(String *,
260
 
                            String *val_ptr)
 
260
String *Field_blob::val_str(String *, String *val_ptr) const
261
261
{
262
262
  char *blob;
263
263
 
272
272
}
273
273
 
274
274
 
275
 
my_decimal *Field_blob::val_decimal(my_decimal *decimal_value)
 
275
type::Decimal *Field_blob::val_decimal(type::Decimal *decimal_value) const
276
276
{
277
277
  const char *blob;
278
278
  size_t length;
286
286
    length= 0;
287
287
  }
288
288
  else
 
289
  {
289
290
    length= get_length(ptr);
290
 
 
291
 
  str2my_decimal(E_DEC_FATAL_ERROR, blob, length, charset(),
292
 
                 decimal_value);
 
291
  }
 
292
 
 
293
  decimal_value->store(E_DEC_FATAL_ERROR, blob, length, charset());
 
294
 
293
295
  return decimal_value;
294
296
}
295
297
 
406
408
  unsigned char *blob1;
407
409
  uint32_t blob_length=get_length(ptr);
408
410
  memcpy(&blob1,ptr+sizeof(uint32_t),sizeof(char*));
409
 
  const CHARSET_INFO * const cs= charset();
 
411
  const charset_info_st * const cs= charset();
410
412
  uint32_t local_char_length= max_key_length / cs->mbmaxlen;
411
413
  local_char_length= my_charpos(cs, blob1, blob1+blob_length,
412
414
                                local_char_length);
424
426
 
425
427
uint32_t Field_blob::sort_length() const
426
428
{
427
 
  return (uint32_t) (current_session->variables.max_sort_length +
 
429
  return (uint32_t) (getTable()->getSession()->variables.max_sort_length +
428
430
                     (field_charset == &my_charset_bin ? 0 : sizeof(uint32_t)));
429
431
}
430
432