CONCAT() and numeric arguments
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
# rpm -q percona-toolkit
percona-
pt-table-checksum gives me false diffs and I think it's because of changed behaviour of CONCAT()
I have a master with MySQL 5.1 and a slave with MariaDB 5.5
...
mysql> select CRC32(concat(
*******
CRC32(concat(
1 row in set (0.00 sec)
...
...
MariaDB [rolloutdb]> select CRC32(concat(
*******
CRC32(concat(
1 row in set (0.00 sec)
...
please note that the checksum of single fields is the same but the checksum of the 3 fields concatenated differs.
The MySQL manual tells
http://
...
Returns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are nonbinary strings, the result is a nonbinary string. If the arguments include any binary strings, the result is a binary string. A numeric argument is converted to its equivalent string form. This is a nonbinary string as of MySQL 5.5.3. Before 5.5.3, it is a binary string; to avoid that and produce a nonbinary string, you can use an explicit type cast
...
Please see attached my attempt for a fix for pt-table-checksum. My idea basically was to enforce a binary string by casting concat_ws separator to binary. Maybe other tools needs a fix too, pt-table-sync for instance
Markus,
Is that possible for you to provide the data content for this row? Also do you get inconsistent crc32(concat()) values on other rows? I am asking because I didn't reproduce this problem in my test.
Master: PS 5.1.71rel14.9-log
Slave1: PS 5.5.36-34.2-rel34.2
Slave2: 5.5.40-MariaDB
Data:
> select * from t1 where id = 14\G
id: 14
name: percona
address: 400 West Main Street, Suite 204, Post Office Box 1126, Durham, North Carolina 27702 USA
Master > select CRC32(concat( name)), CRC32(concat( id)),CRC32( concat( address) ),CRC32( concat( id,name, address) ) from t1 where id=14\G ******* ******* ****** 1. row ******* ******* ******* ******
CRC32( concat( name)): 33349892
CRC32( concat( id)): 2788221432
CRC32( concat( address) ): 2013723334 id,name, address) ): 2614596401
*******
CRC32(concat(
Slave1 > select CRC32(concat( name)), CRC32(concat( id)),CRC32( concat( address) ),CRC32( concat( id,name, address) ) from t1 where id=14\G ******* ******* ****** 1. row ******* ******* ******* ******
CRC32( concat( name)): 33349892
CRC32( concat( id)): 2788221432
CRC32( concat( address) ): 2013723334 id,name, address) ): 2614596401
*******
CRC32(concat(
Slave2 > select CRC32(concat( name)), CRC32(concat( id)),CRC32( concat( address) ),CRC32( concat( id,name, address) ) from t1 where id=14\G ******* ******* ****** 1. row ******* ******* ******* ******
CRC32( concat( name)): 33349892
CRC32( concat( id)): 2788221432
CRC32( concat( address) ): 2013723334 id,name, address) ): 2614596401
*******
CRC32(concat(