pt-online-schema-change doesn't like reserved words in column names

Bug #873598 reported by chris erway
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Fix Released
High
Daniel Nichter

Bug Description

Hi, we love pt-online-schema-change (thanks!) but unfortunately one of our tables has a column with a reserved name in it. Unfortunately, pt-online-schema-change doesn't escape names with backticks, etc, so we can't use the tool for this one really cool online migration we want to do. Just letting you know -- thanks!

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

Can you point out where it fails to backtick-quote the name so we can find it more easily? We generally use a quoter module to do this pretty universally, so it surprises me that we let one slip through like this.

Revision history for this message
TR Jordan (terral-jordan) wrote :

Here's a patch that seems to fix it.

(venv)trjordan@trjordan-desktop:~/repos/percona-toolkit$ bzr diff -r109..110
=== modified file 'bin/pt-online-schema-change'
--- bin/pt-online-schema-change 2011-09-01 16:00:38 +0000
+++ bin/pt-online-schema-change 2011-10-13 19:13:08 +0000
@@ -3829,7 +3829,7 @@
    my $old_table = "`$db`.`$tbl`";
    my $new_table = "`$db`.`$tmp_tbl`";
    my $new_values = join(', ', map { "NEW.$_" } @{$args{columns}});
- my $columns = join(', ', @{$args{columns}});
+ my $columns = join(', ', map { "`$_`" } @{$args{columns}});

    my $delete_trigger = "CREATE TRIGGER mk_osc_del AFTER DELETE ON $old_table "
                       . "FOR EACH ROW "
@@ -3928,7 +3928,7 @@
    my ($dbh, $msg, $from_table, $to_table, $chunks) = @args{@required_args};
    my $pr = $args{Progress};
    my $sleep = $args{sleep};
- my $columns = join(', ', @{$args{columns}});
+ my $columns = join(', ', map { "`$_`" } @{$args{columns}});
    my $n_chunks = @$chunks - 1;

    for my $chunkno ( 0..$n_chunks ) {

Changed in percona-toolkit:
importance: Undecided → Medium
tags: added: ident-quoting pt-online-schema-change
Changed in percona-toolkit:
importance: Medium → Undecided
Revision history for this message
Simon J Mudd (sjmudd) wrote :

Just to comment that I'm also affected by this. I'll try the patch and see if it works.

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

We certainly need to fix this. Thanks for the bug report and the up-votes.

Changed in percona-toolkit:
importance: Undecided → High
status: New → Confirmed
milestone: none → 2.0-beta3
Changed in percona-toolkit:
assignee: nobody → Daniel Nichter (daniel-nichter)
Revision history for this message
Dan Cech (dan-aussiedan) wrote :

I arrived at the same patch independently, and can confirm that it resolves the problem.

Changed in percona-toolkit:
assignee: Daniel Nichter (daniel-nichter) → nobody
Changed in percona-toolkit:
assignee: nobody → Daniel Nichter (daniel-nichter)
status: Confirmed → In Progress
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

This has been tested with both reserved word and spaces, reproduced, and fixed. It will be in the next release, 2.0.4 (or, you can pull pt-online-schema-change directly from the 2.0 branch).

Changed in percona-toolkit:
status: In Progress → Fix Committed
Revision history for this message
Baron Schwartz (baron-xaprb) wrote :

Was this released in 2.0.4?

Changed in percona-toolkit:
status: Fix Committed → Fix Released
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-279

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.