~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/str.cc

  • Committer: Brian Aker
  • Date: 2009-12-03 01:17:53 UTC
  • mto: (1237.3.2 push)
  • mto: This revision was merged to the branch mainline in revision 1238.
  • Revision ID: brian@gaz-20091203011753-159h2no5m5c5dt9b
Small cleanups, did in MERGE table only engine flag.

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
 
}
 
27
 
36
28
 
37
29
Field_str::Field_str(unsigned char *ptr_arg,
38
30
                     uint32_t len_arg,
141
133
 
142
134
  ASSERT_COLUMN_MARKED_FOR_WRITE;
143
135
 
144
 
  length= internal::my_gcvt(nr, internal::MY_GCVT_ARG_DOUBLE, local_char_length, buff, &error);
 
136
  length= my_gcvt(nr, MY_GCVT_ARG_DOUBLE, local_char_length, buff, &error);
145
137
  if (error)
146
138
  {
147
139
    if (table->in_use->abort_on_warning)
152
144
  return store(buff, length, charset());
153
145
}
154
146
 
 
147
/* If one of the fields is binary and the other one isn't return 1 else 0 */
 
148
 
 
149
bool Field_str::compare_str_field_flags(CreateField *new_field_ptr,
 
150
                                        uint32_t flag_arg)
 
151
{
 
152
  return (((new_field_ptr->flags & (BINCMP_FLAG | BINARY_FLAG)) &&
 
153
          !(flag_arg & (BINCMP_FLAG | BINARY_FLAG))) ||
 
154
         (!(new_field_ptr->flags & (BINCMP_FLAG | BINARY_FLAG)) &&
 
155
          (flag_arg & (BINCMP_FLAG | BINARY_FLAG))));
 
156
}
 
157
 
 
158
 
 
159
uint32_t Field_str::is_equal(CreateField *new_field_ptr)
 
160
{
 
161
  if (compare_str_field_flags(new_field_ptr, flags))
 
162
    return 0;
 
163
 
 
164
  return ((new_field_ptr->sql_type == real_type()) &&
 
165
          new_field_ptr->charset == field_charset &&
 
166
          new_field_ptr->length == max_display_length());
 
167
}
 
168
 
155
169
 
156
170
bool check_string_copy_error(Field_str *field,
157
171
                             const char *well_formed_error_pos,
190
204
    {
191
205
      *t++= '\\';
192
206
      *t++= 'x';
193
 
      *t++= internal::_dig_vec_upper[((unsigned char) *pos) >> 4];
194
 
      *t++= internal::_dig_vec_upper[((unsigned char) *pos) & 15];
 
207
      *t++= _dig_vec_upper[((unsigned char) *pos) >> 4];
 
208
      *t++= _dig_vec_upper[((unsigned char) *pos) & 15];
195
209
    }
196
210
  }
197
211
  if (end_orig > end)
217
231
  return field_length + (field_length > 255 ? 2 : 1);
218
232
}
219
233
 
220
 
} /* namespace drizzled */