~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/str.cc

Merge Stewart.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
int
74
74
Field_str::report_if_important_data(const char *field_ptr, const char *end)
75
75
{
76
 
  if ((field_ptr < end) && getTable()->in_use->count_cuted_fields)
 
76
  if ((field_ptr < end) && table->in_use->count_cuted_fields)
77
77
  {
78
 
    set_warning(DRIZZLE_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
79
 
 
 
78
    if (test_if_important_data(field_charset, field_ptr, end))
 
79
    {
 
80
      if (table->in_use->abort_on_warning)
 
81
        set_warning(DRIZZLE_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
 
82
      else
 
83
        set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
 
84
    }
 
85
    else /* If we lost only spaces then produce a NOTE, not a WARNING */
 
86
      set_warning(DRIZZLE_ERROR::WARN_LEVEL_NOTE, ER_WARN_DATA_TRUNCATED, 1);
80
87
    return 2;
81
88
  }
82
89
  return 0;
102
109
    !=0  error
103
110
*/
104
111
 
105
 
int Field_str::store_decimal(const type::Decimal *d)
 
112
int Field_str::store_decimal(const my_decimal *d)
106
113
{
107
114
  char buff[DECIMAL_MAX_STR_LENGTH+1];
108
115
  String str(buff, sizeof(buff), &my_charset_bin);
109
 
  class_decimal2string(d, 0, &str);
 
116
  my_decimal2string(E_DEC_FATAL_ERROR, d, 0, 0, 0, &str);
110
117
  return store(str.ptr(), str.length(), str.charset());
111
118
}
112
119
 
113
 
type::Decimal *Field_str::val_decimal(type::Decimal *decimal_value)
 
120
my_decimal *Field_str::val_decimal(my_decimal *decimal_value)
114
121
{
115
122
  int64_t nr= val_int();
116
 
  int2_class_decimal(E_DEC_FATAL_ERROR, nr, 0, decimal_value);
 
123
  int2my_decimal(E_DEC_FATAL_ERROR, nr, 0, decimal_value);
117
124
  return decimal_value;
118
125
}
119
126
 
137
144
  length= internal::my_gcvt(nr, internal::MY_GCVT_ARG_DOUBLE, local_char_length, buff, &error);
138
145
  if (error)
139
146
  {
140
 
    if (getTable()->getSession()->abortOnWarning())
141
 
    {
 
147
    if (table->in_use->abort_on_warning)
142
148
      set_warning(DRIZZLE_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
143
 
    }
144
149
    else
145
 
    {
146
150
      set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
147
 
    }
148
151
  }
149
152
  return store(buff, length, charset());
150
153
}
198
201
    *t++= '.';
199
202
  }
200
203
  *t= '\0';
201
 
  push_warning_printf(field->getTable()->in_use,
202
 
                      field->getTable()->in_use->abortOnWarning() ?
 
204
  push_warning_printf(field->table->in_use,
 
205
                      field->table->in_use->abort_on_warning ?
203
206
                      DRIZZLE_ERROR::WARN_LEVEL_ERROR :
204
207
                      DRIZZLE_ERROR::WARN_LEVEL_WARN,
205
208
                      ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
206
209
                      ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
207
210
                      "string", tmp, field->field_name,
208
 
                      (uint32_t) field->getTable()->in_use->row_count);
 
211
                      (uint32_t) field->table->in_use->row_count);
209
212
  return true;
210
213
}
211
214