Bug #82809 mysqldbcompare output error SQL when 2 tables having different primary keys
Submitted: 31 Aug 2016 7:20 Modified: 10 Sep 2016 9:37
Reporter: CB CB Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Utilities Severity:S3 (Non-critical)
Version:1.6.4 OS:Red Hat
Assigned to: CPU Architecture:Any
Tags: mysqldbcompre, primary key

[31 Aug 2016 7:20] CB CB
Description:
assume 2 tables, db1.TableA has primary key(Key1), db2.TableA has primary key(Key1, Key2).

i use mysqldbcompare to generate the SQL statements for data transformations to make db1.TableA the same as db2.TableA.

the output is :
ALTER TABLE db1.Table1 ADD PRIMARY KEY(Key2)

i think "DROP PRIMARY KEY" is omitted.
i think the output should be "ALTER TABLE db1.Table1 DROP PRIMARY KEY, ADD PRIMARY KEY(Key2)"

Another problem:
To generate the SQL statements for data transformations to make db1.TableA the same as db2.TableA, i need to run mysqldbcompare 3 times: 
1. drop primary key(i think omitted) , add primary key(Key2)
2. drop primary key , add primary key(Key1,Key2)
3. insert delete update SQLs
Can i complete in 1 time: drop primary key, add primary key(Key1,Key2), insert delete update SQLs?

How to repeat:
create 2 tables, db1.TableA has primary key(Key1), db2.TableA has primary key(Key1, Key2), and input some records, then run mysqldbcompare --difftype=sql

Suggested fix:
sql_transform.py  _get_indexes:
1. before "Generate DROP index clauses", if 2 tables has different primary keys and dest has more than 0 primary key, drop_indexes.append("  DROP PRIMARY KEY").
2. in "Generate DROP index clauses" , if index[2] == "PRIMARY": pass
[10 Sep 2016 9:37] Umesh Shastry
Hello!

Thank you for the report.

Thanks,
Umesh