Bug #13926 mysqldump --order-by-primary fails if PK column needs quoting
Submitted: 11 Oct 2005 14:06 Modified: 19 Jan 2007 4:13
Reporter: Axel Schwenke Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version:5.0.15-rc OS:
Assigned to: Alexander Barkov
Tags: bfsm_2006_12_21

[11 Oct 2005 14:06] Axel Schwenke
Description:
If a tables PK contains a column that needs quoting in SQL (i.e. column name contains whitespace or "/") then 'mysqldump --order-by-primary ...' creates invalid SQL and fails.

How to repeat:
ls3235:~ # mysqltest test
CREATE TABLE t1(`a/b` INT PRIMARY KEY);
--exec mysqldump  --order-by-primary test t1
mysqldump: mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `t1` ORDER BY a/b': Unknown column 'a' in 'order clause' (1054)
mysqldump: Got error: 1054: Unknown column 'a' in 'order clause' when retrieving data from server
mysqltest: At line 2: command "mysqldump  --order-by-primary test t1" failed

Suggested fix:
Quote PK columns in SQL generated by mysqldump.
[11 Oct 2005 14:07] Axel Schwenke
fixed typo
[11 Oct 2005 20:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/30935
[28 Jul 2006 5:49] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/9694
[28 Jul 2006 5:56] Greg Lehey
Tested an updated patch supplied by Axel, added test and test results to mysqldump test file.
[28 Jul 2006 18:15] Jim Winstead
Patch looks okay to me, except for some cosmetic problems pointed out via email.
[1 Aug 2006 5:11] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/9868

ChangeSet@1.2212, 2006-08-01 14:40:32+09:30, grog@eucla.lemis.com +3 -0
  BUG#13926  mysqldump --order-by-primary fails if PK column needs quoting
  
  Fix by quoting columns.
[2 Aug 2006 1:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/9921

ChangeSet@1.2232, 2006-08-02 11:26:08+09:30, grog@eucla.lemis.com +3 -0
  BUG#13926: --order-by-primary fails if PKEY contains quote character.
  Quote PKEY.
[17 Nov 2006 9:26] Alexander Barkov
The patch was pushed into:
5.0.25
5.1.12

TODO: need backporting to 4.1, as it is affected as well.
[21 Nov 2006 7:07] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/15599

ChangeSet@1.2554, 2006-11-21 11:09:33+04:00, bar@mysql.com +3 -0
  BUG#13926: --order-by-primary fails if PKEY contains quote character.
  Backporting from 5.0
[21 Nov 2006 8:06] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/15601

ChangeSet@1.2311, 2006-11-21 12:09:14+04:00, bar@mysql.com +2 -0
  Prepare to merge "backport of bug#13926 from 5.0 to 4.1" back into 5.0:
  Moving tests into their new place into 4.1 tests section
[21 Nov 2006 8:19] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/15603

ChangeSet@1.2369, 2006-11-21 12:22:10+04:00, bar@mysql.com +2 -0
  Preparing to merge "backport of bug#13926 into 5.0"
  Moving tests to 4.1 section
[18 Jan 2007 15:24] Lars Thalmann
Pushed into 4.1.23, 5.0.36, 5.1.15.
[19 Jan 2007 4:13] Paul Dubois
Noted in 4.1.23, 5.0.36, 5.1.15 changelogs.

mysqldump --order-by-primary failed if the primary key name was an
identifier that required quoting.