[MDEV-22503] MDB limits DECIMAL column precision to 16 doing CTAS with floor/ceil over DECIMAL(X,Y) where X > 16 Created: 2020-05-08  Updated: 2020-05-14  Resolved: 2020-05-14

Status: Closed
Project: MariaDB Server
Component/s: Data types
Affects Version/s: 10.0, 10.1, 10.2, 10.3, 10.4, 10.5
Fix Version/s: 10.5.4, 10.1.46, 10.2.33, 10.3.24, 10.4.14

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

Issue Links:
Relates
relates to MCOL-641 Full DECIMAL support in ColumnStore Closed

 Description   

MDB limits DECIMAL column precision to 16 doing CTAS with floor/ceil over DECIMAL(X,Y) where X > 16.

Consider the example.

MariaDB [test]> CREATE TABLE `t44` (`d1` decimal(38,0) DEFAULT NULL);
ERROR 1050 (42S01): Table 't44' already exists
MariaDB [test]> drop table t44;
Query OK, 0 rows affected (0.008 sec)
 
MariaDB [test]> CREATE TABLE `t44` (`d1` decimal(38,0) DEFAULT NULL);
Query OK, 0 rows affected (0.014 sec)
 
MariaDB [test]> create table t45 as select floor(d1) from t44;
Query OK, 0 rows affected (0.017 sec)
Records: 0  Duplicates: 0  Warnings: 0
 
MariaDB [test]> show create table t45;
+-------+------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                         |
+-------+------------------------------------------------------------------------------------------------------+
| t45   | CREATE TABLE `t45` (
  `floor(d1)` decimal(16,0) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+------------------------------------------------------------------------------------------------------+
1 row in set (0.001 sec)
 
MariaDB [test]> insert into t44 values (12345678901234567890123456789012345678);
Query OK, 1 row affected (0.006 sec)
 
MariaDB [test]> select floor(d1) from t44;
+----------------------------------------+
| floor(d1)                              |
+----------------------------------------+
| 12345678901234567890123456789012345678 |
+----------------------------------------+
1 row in set (0.002 sec)
 
MariaDB [test]> drop table t45;
Query OK, 0 rows affected (0.009 sec)
 
MariaDB [test]> create table t45 as select floor(d1) from t44;
ERROR 1264 (22003): Out of range value for column 'floor(d1)' at row 1



 Comments   
Comment by Alexander Barkov [ 2020-05-13 ]

Reproducible with all versions starting from at least 10.0:

CREATE OR REPLACE TABLE t1 (d1 decimal(38,0) DEFAULT NULL);
CREATE OR REPLACE TABLE t2 AS SELECT floor(d1) FROM t1;
SHOW CREATE TABLE t2;

+-------+-----------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                        |
+-------+-----------------------------------------------------------------------------------------------------+
| t2    | CREATE TABLE `t2` (
  `floor(d1)` decimal(16,0) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+-------+-----------------------------------------------------------------------------------------------------+

Generated at Thu Feb 08 09:15:13 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.