pt-table-sync doesn't escape replicate table

Bug #1437775 reported by Daniel Black
20
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Confirmed
Undecided
Unassigned

Bug Description

version: percona-toolkit-2.2.13-1.noarch

a a table name of replicate needs escaping, running pt-table-sync will result in a sql error.

$ pt-table-sync --dry-run --print --replicate=X_20150210.pt-table-checksums --databases X_20150210 h=localhost,

# NOTE: --dry-run does not show if data needs to be synced because it
# does not access, compare or sync data. --dry-run only shows
# the work that would be done.
DBD::mysql::db selectall_arrayref failed: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-table-checksums WHERE master_cnt <> this_cnt OR master_crc <> this_crc OR ISNUL' at line 1 [for Statement "SELECT db, tbl, CONCAT(db, '.', tbl) AS `table`, chunk, chunk_index, lower_boundary, upper_boundary, COALESCE(this_cnt-master_cnt, 0) AS cnt_diff, COALESCE(this_crc <> master_crc OR ISNULL(master_crc) <> ISNULL(this_crc), 0) AS crc_diff, this_cnt, master_cnt, this_crc, master_crc FROM X_20150210.pt-table-checksums WHERE master_cnt <> this_cnt OR master_crc <> this_crc OR ISNULL(master_crc) <> ISNULL(this_crc)"] at /usr/bin/pt-table-sync line 4957.
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::mysql::db handle ;host=localhost;port=3310;mysql_read_default_group=client at /usr/bin/pt-table-sync line 4957.
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::mysql::db handle ;host=localhost;port=3310;mysql_read_default_group=client at /usr/bin/pt-table-sync line 4957

patch:
--- /tmp/pt-table-sync 2015-03-29 13:45:45.209879060 +0930
+++ /usr/bin/pt-table-sync 2015-03-29 13:55:34.360832636 +0930
@@ -4950,7 +4950,7 @@
       . "COALESCE("
       . "this_crc <> master_crc OR ISNULL(master_crc) <> ISNULL(this_crc), 0"
       . ") AS crc_diff, this_cnt, master_cnt, this_crc, master_crc "
- . "FROM $table "
+ . "FROM " . $self->{Quoter}->join_quote(undef, $table) . " "
       . "WHERE master_cnt <> this_cnt OR master_crc <> this_crc "
       . "OR ISNULL(master_crc) <> ISNULL(this_crc)";
    PTDEBUG && _d($sql);

Revision history for this message
Nilnandan Joshi (nilnandan-joshi) wrote :

Confirmed.

nilnandan@desktop:~$ pt-table-sync --version
pt-table-sync 2.2.14
nilnandan@desktop:~$

mysql> create table `nil-test` (id int);
Query OK, 0 rows affected (0.02 sec)

nilnandan@desktop:~$ pt-table-sync --user=root --password=msandbox --socket=/tmp/mysql_sandbox20886.sock --replicate=test.nil-test --databases=test --dry-run --print h=localhost
# NOTE: --dry-run does not show if data needs to be synced because it
# does not access, compare or sync data. --dry-run only shows
# the work that would be done.
DBD::mysql::db selectall_arrayref failed: 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 '-test WHERE master_cnt <> this_cnt OR master_crc <> this_crc OR ISNULL(master_cr' at line 1 [for Statement "SELECT db, tbl, CONCAT(db, '.', tbl) AS `table`, chunk, chunk_index, lower_boundary, upper_boundary, COALESCE(this_cnt-master_cnt, 0) AS cnt_diff, COALESCE(this_crc <> master_crc OR ISNULL(master_crc) <> ISNULL(this_crc), 0) AS crc_diff, this_cnt, master_cnt, this_crc, master_crc FROM test.nil-test WHERE master_cnt <> this_cnt OR master_crc <> this_crc OR ISNULL(master_crc) <> ISNULL(this_crc)"] at /usr/bin/pt-table-sync line 4957.
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::mysql::db handle ;host=localhost;mysql_socket=/tmp/mysql_sandbox20886.sock;mysql_read_default_group=client at /usr/bin/pt-table-sync line 4957.
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::mysql::db handle ;host=localhost;mysql_socket=/tmp/mysql_sandbox20886.sock;mysql_read_default_group=client at /usr/bin/pt-table-sync line 4957.
nilnandan@desktop:~$

Changed in percona-toolkit:
status: New → Confirmed
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-1275

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

Duplicates of this bug

Other bug subscribers

Remote bug watches

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