Subject: | issues with changing table charset/collation options |
Hi,
I've been using your excellent mysqldiff utility, but I ran into a
really small bug. If the charset/collation value for a table changes,
the charset for fields are not altered if they match the table's
original setting, because they are left blank in that case.
So if I have a table with CHARSET=latin1 that I change to CHARSET=utf8
and I also change a couple of fields (say a VarChar to Char), mysqldiff
will make the field changes first, then the table changes. This means
that the fields will be left in latin1. The exact example that I ran
into this on is:
ALTER TABLE `ITEM_VALUE` CHANGE COLUMN `UID` `UID` char(12) NOT NULL; #
was varchar(12) NOT NULL
ALTER TABLE `ITEM_VALUE` ENGINE=MyISAM DEFAULT CHARSET=utf8; # was
ENGINE=MyISAM DEFAULT CHARSET=latin1
If I then apply this script to the original database and run another
diff, if generates another patch to change the charset on that field.
If I change the order to this, it all works as expected:
ALTER TABLE `ITEM_VALUE` ENGINE=MyISAM DEFAULT CHARSET=utf8; # was
ENGINE=MyISAM DEFAULT CHARSET=latin1
ALTER TABLE `ITEM_VALUE` CHANGE COLUMN `UID` `UID` char(12) NOT NULL; #
was varchar(12) NOT NULL
So, a fix for this bug would be to output table changes before field
changes. Sound reasonable?
Thanks,
Marcus