Char chunking doesn't quote column name

Bug #967451 reported by David Delikat
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Fix Released
Medium
Daniel Nichter
2.0
Fix Released
Medium
Daniel Nichter
2.1
Fix Released
Medium
Daniel Nichter

Bug Description

received this error from pt-table-sync:

 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key)) FROM `<database>`.`<column>` ORDER BY `key`' at line 1 [for Statement "SELECT MAX(LENGTH(key)) FROM `<database>`.`<table>` ORDER BY `key`"] at line 3316 while doing <database>.<column> on <host>

the paramater to the 'LENGTH' function needs quoting.

here is a patch:

*** modified/pt-table-sync 2012-03-28 11:00:55.000000000 -0500
--- original/pt-table-sync 2012-03-07 17:47:53.000000000 -0600
*************** sub _chunk_char {
*** 3309,3315 ****
     PTDEBUG && _d("Base", $base, "chars:", @chars);

! $sql = "SELECT MAX(LENGTH(`$chunk_col`)) FROM $db_tbl "
          . ($args{where} ? "WHERE $args{where} " : "")
          . "ORDER BY `$chunk_col`";
     PTDEBUG && _d($dbh, $sql);
--- 3309,3315 ----
     PTDEBUG && _d("Base", $base, "chars:", @chars);

! $sql = "SELECT MAX(LENGTH($chunk_col)) FROM $db_tbl "
          . ($args{where} ? "WHERE $args{where} " : "")
          . "ORDER BY `$chunk_col`";
     PTDEBUG && _d($dbh, $sql);

Revision history for this message
Baron Schwartz (baron-xaprb) wrote :

Thanks for the bug report. This is a problem in all of the tools that use TableChunker.

Changed in percona-toolkit:
status: New → Confirmed
importance: Undecided → Medium
milestone: none → 2.1.1
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

In 2.0 this affects pt-table-sync, pt-upgrade, and pt-online-schema-change. In 2.1 it affects the same minus pt-online-schema-change which is/was redesigned in 2.1.

tags: added: crash ident-quoting pt-online-schema-change pt-table-sync pt-upgrade
summary: - quotes missing from sql statement
+ Char chunking doesn't quote column name
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PT-504

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.