Bug #32477 Patch: easy fix for sybase reverse engineering bug - foreign key repeat
Submitted: 18 Nov 2007 9:53 Modified: 2 Oct 2009 19:13
Reporter: John Hettinger Email Updates:
Status: No Feedback Impact on me:
Category:MySQL Migration Toolkit Severity:S3 (Non-critical)
Version:ReverseEngineeringSybase.java v1.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: CHECKED, Contribution

[18 Nov 2007 9:53] John Hettinger
When reverse engineering a sybase table in the function reverseEngineerTableFKs (in the file ReverseEngineeringSybase.java), any foreign key constraint with two or more fields will repeat the first field in both field lists (that table's foreign key field list and the referenced table's primary key field list).  This is due to the fkColumnPos variable not being incremented until after the field names have been assigned to variables the second time.

How to repeat:
Use the migration toolkit to convert a sybase database that contains at least one table having a foreign key constraint with two or more fields.  Make sure that table is converted and look at the mysql code generated, the foreign key constraint will repeat the first field in both lists (that table's foreign key field list and the referenced table's primary key field list).  This sql statement will not work for obvious reasons.

Suggested fix:
Remove the post assignment unary addition in the second field name assignment within the foreign key field name loop in the function reverseEngineerTableFKs.  Add an increment to the variable fkColumnPos before the variable assignments.  Code snippets from the file ReverseEngineeringSybase.java:

// before, this causes the bug
refColumnName = rset.getString(fkColumnPos + 16);
fkColumnName = rset.getString(fkColumnPos++);

// after, this fixes the bug
refColumnName = rset.getString(fkColumnPos + 16);
fkColumnName = rset.getString(fkColumnPos);
[20 Nov 2007 16:53] MySQL Verification Team
Thank you for the bug report and contribution.
[8 Jun 2009 22:31] liz drachnik
Hello John - 

In order for us to continue the process of reviewing your contribution to MySQL - We need you to review and sign the Sun|MySQL contributor agreement (the "SCA")

The process is explained here: 

Getting a signed/approved SCA on file will help us facilitate your contribution-- this one, and others in the future.

Thank you ! 

Liz Drachnik  - Program Manager - MySQL
[2 Oct 2009 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".