Activity log for bug #337038

Date Who What changed Old value New value Message
2009-03-03 02:26:16 Stewart Smith bug added bug
2009-03-03 02:26:32 Stewart Smith drizzle: importance Undecided High
2009-03-03 02:26:32 Stewart Smith drizzle: statusexplanation
2009-03-03 02:26:32 Stewart Smith drizzle: milestone cirrus
2009-03-03 03:08:46 Padraig O'Sullivan drizzle: status New Confirmed
2009-03-03 03:08:46 Padraig O'Sullivan drizzle: statusexplanation 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?
2009-03-04 04:20:26 Padraig O'Sullivan drizzle: status Confirmed In Progress
2009-03-04 04:20:26 Padraig O'Sullivan drizzle: assignee posulliv
2009-03-04 04:20:26 Padraig O'Sullivan drizzle: statusexplanation 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? Ok, so now the behavior is as follows: 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); ERROR 1067 (42000): Invalid default value for 'f1' drizzle> show warnings; +---------+------+-----------------------------------------+ | Level | Code | Message | +---------+------+-----------------------------------------+ | Warning | 1265 | Data truncated for column 'f1' at row 1 | | Error | 1067 | Invalid default value for 'f1' | +---------+------+-----------------------------------------+ 2 rows in set (0.00 sec) drizzle> I've committed this change to the branch linked to this bug. What I'm working on now is cleaning up the test cases which this fix breaks so that might take a little bit of time. A lot of test cases just expect warnings here instead of errors in this scenario...much more than I expected! -Padraig
2009-04-03 00:24:46 Padraig O'Sullivan drizzle: status In Progress Fix Committed
2009-04-08 20:14:15 Padraig O'Sullivan drizzle: status Fix Committed Fix Released