Bug #52421 DECIMAL type given with decimals doesn't return an error.
Submitted: 28 Mar 2010 22:31 Modified: 29 Mar 2010 4:19
Reporter: Tobias Asplund Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version:5.1.32, 5.1.43 OS:Any
Assigned to: CPU Architecture:Any

[28 Mar 2010 22:31] Tobias Asplund
Description:
When using the decimal type, giving a decimal number for the datatype itself doesn't give an error - instead it rounds it to the nearest integer which can cause a hard-to-see syntax problem.

How to repeat:
mysql> create table t2 ( a decimal(5.2) );  # <-- Note the "."
Query OK, 0 rows affected (0.09 sec)

mysql> DESC t2;
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| a     | decimal(5,0) | YES  |     | NULL    |       | 
+-------+--------------+------+-----+---------+-------+
1 row in set (0.04 sec)

mysql> create table t3 ( a decimal(5,2) );    # <-- Note the ","
Query OK, 0 rows affected (0.06 sec)

mysql> DESC t3;
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| a     | decimal(5,2) | YES  |     | NULL    |       | 
+-------+--------------+------+-----+---------+-------+
1 row in set (0.03 sec)
[29 Mar 2010 4:19] Valeriy Kravchuk
Thank you for the problem report. Verified just as described:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 39
Server version: 5.1.43-community-log MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create table t2 ( a decimal(5.2) );
Query OK, 0 rows affected (2.02 sec)

mysql> show create table t2\G
*************************** 1. row ***************************
       Table: t2
Create Table: CREATE TABLE `t2` (
  `a` decimal(5,0) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.17 sec)