pt-table-checksum to handle different floating notation in 5.1, 5.5
Following up on Sheer's post:
http://
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(
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_
...
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
- Started by
- Completed by