~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/decimal.cc

  • Committer: Stewart Smith
  • Date: 2010-06-16 14:23:07 UTC
  • mto: (1626.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 1633.
  • Revision ID: stewart@flamingspork.com-20100616142307-xzid4yzriltwu6tt
add basic test for Handler_update status variable

Show diffs side-by-side

added added

removed removed

Lines of Context:
124
124
 
125
125
bool Field_decimal::store_value(const my_decimal *decimal_value)
126
126
{
127
 
  int error= my_decimal2binary(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW,
128
 
                                         decimal_value, ptr, precision, dec);
129
 
  if (warn_if_overflow(error))
 
127
  int error= 0;
 
128
 
 
129
  if (warn_if_overflow(my_decimal2binary(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW,
 
130
                                         decimal_value, ptr, precision, dec)))
130
131
  {
131
 
    if (error != E_DEC_TRUNCATED)
132
 
    {
133
 
      my_decimal buff;
134
 
      set_value_on_overflow(&buff, decimal_value->sign());
135
 
      my_decimal2binary(E_DEC_FATAL_ERROR, &buff, ptr, precision, dec);
136
 
    }
 
132
    my_decimal buff;
 
133
    set_value_on_overflow(&buff, decimal_value->sign());
 
134
    my_decimal2binary(E_DEC_FATAL_ERROR, &buff, ptr, precision, dec);
137
135
    error= 1;
138
136
  }
139
137
  return(error);
152
150
                           ~(E_DEC_OVERFLOW | E_DEC_BAD_NUM),
153
151
                           from, length, charset_arg,
154
152
                           &decimal_value)) &&
155
 
      getTable()->in_use->abort_on_warning)
 
153
      table->in_use->abort_on_warning)
156
154
  {
157
155
    /* Because "from" is not NUL-terminated and we use %s in the ER() */
158
156
    String from_as_str;
159
157
    from_as_str.copy(from, length, &my_charset_bin);
160
158
 
161
 
    push_warning_printf(getTable()->in_use, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
 
159
    push_warning_printf(table->in_use, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
162
160
                        ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
163
161
                        ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
164
162
                        "decimal", from_as_str.c_ptr(), field_name,
165
 
                        (uint32_t) getTable()->in_use->row_count);
 
163
                        (uint32_t) table->in_use->row_count);
166
164
 
167
165
    return(err);
168
166
  }
182
180
      String from_as_str;
183
181
      from_as_str.copy(from, length, &my_charset_bin);
184
182
 
185
 
      push_warning_printf(getTable()->in_use, DRIZZLE_ERROR::WARN_LEVEL_WARN,
 
183
      push_warning_printf(table->in_use, DRIZZLE_ERROR::WARN_LEVEL_WARN,
186
184
                          ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
187
185
                          ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
188
186
                          "decimal", from_as_str.c_ptr(), field_name,
189
 
                          (uint32_t) getTable()->in_use->row_count);
 
187
                          (uint32_t) table->in_use->row_count);
190
188
      my_decimal_set_zero(&decimal_value);
191
189
 
192
190
      break;
218
216
    if (check_overflow(err))
219
217
      set_value_on_overflow(&decimal_value, decimal_value.sign());
220
218
    /* Only issue a warning if store_value doesn't issue an warning */
221
 
    getTable()->in_use->got_warning= 0;
 
219
    table->in_use->got_warning= 0;
222
220
  }
223
221
  if (store_value(&decimal_value))
224
222
    err= 1;
225
 
  else if (err && !getTable()->in_use->got_warning)
 
223
  else if (err && !table->in_use->got_warning)
226
224
    err= warn_if_overflow(err);
227
225
  return(err);
228
226
}
241
239
    if (check_overflow(err))
242
240
      set_value_on_overflow(&decimal_value, decimal_value.sign());
243
241
    /* Only issue a warning if store_value doesn't issue an warning */
244
 
    getTable()->in_use->got_warning= 0;
 
242
    table->in_use->got_warning= 0;
245
243
  }
246
244
  if (store_value(&decimal_value))
247
245
    err= 1;
248
 
  else if (err && not getTable()->in_use->got_warning)
 
246
  else if (err && !table->in_use->got_warning)
249
247
    err= warn_if_overflow(err);
250
248
  return err;
251
249
}