Padraig O'Sullivan wrote: > Confirmed on trunk: > > drizzle> use test > Database changed > drizzle> create table t1 ( > -> f1 decimal not null default 17.49, > -> f2 decimal not null default 17.68, > -> f3 decimal not null default 99.2, > -> f4 decimal not null default 99.7, > -> f5 decimal not null default 104.49, > -> f6 decimal not null default 199.91, > -> f7 decimal not null default 999.9, > -> f8 decimal not null default 9999.99); > Query OK, 0 rows affected, 8 warnings (0.01 sec) > > drizzle> show warnings; > +-------+------+-----------------------------------------+ > | Level | Code | Message | > +-------+------+-----------------------------------------+ > | Note | 1265 | Data truncated for column 'f1' at row 1 | > | Note | 1265 | Data truncated for column 'f2' at row 1 | > | Note | 1265 | Data truncated for column 'f3' at row 1 | > | Note | 1265 | Data truncated for column 'f4' at row 1 | > | Note | 1265 | Data truncated for column 'f5' at row 1 | > | Note | 1265 | Data truncated for column 'f6' at row 1 | > | Note | 1265 | Data truncated for column 'f7' at row 1 | > | Note | 1265 | Data truncated for column 'f8' at row 1 | > +-------+------+-----------------------------------------+ > 8 rows in set (0.00 sec) > > drizzle> > > Just looking at the relevant code for this in drizzled/field/decimal.cc > at the Field_new_decimal::store() method, it seems that only warnings > are ever issued with these types - an error is never printed. The > relevant code is: > > switch (err) { > case E_DEC_TRUNCATED: > set_warning(DRIZZLE_ERROR::WARN_LEVEL_NOTE, ER_WARN_DATA_TRUNCATED, 1); > break; > case E_DEC_OVERFLOW: > set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); > set_value_on_overflow(&decimal_value, decimal_value.sign()); > break; > case E_DEC_BAD_NUM: > { > /* Because "from" is not NUL-terminated and we use %s in the ER() */ > String from_as_str; > from_as_str.copy(from, length, &my_charset_bin); > > push_warning_printf(table->in_use, DRIZZLE_ERROR::WARN_LEVEL_WARN, > ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, > ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD), > "decimal", from_as_str.c_ptr(), field_name, > (uint32_t) table->in_use->row_count); > my_decimal_set_zero(&decimal_value); > > break; > } > > Should overflow also be an error here?
Yes. I think so. We've decided that Drizzle should always error on data issues.
Monty
Padraig O'Sullivan wrote: -+----- -+----- ------- ------- ------- ------- ------- -+ -+----- -+----- ------- ------- ------- ------- ------- -+ -+----- -+----- ------- ------- ------- ------- ------- -+ field/decimal. cc decimal: :store( ) method, it seems that only warnings DRIZZLE_ ERROR:: WARN_LEVEL_ NOTE, ER_WARN_ DATA_TRUNCATED, 1); DRIZZLE_ ERROR:: WARN_LEVEL_ WARN, ER_WARN_ DATA_OUT_ OF_RANGE, 1); on_overflow( &decimal_ value, decimal_ value.sign( )); str.copy( from, length, &my_charset_bin); printf( table-> in_use, DRIZZLE_ ERROR:: WARN_LEVEL_ WARN, WRONG_VALUE_ FOR_FIELD, _WRONG_ VALUE_FOR_ FIELD), str.c_ptr( ), field_name, in_use- >row_count) ; set_zero( &decimal_ value);
> Confirmed on trunk:
>
> drizzle> use test
> Database changed
> drizzle> create table t1 (
> -> f1 decimal not null default 17.49,
> -> f2 decimal not null default 17.68,
> -> f3 decimal not null default 99.2,
> -> f4 decimal not null default 99.7,
> -> f5 decimal not null default 104.49,
> -> f6 decimal not null default 199.91,
> -> f7 decimal not null default 999.9,
> -> f8 decimal not null default 9999.99);
> Query OK, 0 rows affected, 8 warnings (0.01 sec)
>
> drizzle> show warnings;
> +------
> | Level | Code | Message |
> +------
> | Note | 1265 | Data truncated for column 'f1' at row 1 |
> | Note | 1265 | Data truncated for column 'f2' at row 1 |
> | Note | 1265 | Data truncated for column 'f3' at row 1 |
> | Note | 1265 | Data truncated for column 'f4' at row 1 |
> | Note | 1265 | Data truncated for column 'f5' at row 1 |
> | Note | 1265 | Data truncated for column 'f6' at row 1 |
> | Note | 1265 | Data truncated for column 'f7' at row 1 |
> | Note | 1265 | Data truncated for column 'f8' at row 1 |
> +------
> 8 rows in set (0.00 sec)
>
> drizzle>
>
> Just looking at the relevant code for this in drizzled/
> at the Field_new_
> are ever issued with these types - an error is never printed. The
> relevant code is:
>
> switch (err) {
> case E_DEC_TRUNCATED:
> set_warning(
> break;
> case E_DEC_OVERFLOW:
> set_warning(
> set_value_
> break;
> case E_DEC_BAD_NUM:
> {
> /* Because "from" is not NUL-terminated and we use %s in the ER() */
> String from_as_str;
> from_as_
>
> push_warning_
> ER_TRUNCATED_
> ER(ER_TRUNCATED
> "decimal", from_as_
> (uint32_t) table->
> my_decimal_
>
> break;
> }
>
> Should overflow also be an error here?
Yes. I think so. We've decided that Drizzle should always error on data
issues.
Monty