[MDEV-10125] Altering decimal column on a TokuDB table can corrupt data Created: 2016-05-25  Updated: 2018-01-01

Status: Confirmed
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Storage Engine - TokuDB
Affects Version/s: 10.1.14
Fix Version/s: 10.1

Type: Bug Priority: Major
Reporter: Jeff Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: upstream
Environment:

centos 7



 Description   

When changing a decimal column's scale but not precision on a tokudb column (and keeping everything else the same) the column's data can be corrupted.

NB Changing NULL/NOT NULL, SIGNED/UNSIGNED or decimal precision will all result in things working properly.

Here's a test case that can reproduce the problem:

create table dec_test( 
	val decimal(9,2) NOT NULL
) ENGINE = TOKUDB;
 
INSERT INTO `dec_test` VALUES (0);
INSERT INTO `dec_test` VALUES (10);
INSERT INTO `dec_test` VALUES (20);
 
ALTER TABLE `dec_test` CHANGE COLUMN `val` `val` DECIMAL(9,4) NOT NULL; 
 
select  * from dec_test;



 Comments   
Comment by Elena Stepanova [ 2016-05-27 ]

Same happens with Percona server (tried 5.6.29):

MySQL [test]> create table dec_test( 
    -> val decimal(9,2) NOT NULL
    -> ) ENGINE = TOKUDB;
Query OK, 0 rows affected (0.07 sec)
 
MySQL [test]>  
MySQL [test]> INSERT INTO `dec_test` VALUES (0);
Query OK, 1 row affected (0.00 sec)
 
MySQL [test]> INSERT INTO `dec_test` VALUES (10);
Query OK, 1 row affected (0.01 sec)
 
MySQL [test]> INSERT INTO `dec_test` VALUES (20);
Query OK, 1 row affected (0.00 sec)
 
MySQL [test]>  
MySQL [test]> ALTER TABLE `dec_test` CHANGE COLUMN `val` `val` DECIMAL(9,4) NOT NULL; 
Query OK, 0 rows affected (0.03 sec)
Records: 0  Duplicates: 0  Warnings: 0

MySQL [test]> select  * from dec_test;
+--------+
| val    |
+--------+
| 0.0000 |
| 0.2560 |
| 0.5120 |
+--------+
3 rows in set (0.00 sec)
 
MySQL [test]> select @@version, @@version_comment;
+-------------+---------------------+
| @@version   | @@version_comment   |
+-------------+---------------------+
| 5.6.29-76.2 | Source distribution |
+-------------+---------------------+
1 row in set (0.00 sec)

jeffscott2,
Did you also report the problem to Percona (the current TokuDB owner), and if not, are you planning to?

Comment by Jeff [ 2016-06-07 ]

I found a similar bug report at percona which is currently Triaged
https://bugs.launchpad.net/percona-server/+bug/1547211

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