From ef75630344e66e83b2b534a2e9c01d760e9f3035 Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Thu, 25 Jun 2015 13:21:12 -0700 Subject: [PATCH] Update TableParser module in all tools. --- bin/pt-archiver | 3 +++ bin/pt-duplicate-key-checker | 3 +++ bin/pt-find | 3 +++ bin/pt-heartbeat | 3 +++ bin/pt-index-usage | 3 +++ bin/pt-kill | 3 +++ bin/pt-online-schema-change | 3 +++ bin/pt-query-digest | 3 +++ bin/pt-table-checksum | 3 +++ bin/pt-table-sync | 3 +++ bin/pt-table-usage | 23 ++++++++++++++--------- 11 files changed, 44 insertions(+), 9 deletions(-) diff --git a/bin/pt-archiver b/bin/pt-archiver index 7de572c6..756ce6f9 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -1931,6 +1931,9 @@ sub parse { my (%type_for, %is_nullable, %is_numeric, %is_autoinc); foreach my $col ( @cols ) { my $def = $def_for{$col}; + + $def =~ s/``//g; + my ( $type ) = $def =~ m/`[^`]+`\s([a-z]+)/; die "Can't determine column type for $def" unless $type; $type_for{$col} = $type; diff --git a/bin/pt-duplicate-key-checker b/bin/pt-duplicate-key-checker index 2960182e..cca5667c 100755 --- a/bin/pt-duplicate-key-checker +++ b/bin/pt-duplicate-key-checker @@ -356,6 +356,9 @@ sub parse { my (%type_for, %is_nullable, %is_numeric, %is_autoinc); foreach my $col ( @cols ) { my $def = $def_for{$col}; + + $def =~ s/``//g; + my ( $type ) = $def =~ m/`[^`]+`\s([a-z]+)/; die "Can't determine column type for $def" unless $type; $type_for{$col} = $type; diff --git a/bin/pt-find b/bin/pt-find index e3bd0cd0..0f4e22ff 100755 --- a/bin/pt-find +++ b/bin/pt-find @@ -1848,6 +1848,9 @@ sub parse { my (%type_for, %is_nullable, %is_numeric, %is_autoinc); foreach my $col ( @cols ) { my $def = $def_for{$col}; + + $def =~ s/``//g; + my ( $type ) = $def =~ m/`[^`]+`\s([a-z]+)/; die "Can't determine column type for $def" unless $type; $type_for{$col} = $type; diff --git a/bin/pt-heartbeat b/bin/pt-heartbeat index d8d63a21..68fe5946 100755 --- a/bin/pt-heartbeat +++ b/bin/pt-heartbeat @@ -2789,6 +2789,9 @@ sub parse { my (%type_for, %is_nullable, %is_numeric, %is_autoinc); foreach my $col ( @cols ) { my $def = $def_for{$col}; + + $def =~ s/``//g; + my ( $type ) = $def =~ m/`[^`]+`\s([a-z]+)/; die "Can't determine column type for $def" unless $type; $type_for{$col} = $type; diff --git a/bin/pt-index-usage b/bin/pt-index-usage index cb20bcd4..c5b49d2a 100755 --- a/bin/pt-index-usage +++ b/bin/pt-index-usage @@ -3087,6 +3087,9 @@ sub parse { my (%type_for, %is_nullable, %is_numeric, %is_autoinc); foreach my $col ( @cols ) { my $def = $def_for{$col}; + + $def =~ s/``//g; + my ( $type ) = $def =~ m/`[^`]+`\s([a-z]+)/; die "Can't determine column type for $def" unless $type; $type_for{$col} = $type; diff --git a/bin/pt-kill b/bin/pt-kill index 02dec217..fa75b6ab 100755 --- a/bin/pt-kill +++ b/bin/pt-kill @@ -2913,6 +2913,9 @@ sub parse { my (%type_for, %is_nullable, %is_numeric, %is_autoinc); foreach my $col ( @cols ) { my $def = $def_for{$col}; + + $def =~ s/``//g; + my ( $type ) = $def =~ m/`[^`]+`\s([a-z]+)/; die "Can't determine column type for $def" unless $type; $type_for{$col} = $type; diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index ead42cfd..9852d22c 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -3176,6 +3176,9 @@ sub parse { my (%type_for, %is_nullable, %is_numeric, %is_autoinc); foreach my $col ( @cols ) { my $def = $def_for{$col}; + + $def =~ s/``//g; + my ( $type ) = $def =~ m/`[^`]+`\s([a-z]+)/; die "Can't determine column type for $def" unless $type; $type_for{$col} = $type; diff --git a/bin/pt-query-digest b/bin/pt-query-digest index 3a1bcac5..5373e366 100755 --- a/bin/pt-query-digest +++ b/bin/pt-query-digest @@ -8787,6 +8787,9 @@ sub parse { my (%type_for, %is_nullable, %is_numeric, %is_autoinc); foreach my $col ( @cols ) { my $def = $def_for{$col}; + + $def =~ s/``//g; + my ( $type ) = $def =~ m/`[^`]+`\s([a-z]+)/; die "Can't determine column type for $def" unless $type; $type_for{$col} = $type; diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index 6d3e8267..ee993b45 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -4392,6 +4392,9 @@ sub parse { my (%type_for, %is_nullable, %is_numeric, %is_autoinc); foreach my $col ( @cols ) { my $def = $def_for{$col}; + + $def =~ s/``//g; + my ( $type ) = $def =~ m/`[^`]+`\s([a-z]+)/; die "Can't determine column type for $def" unless $type; $type_for{$col} = $type; diff --git a/bin/pt-table-sync b/bin/pt-table-sync index 2bf517fd..c700f715 100755 --- a/bin/pt-table-sync +++ b/bin/pt-table-sync @@ -2832,6 +2832,9 @@ sub parse { my (%type_for, %is_nullable, %is_numeric, %is_autoinc); foreach my $col ( @cols ) { my $def = $def_for{$col}; + + $def =~ s/``//g; + my ( $type ) = $def =~ m/`[^`]+`\s([a-z]+)/; die "Can't determine column type for $def" unless $type; $type_for{$col} = $type; diff --git a/bin/pt-table-usage b/bin/pt-table-usage index e0fc3a54..1284092b 100755 --- a/bin/pt-table-usage +++ b/bin/pt-table-usage @@ -5818,16 +5818,20 @@ $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Quotekeys = 0; +local $EVAL_ERROR; +eval { + require Quoter; +}; + sub new { my ( $class, %args ) = @_; - my @required_args = qw(Quoter); - foreach my $arg ( @required_args ) { - die "I need a $arg argument" unless $args{$arg}; - } my $self = { %args }; + $self->{Quoter} ||= Quoter->new(); return bless $self, $class; } +sub Quoter { shift->{Quoter} } + sub get_create_table { my ( $self, $dbh, $db, $tbl ) = @_; die "I need a dbh parameter" unless $dbh; @@ -5857,13 +5861,11 @@ sub get_create_table { PTDEBUG && _d($show_sql); my $href; eval { $href = $dbh->selectrow_hashref($show_sql); }; - if ( $EVAL_ERROR ) { - PTDEBUG && _d($EVAL_ERROR); - + if ( my $e = $EVAL_ERROR ) { PTDEBUG && _d($old_sql_mode); $dbh->do($old_sql_mode); - return; + die $e; } PTDEBUG && _d($old_sql_mode); @@ -5907,6 +5909,9 @@ sub parse { my (%type_for, %is_nullable, %is_numeric, %is_autoinc); foreach my $col ( @cols ) { my $def = $def_for{$col}; + + $def =~ s/``//g; + my ( $type ) = $def =~ m/`[^`]+`\s([a-z]+)/; die "Can't determine column type for $def" unless $type; $type_for{$col} = $type; @@ -6016,7 +6021,7 @@ sub check_table { die "I need a $arg argument" unless $args{$arg}; } my ($dbh, $db, $tbl) = @args{@required_args}; - my $q = $self->{Quoter}; + my $q = $self->{Quoter} || 'Quoter'; my $db_tbl = $q->quote($db, $tbl); PTDEBUG && _d('Checking', $db_tbl);