[MDEV-8502] DECIMAL accepts out of range DEFAULT values Created: 2015-07-20  Updated: 2016-06-27  Resolved: 2016-06-27

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 5.5, 10.0, 10.1
Fix Version/s: 10.1.15

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None


 Description   

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT 10000.1);

correctly returns:

+---------+------+--------------------------------------------+
| Level   | Code | Message                                    |
+---------+------+--------------------------------------------+
| Warning | 1264 | Out of range value for column 'a' at row 1 |
| Error   | 1067 | Invalid default value for 'a'              |
+---------+------+--------------------------------------------+

A similar script with a quoted default value:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a DECIMAL(2,1) DEFAULT '10000.1');

Does not produce an error.

The default value is adjusted to the data type range:

SHOW CREATE TABLE t1; +-------+---------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                |
+-------+---------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `a` decimal(2,1) DEFAULT '9.9'
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+---------------------------------------------------------------------------------------------+



 Comments   
Comment by Sergei Golubchik [ 2016-06-27 ]

ok to push

Generated at Thu Feb 08 07:27:38 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.