~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/field/str.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <drizzled/session.h>
27
27
#include <drizzled/internal/m_string.h>
28
28
 
29
 
namespace drizzled
30
 
{
 
29
namespace drizzled {
31
30
 
32
31
namespace internal
33
32
{
34
 
extern char _dig_vec_upper[];
 
33
  extern char _dig_vec_upper[];
35
34
}
36
35
 
37
36
Field_str::Field_str(unsigned char *ptr_arg,
39
38
                     unsigned char *null_ptr_arg,
40
39
                     unsigned char null_bit_arg,
41
40
                     const char *field_name_arg,
42
 
                     const CHARSET_INFO * const charset_arg)
 
41
                     const charset_info_st * const charset_arg)
43
42
  :Field(ptr_arg, len_arg,
44
43
         null_ptr_arg,
45
44
         null_bit_arg,
70
69
    send a truncation note, otherwise send a truncation error.
71
70
*/
72
71
 
73
 
int
74
 
Field_str::report_if_important_data(const char *field_ptr, const char *end)
 
72
int Field_str::report_if_important_data(const char *field_ptr, const char *end)
75
73
{
76
 
  if ((field_ptr < end) && getTable()->in_use->count_cuted_fields)
 
74
  if (field_ptr < end && getTable()->in_use->count_cuted_fields)
77
75
  {
78
76
    set_warning(DRIZZLE_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
79
 
 
80
77
    return 2;
81
78
  }
82
79
  return 0;
112
109
 
113
110
type::Decimal *Field_str::val_decimal(type::Decimal *decimal_value) const
114
111
{
115
 
  int64_t nr= val_int();
116
 
  int2_class_decimal(E_DEC_FATAL_ERROR, nr, 0, decimal_value);
 
112
  int2_class_decimal(E_DEC_FATAL_ERROR, val_int(), 0, decimal_value);
117
113
  return decimal_value;
118
114
}
119
115
 
129
125
{
130
126
  char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
131
127
  uint32_t local_char_length= field_length / charset()->mbmaxlen;
132
 
  size_t length;
133
128
  bool error;
134
129
 
135
130
  ASSERT_COLUMN_MARKED_FOR_WRITE;
136
131
 
137
 
  length= internal::my_gcvt(nr, internal::MY_GCVT_ARG_DOUBLE, local_char_length, buff, &error);
 
132
  size_t length= internal::my_gcvt(nr, internal::MY_GCVT_ARG_DOUBLE, local_char_length, buff, &error);
138
133
  if (error)
139
134
  {
140
135
    if (getTable()->getSession()->abortOnWarning())
154
149
                             const char *well_formed_error_pos,
155
150
                             const char *cannot_convert_error_pos,
156
151
                             const char *end,
157
 
                             const CHARSET_INFO * const cs)
 
152
                             const charset_info_st * const cs)
158
153
{
159
 
  const char *pos, *end_orig;
160
 
  char tmp[64], *t;
161
 
 
162
 
  if (!(pos= well_formed_error_pos) &&
163
 
      !(pos= cannot_convert_error_pos))
 
154
  const char* pos= well_formed_error_pos;
 
155
  if (not pos && not (pos= cannot_convert_error_pos))
164
156
    return false;
165
157
 
166
 
  end_orig= end;
 
158
  const char* end_orig= end;
167
159
  set_if_smaller(end, pos + 6);
168
160
 
169
 
  for (t= tmp; pos < end; pos++)
 
161
  char tmp[64];
 
162
  char* t= tmp;
 
163
  for (; pos < end; pos++)
170
164
  {
171
165
    /*
172
166
      If the source string is ASCII compatible (mbminlen==1)
177
171
      or the source character is not in the printable range,
178
172
      then print the character using HEX notation.
179
173
    */
180
 
    if (((unsigned char) *pos) >= 0x20 &&
181
 
        ((unsigned char) *pos) <= 0x7F &&
182
 
        cs->mbminlen == 1)
 
174
    if (((unsigned char) *pos) >= 0x20 && ((unsigned char) *pos) <= 0x7F && cs->mbminlen == 1)
183
175
    {
184
176
      *t++= *pos;
185
177
    }
199
191
  }
200
192
  *t= '\0';
201
193
  push_warning_printf(field->getTable()->in_use,
202
 
                      field->getTable()->in_use->abortOnWarning() ?
203
 
                      DRIZZLE_ERROR::WARN_LEVEL_ERROR :
204
 
                      DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
194
                      field->getTable()->in_use->abortOnWarning() ? DRIZZLE_ERROR::WARN_LEVEL_ERROR : DRIZZLE_ERROR::WARN_LEVEL_WARN,
205
195
                      ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
206
196
                      ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
207
197
                      "string", tmp, field->field_name,