~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/str.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-13 01:03:01 UTC
  • mto: (1126.9.2 captain-20090915-01)
  • mto: This revision was merged to the branch mainline in revision 1133.
  • Revision ID: osullivan.padraig@gmail.com-20090913010301-tcvvezipx1124acy
Added calls to the dtrace delete begin/end probes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
 
21
21
 
22
 
#include "config.h"
 
22
#include <drizzled/server_includes.h>
23
23
#include <drizzled/field/str.h>
24
24
#include <drizzled/error.h>
25
25
#include <drizzled/table.h>
26
26
#include <drizzled/session.h>
27
 
#include "drizzled/internal/m_string.h"
28
 
 
29
 
namespace drizzled
30
 
{
31
 
 
32
 
namespace internal
33
 
{
34
 
extern char _dig_vec_upper[];
35
 
}
36
 
 
37
 
Field_str::Field_str(unsigned char *ptr_arg,
38
 
                     uint32_t len_arg,
 
27
 
 
28
 
 
29
Field_str::Field_str(unsigned char *ptr_arg,uint32_t len_arg,
39
30
                     unsigned char *null_ptr_arg,
40
 
                     unsigned char null_bit_arg,
 
31
                     unsigned char null_bit_arg, utype unireg_check_arg,
41
32
                     const char *field_name_arg,
42
33
                     const CHARSET_INFO * const charset_arg)
43
 
  :Field(ptr_arg, len_arg,
44
 
         null_ptr_arg,
45
 
         null_bit_arg,
46
 
         Field::NONE,
47
 
         field_name_arg)
 
34
  :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
 
35
         unireg_check_arg, field_name_arg)
48
36
{
49
37
  field_charset= charset_arg;
50
38
  if (charset_arg->state & MY_CS_BINSORT)
51
 
    flags|= BINARY_FLAG;
 
39
    flags|=BINARY_FLAG;
52
40
  field_derivation= DERIVATION_IMPLICIT;
53
41
}
54
42
 
141
129
 
142
130
  ASSERT_COLUMN_MARKED_FOR_WRITE;
143
131
 
144
 
  length= internal::my_gcvt(nr, internal::MY_GCVT_ARG_DOUBLE, local_char_length, buff, &error);
 
132
  length= my_gcvt(nr, MY_GCVT_ARG_DOUBLE, local_char_length, buff, &error);
145
133
  if (error)
146
134
  {
147
135
    if (table->in_use->abort_on_warning)
152
140
  return store(buff, length, charset());
153
141
}
154
142
 
 
143
/* If one of the fields is binary and the other one isn't return 1 else 0 */
 
144
 
 
145
bool Field_str::compare_str_field_flags(CreateField *new_field_ptr,
 
146
                                        uint32_t flag_arg)
 
147
{
 
148
  return (((new_field_ptr->flags & (BINCMP_FLAG | BINARY_FLAG)) &&
 
149
          !(flag_arg & (BINCMP_FLAG | BINARY_FLAG))) ||
 
150
         (!(new_field_ptr->flags & (BINCMP_FLAG | BINARY_FLAG)) &&
 
151
          (flag_arg & (BINCMP_FLAG | BINARY_FLAG))));
 
152
}
 
153
 
 
154
 
 
155
uint32_t Field_str::is_equal(CreateField *new_field_ptr)
 
156
{
 
157
  if (compare_str_field_flags(new_field_ptr, flags))
 
158
    return 0;
 
159
 
 
160
  return ((new_field_ptr->sql_type == real_type()) &&
 
161
          new_field_ptr->charset == field_charset &&
 
162
          new_field_ptr->length == max_display_length());
 
163
}
 
164
 
155
165
 
156
166
bool check_string_copy_error(Field_str *field,
157
167
                             const char *well_formed_error_pos,
190
200
    {
191
201
      *t++= '\\';
192
202
      *t++= 'x';
193
 
      *t++= internal::_dig_vec_upper[((unsigned char) *pos) >> 4];
194
 
      *t++= internal::_dig_vec_upper[((unsigned char) *pos) & 15];
 
203
      *t++= _dig_vec_upper[((unsigned char) *pos) >> 4];
 
204
      *t++= _dig_vec_upper[((unsigned char) *pos) & 15];
195
205
    }
196
206
  }
197
207
  if (end_orig > end)
217
227
  return field_length + (field_length > 255 ? 2 : 1);
218
228
}
219
229
 
220
 
} /* namespace drizzled */