diff --git a/bin/pt-upgrade b/bin/pt-upgrade index 2aaacf26..82dbb148 100755 --- a/bin/pt-upgrade +++ b/bin/pt-upgrade @@ -8036,7 +8036,14 @@ sub pending_changes { sub get_result_set_struct { my ( $dbh, $sth ) = @_; - my @cols = @{$sth->{NAME}}; + my @cols = map { + my $name = $_; + my $name_len = length($name); + if ( $name_len > 64 ) { + $name = substr($name, ($name_len - 64), 64); + } + $name; + } @{$sth->{NAME}}; my @types = map { $dbh->type_info($_)->{TYPE_NAME} } @{$sth->{TYPE}}; my @nullable = map { $dbh->type_info($_)->{NULLABLE} == 1 ? 1 : 0 } @{$sth->{TYPE}}; diff --git a/lib/MockSyncStream.pm b/lib/MockSyncStream.pm index 6cf932f2..a9ba9435 100644 --- a/lib/MockSyncStream.pm +++ b/lib/MockSyncStream.pm @@ -94,7 +94,17 @@ sub pending_changes { # uses sth attributes to return a pseudo table struct for the query's columns. sub get_result_set_struct { my ( $dbh, $sth ) = @_; - my @cols = @{$sth->{NAME}}; + my @cols = map { + my $name = $_; + my $name_len = length($name); + if ( $name_len > 64 ) { + # https://bugs.launchpad.net/percona-toolkit/+bug/1060774 + # Chop off the left end because right-side data tends to be + # the difference, e.g. load_the_canons vs. load_the_cantos. + $name = substr($name, ($name_len - 64), 64); + } + $name; + } @{$sth->{NAME}}; my @types = map { $dbh->type_info($_)->{TYPE_NAME} } @{$sth->{TYPE}}; my @nullable = map { $dbh->type_info($_)->{NULLABLE} == 1 ? 1 : 0 } @{$sth->{TYPE}}; diff --git a/t/pt-upgrade/basics.t b/t/pt-upgrade/basics.t index 0061521c..04fcfc81 100644 --- a/t/pt-upgrade/basics.t +++ b/t/pt-upgrade/basics.t @@ -187,6 +187,24 @@ SKIP: { ); } +# ############################################################################# +# SELECT FUNC(), so there are no tables. +# https://bugs.launchpad.net/percona-toolkit/+bug/1060774 +# ############################################################################# +$sb->load_file('master', "$sample/004/tables.sql"); +$sb->load_file('master1', "$sample/004/tables.sql"); + +ok( + no_diff( + sub { pt_upgrade::main(@args, + qw(--compare-results-method rows), + qw(--no-clear-warnings), + "$log/004/select-func.log") }, + "$sample/004/select-func.txt", + ), + 'SELECT FUNC() (bug 1060774)' +); + # ############################################################################# # Done. # ############################################################################# diff --git a/t/pt-upgrade/samples/004/select-func.log b/t/pt-upgrade/samples/004/select-func.log new file mode 100644 index 00000000..94a3bc64 --- /dev/null +++ b/t/pt-upgrade/samples/004/select-func.log @@ -0,0 +1,4 @@ +# User@Host: root[root] @ localhost [] +# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1 +use test; +SELECT (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP('2012-09-16 10:16:36')) / 60, SLEEP(1); diff --git a/t/pt-upgrade/samples/004/select-func.txt b/t/pt-upgrade/samples/004/select-func.txt new file mode 100644 index 00000000..c6764fa5 --- /dev/null +++ b/t/pt-upgrade/samples/004/select-func.txt @@ -0,0 +1,36 @@ + +# Query 1: ID 0xF05C9711D543F5BF at byte 0 _______________________________ +# host1: 127.1:12345 +# host2: 127.1:12348 +# Found 0 differences in 1 samples: +# column counts 0 +# column types 0 +# column values 0 +# row counts 0 +# warning counts 0 +# warning levels 0 +# warnings 0 +# host1 host2 +# Errors 0 0 +# Warnings 0 0 +# Query_time +# sum 0 0 +# min 0 0 +# max 0 0 +# avg 0 0 +# pct_95 0 0 +# stddev 0 0 +# median 0 0 +# row_count +# sum 1 1 +# min 1 1 +# max 1 1 +# avg 1 1 +# pct_95 1 1 +# stddev 0 0 +# median 1 1 +use `test`; +SELECT (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP('2012-09-16 10:16:36')) / 60, SLEEP(1) + +# Statistics +# events 1 diff --git a/t/pt-upgrade/samples/004/tables.sql b/t/pt-upgrade/samples/004/tables.sql new file mode 100644 index 00000000..a6306518 --- /dev/null +++ b/t/pt-upgrade/samples/004/tables.sql @@ -0,0 +1,2 @@ +DROP DATABASE IF EXISTS test; +CREATE DATABASE test;