Bug #29339 Warning 1265 'Data truncated' incorrectly worded
Submitted: 25 Jun 2007 14:36 Modified: 27 Jun 2007 14:04
Reporter: Peter Belm Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Errors Severity:S4 (Feature request)
Version:5.0.41 OS:Any
Assigned to: CPU Architecture:Any

[25 Jun 2007 14:36] Peter Belm
Description:
The data truncated warning is correct for an instance where numbers are actually truncated to fit the columns value type, however if you use an number for an enum column it gives this warning, even though no data is truncated.

How to repeat:
CREATE TABLE  `test_table` (
  `test` enum('0','1') NOT NULL default '0'
);

INSERT INTO `test_table` VALUES(0);

Suggested fix:
Either split the warnings into two warnings with only data that is actually truncated coming under the 1265 warning, and a second one as below:

Or reword the warning to something along the lines of "Data altered to fit column type"
[25 Jun 2007 15:03] MySQL Verification Team
Thank you for the bug report.
[27 Jun 2007 13:01] Sergei Golubchik
The warning is correct. INSERT INTO `test_table` VALUES(0) is treated exactly the same as INSERT INTO `test_table` VALUES('foobar') - both insert values outside of the ENUM set. Try to select from the table to see. ENUM elements are numbered from 1, not from 0. If you do INSERT INTO `test_table` VALUES(1) or INSERT INTO `test_table` VALUES(2) - there will be no warning.
[27 Jun 2007 14:00] Peter Belm
I'm not saying that the reason the warning is coming up is a bug, but that the warning itself is worded incorrectly in some instances (hence the severity of "Feature request"). Turning an integer 0 into a string '0' is not truncation.

This wording can be very confusing if this is the first time you've seen the error. It should be made clear that the data was automatically altered rather than assuming the data was "truncated" (I assume this was originally created for cutting off decimal digits, in that particular case truncation is the correct term).
[27 Jun 2007 14:04] Peter Belm
Sorry I re-read your comment, while I understood the way MySQL enumerates I assumed it was trying to do an automatic type conversion.

Set back to Not a Bug.