diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index 3adee83e..344187be 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -9131,6 +9131,26 @@ sub main { return if $o->get('explain'); my $sql; + # https://bugs.launchpad.net/percona-toolkit/+bug/1019479 + # sql_mode ONLY_FULL_GROUP_BY often raises error even when query is + # safe and deterministic. It's best to turn it off for the session + # at this point. + $sql = 'SELECT @@SQL_MODE'; + PTDEBUG && _d($dbh, $sql); + my ($sql_mode) = eval { $dbh->selectrow_array($sql) }; + if ( $EVAL_ERROR ) { + die "Error getting the current SQL_MODE: $EVAL_ERROR"; + } + $sql_mode =~ s/ONLY_FULL_GROUP_BY//i; + $sql = qq[SET SQL_MODE='$sql_mode']; + PTDEBUG && _d($dbh, $sql); + eval { $dbh->do($sql) }; + if ( $EVAL_ERROR ) { + die "Error setting SQL_MODE" + . ": $EVAL_ERROR"; + } + + # https://bugs.launchpad.net/percona-toolkit/+bug/919352 # The tool shouldn't blindly attempt to change binlog_format; # instead, it should check if it's already set to STATEMENT. diff --git a/t/pt-table-checksum/basics.t b/t/pt-table-checksum/basics.t index 056fbd1b..de2eb369 100644 --- a/t/pt-table-checksum/basics.t +++ b/t/pt-table-checksum/basics.t @@ -56,6 +56,7 @@ sub reset_repl_db { $master_dbh->do("use $repl_db"); } + # ############################################################################ # Default checksum and results. The tool does not technically require any # options on well-configured systems (which the test env cannot be). With @@ -508,6 +509,24 @@ is( "Bug 821675 (dot): 0 errors" ); +# ############################################################################# +# Bug 1019479: does not work with sql_mode ONLY_FULL_GROUP_BY +# ############################################################################# + +# add a couple more modes to test that commas don't affect setting +$master_dbh->do("SET sql_mode = 'NO_ZERO_DATE,ONLY_FULL_GROUP_BY,STRICT_ALL_TABLES'"); + +# force chunk-size because bug doesn't show up if table done in one chunk +$exit_status = pt_table_checksum::main(@args, + qw(--quiet --quiet -t sakila.actor --chunk-size=50)); + +is( + $exit_status, + 0, + "sql_mode ONLY_FULL_GROUP_BY is overidden" +); + + # ############################################################################# # Done. # #############################################################################