Bug #55540 mysqldump --complete-insert : result order differs from column order
Submitted: 26 Jul 2010 0:41 Modified: 9 Oct 2010 20:25
Reporter: Joao de Araujo Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: mysqldump Command-line Client Severity:S2 (Serious)
Version:5.1.47 OS:Any
Assigned to: CPU Architecture:Any
Tags: --complete-insert, mysqldump

[26 Jul 2010 0:41] Joao de Araujo
Description:
The option '--complete-insert' of the command-line mysqldump does NOT work correctly because the results order differs from column order.

How to repeat:
I am using the command :

mysqldump --compact --skip-opt --no-create-info --skip-comments --complete-insert -u username -p mydb securityexchange > securityexchange.sql

The results :

INSERT INTO securityexchange (codExchange, codSecurity) VALUES (25,38128);
INSERT INTO securityexchange (codExchange, codSecurity) VALUES (33,38129);

Where the columns are in the right order as displayed by the programm 'MySQL Query Browser', but the results order are inverted. 

It should be :

INSERT INTO securityexchange (codExchange, codSecurity) VALUES (38128,25);
INSERT INTO securityexchange (codExchange, codSecurity) VALUES (38129,33);

Please, test it!

Suggested fix:
Fix the order of the results in the VALUES chain as specified by the order of the table columns.
[26 Jul 2010 7:44] Sveta Smirnova
Thank you for the report.

Please provide output of SHOW CREATE TABLE securityexchange
[26 Aug 2010 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".
[9 Sep 2010 14:43] Joao de Araujo
sorry for the late answer. I think the problem remains without constraints (FK).

CREATE TABLE `securityexchange` (
  `codSecurity` int(11) NOT NULL,
  `codExchange` int(11) NOT NULL,
  PRIMARY KEY (`codSecurity`,`codExchange`),
  KEY `FKAF7F6DA344C7FC8` (`codExchange`),
  KEY `FKAF7F6DA3883E5202` (`codSecurity`),
  CONSTRAINT `FKAF7F6DA344C7FC8` FOREIGN KEY (`codExchange`) REFERENCES `exchange` (`codExchange`),
  CONSTRAINT `FKAF7F6DA3883E5202` FOREIGN KEY (`codSecurity`) REFERENCES `security` (`codSecurity`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
[9 Sep 2010 20:25] Sveta Smirnova
Thank you for the feedback.

I can not repeat described behavior: I get

INSERT INTO `securityexchange` (`codSecurity`, `codExchange`) VALUES (25,38128);
INSERT INTO `securityexchange` (`codSecurity`, `codExchange`) VALUES (33,38129);

Please try current version 5.1.50 and if problem still exists provide us copy-paste of mysqldump output.
[9 Oct 2010 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".