pt-table-sync doesn't escape replicate table
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
version: percona-
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=
# 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(
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::mysql::db handle ;host=localhost
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::mysql::db handle ;host=localhost
patch:
--- /tmp/pt-table-sync 2015-03-29 13:45:45.209879060 +0930
+++ /usr/bin/
@@ -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->
. "WHERE master_cnt <> this_cnt OR master_crc <> this_crc "
. "OR ISNULL(master_crc) <> ISNULL(this_crc)";
PTDEBUG && _d($sql);
Confirmed.
nilnandan@ desktop: ~$ pt-table-sync --version desktop: ~$
pt-table-sync 2.2.14
nilnandan@
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 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. ;mysql_ socket= /tmp/mysql_ sandbox20886. sock;mysql_ read_default_ group=client at /usr/bin/ pt-table- sync line 4957. ;mysql_ socket= /tmp/mysql_ sandbox20886. sock;mysql_ read_default_ group=client at /usr/bin/ pt-table- sync line 4957. desktop: ~$
# 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(
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::mysql::db handle ;host=localhost
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::mysql::db handle ;host=localhost
nilnandan@