Bug #36408 | Dump of foreign key constraints with mysqldump not sorted | ||
---|---|---|---|
Submitted: | 29 Apr 2008 17:39 | Modified: | 8 Aug 2008 12:22 |
Reporter: | Peter Brückner | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: mysqldump Command-line Client | Severity: | S4 (Feature request) |
Version: | 5.0.45 | OS: | Linux (suse10.3) |
Assigned to: | CPU Architecture: | Any | |
Tags: | mysqldump foreign key constraints sort |
[29 Apr 2008 17:39]
Peter Brückner
[7 Aug 2008 9:05]
Susanne Ebrecht
Many thanks for writing a feature request. Why do you want to sort the constraints by name?
[7 Aug 2008 11:35]
Peter Brückner
we test structural identity to check for correct data model version. everything else is stable sorted in the output but the fk-constraints. so we can't make a diff to check the identity.
[7 Aug 2008 12:26]
Susanne Ebrecht
Your suggested test won't work perfect. The indexes are still not sorted. I found some other bugs during analysing this bug here. I think, what you really want is a dump out where you first have all "CREATE TABLE " statements and then at the end all dependencies. Means first all create table statements in alphabetic order and then after all create table statements all create index statements and "alter table add foreign key" statements. Is that right?
[7 Aug 2008 12:46]
Peter Brückner
i think the constraints belong to the table when created. The sql syntax also designed in this way: CREATE TABLE x ( x CHAR(20), ... CONSTRAINT "xcon1" PRIMARY KEY(x) CONSTRAINT "xcon2" FOREIGN KEY(x) REFERENCES t(y) ON DELETE RESTRICT, .... ); so we would suggest this syntax and sorting by constraint name. But at least a 'stable' output - all definitions with the same meaning have the same dump.
[8 Aug 2008 12:22]
Susanne Ebrecht
Many thanks for your feedback. I will give this feature request to development for discussion. A workaround is to sort the constraints manually at the dump file.
[23 Apr 2010 6:59]
Emanuel Greisen
This issue is still in mysql 5.0.51a. Sorting after dumping is quite hard since it should only sort some of the lines. Any other suggestions on how to verify the structure-identity between two databases including constraints?
[12 Mar 2012 14:23]
Nestor Urquiza
Hi, Are there any plans to implement this feature? Anybody tracking this that could share their workarounds at the moment? Thanks! -Nestor
[12 Mar 2012 14:46]
Deryl Spielman
I would like to see this as well. All constraints, indexes, keys grouped together and sorted alphabetically. For schema comparisons of database changes this helps tremendously. Thanks.
[12 Mar 2012 15:04]
Greg Salas
Glad this request has been brought up again. Any plans on implementing this in the near future?
[12 Mar 2012 19:25]
Nestor Urquiza
Here is a gawk script that can be used to sort mysqldump CONSTRAINT and KEY http://thinkinginsoftware.blogspot.com/2012/03/sort-key-and-constraint-in-mysqldump.html Of course ideally this should be supported inside mysqldump code.