PT-1574 Fixed undefs handling

This commit is contained in:
Carlos Salguero
2018-08-07 14:21:44 -03:00
parent b5a1775bad
commit dc9edf7cda
3 changed files with 15 additions and 8 deletions

View File

@@ -5690,7 +5690,7 @@ sub next {
if ( !$self->{have_rows} ) { if ( !$self->{have_rows} ) {
$self->{nibbleno}++; $self->{nibbleno}++;
PTDEBUG && _d('Nibble:', $self->{nibble_sth}->{Statement}, 'params:', PTDEBUG && _d('Nibble:', $self->{nibble_sth}->{Statement}, 'params:',
join(', ', (@{$self->{lower} || []}, @{$self->{upper} || []}))); join(', ', (@{$self->{lower}} || [], @{$self->{upper} }||[])));
if ( my $callback = $self->{callbacks}->{exec_nibble} ) { if ( my $callback = $self->{callbacks}->{exec_nibble} ) {
$self->{have_rows} = $callback->(%callback_args); $self->{have_rows} = $callback->(%callback_args);
} }
@@ -6089,7 +6089,7 @@ sub _next_boundaries {
PTDEBUG && _d($self->{ub_sth}->{Statement}, 'params:', PTDEBUG && _d($self->{ub_sth}->{Statement}, 'params:',
join(', ', @{$self->{lower}}), $self->{limit}); join(', ', @{$self->{lower}} || []), $self->{limit});
$self->{ub_sth}->execute(@{$self->{lower}}, $self->{limit}); $self->{ub_sth}->execute(@{$self->{lower}}, $self->{limit});
my $boundary = $self->{ub_sth}->fetchall_arrayref(); my $boundary = $self->{ub_sth}->fetchall_arrayref();
PTDEBUG && _d('Next boundary:', Dumper($boundary)); PTDEBUG && _d('Next boundary:', Dumper($boundary));
@@ -6130,6 +6130,9 @@ sub identical_boundaries {
if scalar @$b1 != scalar @$b2; # shouldn't happen if scalar @$b1 != scalar @$b2; # shouldn't happen
my $n_vals = scalar @$b1; my $n_vals = scalar @$b1;
for my $i ( 0..($n_vals-1) ) { for my $i ( 0..($n_vals-1) ) {
next if (!defined($b1->[$i]) && !defined($b2->[$i]));
return 0 if (!defined($b1->[$i]) && defined($b2->[$i])); # diff
return 0 if (defined($b1->[$i]) && !defined($b2->[$i])); # diff
return 0 if $b1->[$i] ne $b2->[$i]; # diff return 0 if $b1->[$i] ne $b2->[$i]; # diff
} }
return 1; return 1;

View File

@@ -53,6 +53,9 @@ $sb->load_file('master', "t/pt-online-schema-change/samples/pt-1574.sql");
stderr => 1, stderr => 1,
); );
my $sql_mode = $dbh->selectcol_arrayref('SELECT @@sql_mode');
warn Data::Dumper::Dumper($sql_mode);
isnt( isnt(
$exit_status, $exit_status,
0, 0,

View File

@@ -22,12 +22,13 @@ INSERT INTO `test`.`t1` VALUES
(NULL,NULL,NULL); (NULL,NULL,NULL);
CREATE TABLE `test`.`t2` ( CREATE TABLE `t2` (
`id` int(11) DEFAULT NULL, `id` int(11) DEFAULT NULL,
`site_name` varchar(25) PRIMARY KEY, `site_name` varchar(25) NOT NULL,
`last_update` datetime DEFAULT NULL, `last_update` datetime DEFAULT NULL,
UNIQUE KEY `idx_id` (`id`), PRIMARY KEY (`site_name`),
KEY `idx_last_update` (`last_update`) UNIQUE KEY `idx_id` (`id`),
KEY `idx_last_update` (`last_update`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `test`.`t2` VALUES INSERT INTO `test`.`t2` VALUES