pt-table-checksum to handle different floating notation in 5.1, 5.5

Registered by Shlomi Noach

Following up on Sheer's post:
 http://blog.mozilla.org/it/2013/01/17/mysql-5-1-vs-mysql-5-5-floats-doubles-and-scientific-notation/

MySQL 5.1 uses scientific notation for small FLOAT/DOUBLE values, while 5.5 uses normal notation. I.e., consider the following:

create table tf(f float);
insert into tf values(0.0000958084);
select * from tf;

In 5.1:
+-------------+
| f |
+-------------+
| 9.58084e-05 |
+-------------+

in 5.5:
+--------------+
| f |
+--------------+
| 0.0000958084 |
+--------------+

This is for small numbers (obviously < 1)
I suggest that the --float-precision is expanded in the following way:
sub get_checksum_columns {
...
         elsif ( $float_precision && $type =~ m/float|double/ ) {
            $result = "ROUND(IF($result BETWEEN -1 AND 1, CAST($result AS DECIMAL(65,30)), $result), $float_precision)";
         }

Thus, for smaller numbers, the CAST to DECIMAL normalizes the number and displays in non-scientific format on all versions.

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
None
Direction:
Needs approval
Assignee:
None
Definition:
New
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.