Bug #48903 Slave performs statement for decimal column with size less than on master
Submitted: 19 Nov 2009 13:22 Modified: 7 Nov 2015 8:13
Reporter: Serge Kozlov Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Row Based Replication ( RBR ) Severity:S3 (Non-critical)
Version:5.1-rep+3 OS:Any
Assigned to: Andrei Elkin CPU Architecture:Any
Tags: decimal, error 1535, size, slave

[19 Nov 2009 13:22] Serge Kozlov
Description:
There is master and slave. Master and slave have same table with decimal column but with difference for floating parts: size on slave greater than on master. Total size are equal. The slave should stop with error 1535 if get a data for the table but SQL thread just truncates it.

How to repeat:
The master has following table:
CREATE TABLE t1 (a DECIMAL(9,3));

We change the definition of that table on slave (parameters of DECIMAL column), insert a data on master into the table and check results.

Case 1: OK
SLAVE: ALTER TABLE t1 CHANGE a a DECIMAL(9,2);
MASTER: INSERT INTO t1 VALUES(-123456.123), (654321.456);
SLAVE: Error 1535. Table definition on master and slave does not match: Column 0 size mismatch - master has size 5, test.t1 on slave has size 5. Master's column size should be <= the slave's column size.

Case 2: OK 
SLAVE: ALTER TABLE t1 CHANGE a a DECIMAL(8,3);
MASTER: INSERT INTO t1 VALUES(-123456.123), (654321.456);
SLAVE: Error 1535. Table definition on master and slave does not match: Column 0 size mismatch - master has size 5, test.t1 on slave has size 5. Master's column size should be <= the slave's column size.

Case 3: NOT OK
SLAVE: ALTER TABLE t1 CHANGE a a DECIMAL(9,4);
MASTER: INSERT INTO t1 VALUES(-123456.123), (654321.456);
SLAVE: SELECT * FROM t1 ORDER BY a;
a
-23456.1230
54321.4560

Decimal column has format DECIMAL(M, N). Seems the slave just check absolute values of decimal column M and N but really need to check (M-N) and N.

Suggested fix:
The slave should control the size of integer part of decimal values but not total size.
[29 Nov 2009 19:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/92012

364 Serge Kozlov	2009-11-29
      1. Test cases for bugs: bug#48815, bug#48819, bug#48845, bug#48903, bug#48908
      2. Added sorting test cases by their file names.
      3. Added test template Replication.pm
      added:
        lib/My/Nuts/Library/Tests/Replication.pm
        suites/bugs/
        suites/bugs/bug48815.pm
        suites/bugs/bug48819.pm
        suites/bugs/bug48845.pm
        suites/bugs/bug48903.pm
        suites/bugs/bug48908.pm
      modified:
        bin/Driver.pm
[28 Dec 2009 21:07] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/95765

365 Serge Kozlov	2009-12-29
      1. Test cases for bugs: bug#48815, bug#48819, bug#48845, bug#48903, bug#48908
      2. Added sorting test cases by their file names.
      3. Added test template Replication.pm
      added:
        lib/My/Nuts/Library/Tests/Replication.pm
        suites/bugs/
        suites/bugs/bug48815.pm
        suites/bugs/bug48819.pm
        suites/bugs/bug48845.pm
        suites/bugs/bug48903.pm
        suites/bugs/bug48908.pm
      modified:
        bin/Driver.pm