DBD::mysql bug causes pt-upgrade to use wrong precision (M) and scale (D)

Bug #926598 reported by Ovais Tariq
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Fix Released
Medium
Daniel Nichter

Bug Description

The function that parses the result set to generate table structure used for comparing rows does not return the correct column definition for double/float data types. The definition of double/float column is returned as float|double(SCALE, PRECISION), while it should be float|double(PRECISION, SCALE).

In the following assignment:

$struct->{size}->{$col}
         = ($type =~ m/(?:float|double)/) ? "($s[$i],$p[$i])"
         : ($type =~ m/(?:decimal)/) ? "($p[$i],$s[$i])"
         : ($type =~ m/(?:char|varchar)/ && $p[$i]) ? "($p[$i])"

The line
= ($type =~ m/(?:float|double)/) ? "($s[$i],$p[$i])"

should be changed to
= ($type =~ m/(?:float|double)/) ? "($p[$i],$s[$i])"

Related branches

Changed in percona-toolkit:
assignee: nobody → Daniel Nichter (daniel-nichter)
importance: Undecided → Medium
status: New → In Progress
tags: added: pt-upgrade wrong-sql
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

I think this a DBD::mysql bug or oddity because the code works as-is. You're correct, in theory, it should be (p,s) because according to http://dev.mysql.com/doc/refman/5.1/en/precision-math-decimal-changes.html p=m=precision and s=d=scale. Yet, on DBD::mysql 4.018 the results for two tests using a double column are correct: (7,2) and (31,23). Yet, on the same version of DBD::mysql, the order is correct for decimal types, (p,s), which again is tested and produces (31,12).

tags: added: percona-21471
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

Key points from a conversation wit Ovais and Baron:

1. DBD::mysql has either one of two bugs: 1) it's scale and precicions are backwards for float|double, or 2) it produces values that are out of range. We don't know which is the case.

2. We can just ignore scale and precision altogether and create "col double" instead of "col double(m, d)".

tags: added: dbd-mysql
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

See also bug 928271.

Changed in percona-toolkit:
milestone: none → 2.0.4
summary: - pt-upgrade: invalid column definition of float|double datatype in
- function MockSyncStream::get_result_set_struct
+ DBD::mysql bug causes pt-upgrade to use wrong precision (M) and scale
+ (D)
Changed in percona-toolkit:
status: In Progress → Fix Committed
Changed in percona-toolkit:
status: Fix Committed → Triaged
Changed in percona-toolkit:
status: Triaged → In Progress
Changed in percona-toolkit:
status: In Progress → Fix Committed
Changed in percona-toolkit:
status: Fix Committed → Fix Released
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PT-462

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.