March 29, 2009

No warnings while rounding?!!

MySQL does truncate the value that you are trying to insert so that it can be accommodated by the given data type. For e.g. if you have a varchar(5) column type, the first 5 characters are inserted and rest are trimmed. The same applies to the numeric values as well. If I try to insert any value that is bigger than 126 in a tinyint declared column, it will always insert the max allowed value i.e. 126
MySQL will throw a warning when it does this extra work of validating and truncating data before adding the record into the table. But when it comes to inserting decimal values into an integer column, it rounds the value to the nearest integer WITHOUT any warning!!

http://bugs.mysql.com/bug.php?id=43930

This has been filed under feature request but I guess it should be declared as a bug with high severity.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.