mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
Do not use precision and scale. Use sandbox 12348 instead of 12347. Call pt_upgrade_main() instead of tool via cmd line in basics.t.
This commit is contained in:
294
bin/pt-upgrade
294
bin/pt-upgrade
@@ -141,12 +141,14 @@ sub parse_options {
|
|||||||
sub as_string {
|
sub as_string {
|
||||||
my ( $self, $dsn, $props ) = @_;
|
my ( $self, $dsn, $props ) = @_;
|
||||||
return $dsn unless ref $dsn;
|
return $dsn unless ref $dsn;
|
||||||
my %allowed = $props ? map { $_=>1 } @$props : ();
|
my @keys = $props ? @$props : sort keys %$dsn;
|
||||||
return join(',',
|
return join(',',
|
||||||
map { "$_=" . ($_ eq 'p' ? '...' : $dsn->{$_}) }
|
map { "$_=" . ($_ eq 'p' ? '...' : $dsn->{$_}) }
|
||||||
grep { defined $dsn->{$_} && $self->{opts}->{$_} }
|
grep {
|
||||||
grep { !$props || $allowed{$_} }
|
exists $self->{opts}->{$_}
|
||||||
sort keys %$dsn );
|
&& exists $dsn->{$_}
|
||||||
|
&& defined $dsn->{$_}
|
||||||
|
} @keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub usage {
|
sub usage {
|
||||||
@@ -700,19 +702,56 @@ sub new {
|
|||||||
return bless $self, $class;
|
return bless $self, $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub get_create_table {
|
||||||
|
my ( $self, $dbh, $db, $tbl ) = @_;
|
||||||
|
die "I need a dbh parameter" unless $dbh;
|
||||||
|
die "I need a db parameter" unless $db;
|
||||||
|
die "I need a tbl parameter" unless $tbl;
|
||||||
|
my $q = $self->{Quoter};
|
||||||
|
|
||||||
|
my $sql = '/*!40101 SET @OLD_SQL_MODE := @@SQL_MODE, '
|
||||||
|
. q{@@SQL_MODE := REPLACE(REPLACE(@@SQL_MODE, 'ANSI_QUOTES', ''), ',,', ','), }
|
||||||
|
. '@OLD_QUOTE := @@SQL_QUOTE_SHOW_CREATE, '
|
||||||
|
. '@@SQL_QUOTE_SHOW_CREATE := 1 */';
|
||||||
|
PTDEBUG && _d($sql);
|
||||||
|
eval { $dbh->do($sql); };
|
||||||
|
PTDEBUG && $EVAL_ERROR && _d($EVAL_ERROR);
|
||||||
|
|
||||||
|
$sql = 'USE ' . $q->quote($db);
|
||||||
|
PTDEBUG && _d($dbh, $sql);
|
||||||
|
$dbh->do($sql);
|
||||||
|
|
||||||
|
$sql = "SHOW CREATE TABLE " . $q->quote($db, $tbl);
|
||||||
|
PTDEBUG && _d($sql);
|
||||||
|
my $href;
|
||||||
|
eval { $href = $dbh->selectrow_hashref($sql); };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
PTDEBUG && _d($EVAL_ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = '/*!40101 SET @@SQL_MODE := @OLD_SQL_MODE, '
|
||||||
|
. '@@SQL_QUOTE_SHOW_CREATE := @OLD_QUOTE */';
|
||||||
|
PTDEBUG && _d($sql);
|
||||||
|
$dbh->do($sql);
|
||||||
|
|
||||||
|
my ($key) = grep { m/create table/i } keys %$href;
|
||||||
|
if ( $key ) {
|
||||||
|
PTDEBUG && _d('This table is a base table');
|
||||||
|
$href->{$key} =~ s/\b[ ]{2,}/ /g;
|
||||||
|
$href->{$key} .= "\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PTDEBUG && _d('This table is a view');
|
||||||
|
($key) = grep { m/create view/i } keys %$href;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $href->{$key};
|
||||||
|
}
|
||||||
|
|
||||||
sub parse {
|
sub parse {
|
||||||
my ( $self, $ddl, $opts ) = @_;
|
my ( $self, $ddl, $opts ) = @_;
|
||||||
return unless $ddl;
|
return unless $ddl;
|
||||||
if ( ref $ddl eq 'ARRAY' ) {
|
|
||||||
if ( lc $ddl->[0] eq 'table' ) {
|
|
||||||
$ddl = $ddl->[1];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return {
|
|
||||||
engine => 'VIEW',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $ddl !~ m/CREATE (?:TEMPORARY )?TABLE `/ ) {
|
if ( $ddl !~ m/CREATE (?:TEMPORARY )?TABLE `/ ) {
|
||||||
die "Cannot parse table definition; is ANSI quoting "
|
die "Cannot parse table definition; is ANSI quoting "
|
||||||
@@ -1019,41 +1058,31 @@ sub remove_auto_increment {
|
|||||||
return $ddl;
|
return $ddl;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub remove_secondary_indexes {
|
sub get_table_status {
|
||||||
my ( $self, $ddl ) = @_;
|
my ( $self, $dbh, $db, $like ) = @_;
|
||||||
my $sec_indexes_ddl;
|
my $q = $self->{Quoter};
|
||||||
my $tbl_struct = $self->parse($ddl);
|
my $sql = "SHOW TABLE STATUS FROM " . $q->quote($db);
|
||||||
|
my @params;
|
||||||
if ( ($tbl_struct->{engine} || '') =~ m/InnoDB/i ) {
|
if ( $like ) {
|
||||||
my $clustered_key = $tbl_struct->{clustered_key};
|
$sql .= ' LIKE ?';
|
||||||
$clustered_key ||= '';
|
push @params, $like;
|
||||||
|
|
||||||
my @sec_indexes = map {
|
|
||||||
my $key_def = $_->{ddl};
|
|
||||||
$key_def =~ s/([\(\)])/\\$1/g;
|
|
||||||
$ddl =~ s/\s+$key_def//i;
|
|
||||||
|
|
||||||
my $key_ddl = "ADD $_->{ddl}";
|
|
||||||
$key_ddl .= ',' unless $key_ddl =~ m/,$/;
|
|
||||||
$key_ddl;
|
|
||||||
}
|
|
||||||
grep { $_->{name} ne $clustered_key }
|
|
||||||
values %{$tbl_struct->{keys}};
|
|
||||||
PTDEBUG && _d('Secondary indexes:', Dumper(\@sec_indexes));
|
|
||||||
|
|
||||||
if ( @sec_indexes ) {
|
|
||||||
$sec_indexes_ddl = join(' ', @sec_indexes);
|
|
||||||
$sec_indexes_ddl =~ s/,$//;
|
|
||||||
}
|
|
||||||
|
|
||||||
$ddl =~ s/,(\n\) )/$1/s;
|
|
||||||
}
|
}
|
||||||
else {
|
PTDEBUG && _d($sql, @params);
|
||||||
PTDEBUG && _d('Not removing secondary indexes from',
|
my $sth = $dbh->prepare($sql);
|
||||||
$tbl_struct->{engine}, 'table');
|
eval { $sth->execute(@params); };
|
||||||
|
if ($EVAL_ERROR) {
|
||||||
|
PTDEBUG && _d($EVAL_ERROR);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
my @tables = @{$sth->fetchall_arrayref({})};
|
||||||
return $ddl, $sec_indexes_ddl, $tbl_struct;
|
@tables = map {
|
||||||
|
my %tbl; # Make a copy with lowercased keys
|
||||||
|
@tbl{ map { lc $_ } keys %$_ } = values %$_;
|
||||||
|
$tbl{engine} ||= $tbl{type} || $tbl{comment};
|
||||||
|
delete $tbl{type};
|
||||||
|
\%tbl;
|
||||||
|
} @tables;
|
||||||
|
return @tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _d {
|
sub _d {
|
||||||
@@ -1141,6 +1170,48 @@ sub join_quote {
|
|||||||
return $db ? "$db.$tbl" : $tbl;
|
return $db ? "$db.$tbl" : $tbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub serialize_list {
|
||||||
|
my ( $self, @args ) = @_;
|
||||||
|
return unless @args;
|
||||||
|
|
||||||
|
return $args[0] if @args == 1 && !defined $args[0];
|
||||||
|
|
||||||
|
die "Cannot serialize multiple values with undef/NULL"
|
||||||
|
if grep { !defined $_ } @args;
|
||||||
|
|
||||||
|
return join ',', map { quotemeta } @args;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub deserialize_list {
|
||||||
|
my ( $self, $string ) = @_;
|
||||||
|
return $string unless defined $string;
|
||||||
|
my @escaped_parts = $string =~ /
|
||||||
|
\G # Start of string, or end of previous match.
|
||||||
|
( # Each of these is an element in the original list.
|
||||||
|
[^\\,]* # Anything not a backslash or a comma
|
||||||
|
(?: # When we get here, we found one of the above.
|
||||||
|
\\. # A backslash followed by something so we can continue
|
||||||
|
[^\\,]* # Same as above.
|
||||||
|
)* # Repeat zero of more times.
|
||||||
|
)
|
||||||
|
, # Comma dividing elements
|
||||||
|
/sxgc;
|
||||||
|
|
||||||
|
push @escaped_parts, pos($string) ? substr( $string, pos($string) ) : $string;
|
||||||
|
|
||||||
|
my @unescaped_parts = map {
|
||||||
|
my $part = $_;
|
||||||
|
|
||||||
|
my $char_class = utf8::is_utf8($part) # If it's a UTF-8 string,
|
||||||
|
? qr/(?=\p{ASCII})\W/ # We only care about non-word
|
||||||
|
: qr/(?=\p{ASCII})\W|[\x{80}-\x{FF}]/; # Otherwise,
|
||||||
|
$part =~ s/\\($char_class)/$1/g;
|
||||||
|
$part;
|
||||||
|
} @escaped_parts;
|
||||||
|
|
||||||
|
return @unescaped_parts;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
}
|
}
|
||||||
# ###########################################################################
|
# ###########################################################################
|
||||||
@@ -2098,7 +2169,7 @@ sub _parse_size {
|
|||||||
$opt->{value} = ($pre || '') . $num;
|
$opt->{value} = ($pre || '') . $num;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$self->save_error("Invalid size for --$opt->{long}");
|
$self->save_error("Invalid size for --$opt->{long}: $val");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -6019,23 +6090,21 @@ sub generate_asc_stmt {
|
|||||||
die "I need a $arg argument" unless defined $args{$arg};
|
die "I need a $arg argument" unless defined $args{$arg};
|
||||||
}
|
}
|
||||||
my ($tbl_struct, $index) = @args{@required_args};
|
my ($tbl_struct, $index) = @args{@required_args};
|
||||||
my @cols = $args{cols} ? @{$args{cols}} : @{$tbl_struct->{cols}};
|
my @cols = $args{cols} ? @{$args{cols}} : @{$tbl_struct->{cols}};
|
||||||
my $q = $self->{Quoter};
|
my $q = $self->{Quoter};
|
||||||
|
|
||||||
die "Index '$index' does not exist in table"
|
die "Index '$index' does not exist in table"
|
||||||
unless exists $tbl_struct->{keys}->{$index};
|
unless exists $tbl_struct->{keys}->{$index};
|
||||||
|
PTDEBUG && _d('Will ascend index', $index);
|
||||||
|
|
||||||
my @asc_cols = @{$tbl_struct->{keys}->{$index}->{cols}};
|
my @asc_cols = @{$tbl_struct->{keys}->{$index}->{cols}};
|
||||||
my @asc_slice;
|
|
||||||
|
|
||||||
@asc_cols = @{$tbl_struct->{keys}->{$index}->{cols}};
|
|
||||||
PTDEBUG && _d('Will ascend index', $index);
|
|
||||||
PTDEBUG && _d('Will ascend columns', join(', ', @asc_cols));
|
|
||||||
if ( $args{asc_first} ) {
|
if ( $args{asc_first} ) {
|
||||||
@asc_cols = $asc_cols[0];
|
@asc_cols = $asc_cols[0];
|
||||||
PTDEBUG && _d('Ascending only first column');
|
PTDEBUG && _d('Ascending only first column');
|
||||||
}
|
}
|
||||||
|
PTDEBUG && _d('Will ascend columns', join(', ', @asc_cols));
|
||||||
|
|
||||||
|
my @asc_slice;
|
||||||
my %col_posn = do { my $i = 0; map { $_ => $i++ } @cols };
|
my %col_posn = do { my $i = 0; map { $_ => $i++ } @cols };
|
||||||
foreach my $col ( @asc_cols ) {
|
foreach my $col ( @asc_cols ) {
|
||||||
if ( !exists $col_posn{$col} ) {
|
if ( !exists $col_posn{$col} ) {
|
||||||
@@ -6596,18 +6665,16 @@ sub make_checksum_query {
|
|||||||
sub find_replication_differences {
|
sub find_replication_differences {
|
||||||
my ( $self, $dbh, $table ) = @_;
|
my ( $self, $dbh, $table ) = @_;
|
||||||
|
|
||||||
(my $sql = <<" EOF") =~ s/\s+/ /gm;
|
my $sql
|
||||||
SELECT db, tbl, chunk, boundaries,
|
= "SELECT db, tbl, CONCAT(db, '.', tbl) AS `table`, "
|
||||||
COALESCE(this_cnt-master_cnt, 0) AS cnt_diff,
|
. "chunk, chunk_index, lower_boundary, upper_boundary, "
|
||||||
COALESCE(
|
. "COALESCE(this_cnt-master_cnt, 0) AS cnt_diff, "
|
||||||
this_crc <> master_crc OR ISNULL(master_crc) <> ISNULL(this_crc),
|
. "COALESCE("
|
||||||
0
|
. "this_crc <> master_crc OR ISNULL(master_crc) <> ISNULL(this_crc), 0"
|
||||||
) AS crc_diff,
|
. ") AS crc_diff, this_cnt, master_cnt, this_crc, master_crc "
|
||||||
this_cnt, master_cnt, this_crc, master_crc
|
. "FROM $table "
|
||||||
FROM $table
|
. "WHERE master_cnt <> this_cnt OR master_crc <> this_crc "
|
||||||
WHERE master_cnt <> this_cnt OR master_crc <> this_crc
|
. "OR ISNULL(master_crc) <> ISNULL(this_crc)";
|
||||||
OR ISNULL(master_crc) <> ISNULL(this_crc)
|
|
||||||
EOF
|
|
||||||
|
|
||||||
PTDEBUG && _d($sql);
|
PTDEBUG && _d($sql);
|
||||||
my $diffs = $dbh->selectall_arrayref($sql, { Slice => {} });
|
my $diffs = $dbh->selectall_arrayref($sql, { Slice => {} });
|
||||||
@@ -7016,11 +7083,12 @@ sub lock_and_wait {
|
|||||||
|
|
||||||
eval {
|
eval {
|
||||||
if ( my $timeout = $args{wait} ) {
|
if ( my $timeout = $args{wait} ) {
|
||||||
my $wait = $args{wait_retry_args}->{wait} || 10;
|
my $ms = $self->{MasterSlave};
|
||||||
my $tries = $args{wait_retry_args}->{tries} || 3;
|
my $tries = $args{wait_retry_args}->{tries} || 3;
|
||||||
|
my $wait;
|
||||||
$self->{Retry}->retry(
|
$self->{Retry}->retry(
|
||||||
wait => sub { sleep $wait; },
|
|
||||||
tries => $tries,
|
tries => $tries,
|
||||||
|
wait => sub { sleep $args{wait_retry_args}->{wait} || 10 },
|
||||||
try => sub {
|
try => sub {
|
||||||
my ( %args ) = @_;
|
my ( %args ) = @_;
|
||||||
|
|
||||||
@@ -7028,12 +7096,18 @@ sub lock_and_wait {
|
|||||||
warn "Retrying MASTER_POS_WAIT() for --wait $timeout...";
|
warn "Retrying MASTER_POS_WAIT() for --wait $timeout...";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $ms = $self->{MasterSlave};
|
$wait = $ms->wait_for_master(
|
||||||
my $wait = $ms->wait_for_master(
|
|
||||||
master_status => $ms->get_master_status($src->{misc_dbh}),
|
master_status => $ms->get_master_status($src->{misc_dbh}),
|
||||||
slave_dbh => $dst->{dbh},
|
slave_dbh => $dst->{dbh},
|
||||||
timeout => $timeout,
|
timeout => $timeout,
|
||||||
);
|
);
|
||||||
|
if ( defined $wait->{result} && $wait->{result} != -1 ) {
|
||||||
|
return; # slave caught up
|
||||||
|
}
|
||||||
|
die; # call fail
|
||||||
|
},
|
||||||
|
fail => sub {
|
||||||
|
my (%args) = @_;
|
||||||
if ( !defined $wait->{result} ) {
|
if ( !defined $wait->{result} ) {
|
||||||
my $msg;
|
my $msg;
|
||||||
if ( $wait->{waited} ) {
|
if ( $wait->{waited} ) {
|
||||||
@@ -7048,20 +7122,14 @@ sub lock_and_wait {
|
|||||||
$msg .= " Sleeping $wait seconds then retrying "
|
$msg .= " Sleeping $wait seconds then retrying "
|
||||||
. ($tries - $args{tryno}) . " more times.";
|
. ($tries - $args{tryno}) . " more times.";
|
||||||
}
|
}
|
||||||
warn $msg;
|
warn "$msg\n";
|
||||||
return;
|
return 1; # call wait, call try
|
||||||
}
|
}
|
||||||
elsif ( $wait->{result} == -1 ) {
|
elsif ( $wait->{result} == -1 ) {
|
||||||
die "Slave did not catch up to its master after waiting "
|
return 0; # call final_fail
|
||||||
. "$timeout seconds with MASTER_POS_WAIT. Try inceasing "
|
|
||||||
. "the --wait time, or disable this feature by specifying "
|
|
||||||
. "--wait 0.";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return $result; # slave caught up
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
on_failure => sub {
|
final_fail => sub {
|
||||||
die "Slave did not catch up to its master after $tries attempts "
|
die "Slave did not catch up to its master after $tries attempts "
|
||||||
. "of waiting $timeout seconds with MASTER_POS_WAIT. "
|
. "of waiting $timeout seconds with MASTER_POS_WAIT. "
|
||||||
. "Check that the slave is running, increase the --wait "
|
. "Check that the slave is running, increase the --wait "
|
||||||
@@ -8088,8 +8156,6 @@ sub get_result_set_struct {
|
|||||||
my @cols = @{$sth->{NAME}};
|
my @cols = @{$sth->{NAME}};
|
||||||
my @types = map { $dbh->type_info($_)->{TYPE_NAME} } @{$sth->{TYPE}};
|
my @types = map { $dbh->type_info($_)->{TYPE_NAME} } @{$sth->{TYPE}};
|
||||||
my @nullable = map { $dbh->type_info($_)->{NULLABLE} == 1 ? 1 : 0 } @{$sth->{TYPE}};
|
my @nullable = map { $dbh->type_info($_)->{NULLABLE} == 1 ? 1 : 0 } @{$sth->{TYPE}};
|
||||||
my @p = @{$sth->{PRECISION}};
|
|
||||||
my @s = @{$sth->{SCALE}};
|
|
||||||
|
|
||||||
my $struct = {
|
my $struct = {
|
||||||
cols => \@cols,
|
cols => \@cols,
|
||||||
@@ -8104,11 +8170,11 @@ sub get_result_set_struct {
|
|||||||
$struct->{is_nullable}->{$col} = $nullable[$i];
|
$struct->{is_nullable}->{$col} = $nullable[$i];
|
||||||
$struct->{is_numeric}->{$col}
|
$struct->{is_numeric}->{$col}
|
||||||
= ($type =~ m/(?:(?:tiny|big|medium|small)?int|float|double|decimal|year)/ ? 1 : 0);
|
= ($type =~ m/(?:(?:tiny|big|medium|small)?int|float|double|decimal|year)/ ? 1 : 0);
|
||||||
|
|
||||||
$struct->{size}->{$col}
|
$struct->{size}->{$col}
|
||||||
= ($type =~ m/(?:float|double)/) ? "($s[$i],$p[$i])"
|
= $type =~ m/(?:char|varchar)/ && $sth->{PRECISION}->[$i]
|
||||||
: ($type =~ m/(?:decimal)/) ? "($p[$i],$s[$i])"
|
? "($sth->{PRECISION}->[$i])"
|
||||||
: ($type =~ m/(?:char|varchar)/ && $p[$i]) ? "($p[$i])"
|
: undef;
|
||||||
: undef;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $struct;
|
return $struct;
|
||||||
@@ -8857,7 +8923,7 @@ $Data::Dumper::Quotekeys = 0;
|
|||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ( $class, %args ) = @_;
|
||||||
my @required_args = qw(method base-dir plugins get_id
|
my @required_args = qw(method base-dir plugins get_id
|
||||||
QueryParser MySQLDump TableParser TableSyncer Quoter);
|
QueryParser TableParser TableSyncer Quoter);
|
||||||
foreach my $arg ( @required_args ) {
|
foreach my $arg ( @required_args ) {
|
||||||
die "I need a $arg argument" unless $args{$arg};
|
die "I need a $arg argument" unless $args{$arg};
|
||||||
}
|
}
|
||||||
@@ -9454,7 +9520,6 @@ sub add_indexes {
|
|||||||
my $qp = $self->{QueryParser};
|
my $qp = $self->{QueryParser};
|
||||||
my $tp = $self->{TableParser};
|
my $tp = $self->{TableParser};
|
||||||
my $q = $self->{Quoter};
|
my $q = $self->{Quoter};
|
||||||
my $du = $self->{MySQLDump};
|
|
||||||
|
|
||||||
my @src_tbls = $qp->get_tables($query);
|
my @src_tbls = $qp->get_tables($query);
|
||||||
my @keys;
|
my @keys;
|
||||||
@@ -9464,8 +9529,11 @@ sub add_indexes {
|
|||||||
my $tbl_struct;
|
my $tbl_struct;
|
||||||
eval {
|
eval {
|
||||||
$tbl_struct = $tp->parse(
|
$tbl_struct = $tp->parse(
|
||||||
$du->get_create_table($dsts->[0]->{dbh}, $q, $db, $tbl)
|
$tp->get_create_table(
|
||||||
);
|
dbh => $dsts->[0]->{dbh},
|
||||||
|
db => $db,
|
||||||
|
tbl => $tbl,
|
||||||
|
));
|
||||||
};
|
};
|
||||||
if ( $EVAL_ERROR ) {
|
if ( $EVAL_ERROR ) {
|
||||||
PTDEBUG && _d('Error parsing', $db, '.', $tbl, ':', $EVAL_ERROR);
|
PTDEBUG && _d('Error parsing', $db, '.', $tbl, ':', $EVAL_ERROR);
|
||||||
@@ -10384,48 +10452,42 @@ sub new {
|
|||||||
|
|
||||||
sub retry {
|
sub retry {
|
||||||
my ( $self, %args ) = @_;
|
my ( $self, %args ) = @_;
|
||||||
my @required_args = qw(try wait);
|
my @required_args = qw(try fail final_fail);
|
||||||
foreach my $arg ( @required_args ) {
|
foreach my $arg ( @required_args ) {
|
||||||
die "I need a $arg argument" unless $args{$arg};
|
die "I need a $arg argument" unless $args{$arg};
|
||||||
};
|
};
|
||||||
my ($try, $wait) = @args{@required_args};
|
my ($try, $fail, $final_fail) = @args{@required_args};
|
||||||
|
my $wait = $args{wait} || sub { sleep 1; };
|
||||||
my $tries = $args{tries} || 3;
|
my $tries = $args{tries} || 3;
|
||||||
|
|
||||||
|
my $last_error;
|
||||||
my $tryno = 0;
|
my $tryno = 0;
|
||||||
|
TRY:
|
||||||
while ( ++$tryno <= $tries ) {
|
while ( ++$tryno <= $tries ) {
|
||||||
PTDEBUG && _d("Retry", $tryno, "of", $tries);
|
PTDEBUG && _d("Try", $tryno, "of", $tries);
|
||||||
my $result;
|
my $result;
|
||||||
eval {
|
eval {
|
||||||
$result = $try->(tryno=>$tryno);
|
$result = $try->(tryno=>$tryno);
|
||||||
};
|
};
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
PTDEBUG && _d("Try code failed:", $EVAL_ERROR);
|
||||||
|
$last_error = $EVAL_ERROR;
|
||||||
|
|
||||||
if ( defined $result ) {
|
if ( $tryno < $tries ) { # more retries
|
||||||
PTDEBUG && _d("Try code succeeded");
|
my $retry = $fail->(tryno=>$tryno, error=>$last_error);
|
||||||
if ( my $on_success = $args{on_success} ) {
|
last TRY unless $retry;
|
||||||
PTDEBUG && _d("Calling on_success code");
|
PTDEBUG && _d("Calling wait code");
|
||||||
$on_success->(tryno=>$tryno, result=>$result);
|
$wait->(tryno=>$tryno);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PTDEBUG && _d("Try code succeeded");
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $EVAL_ERROR ) {
|
|
||||||
PTDEBUG && _d("Try code died:", $EVAL_ERROR);
|
|
||||||
die $EVAL_ERROR unless $args{retry_on_die};
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $tryno < $tries ) {
|
|
||||||
PTDEBUG && _d("Try code failed, calling wait code");
|
|
||||||
$wait->(tryno=>$tryno);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PTDEBUG && _d("Try code did not succeed");
|
PTDEBUG && _d('Try code did not succeed');
|
||||||
if ( my $on_failure = $args{on_failure} ) {
|
return $final_fail->(error=>$last_error);
|
||||||
PTDEBUG && _d("Calling on_failure code");
|
|
||||||
$on_failure->();
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _d {
|
sub _d {
|
||||||
|
@@ -97,8 +97,6 @@ sub get_result_set_struct {
|
|||||||
my @cols = @{$sth->{NAME}};
|
my @cols = @{$sth->{NAME}};
|
||||||
my @types = map { $dbh->type_info($_)->{TYPE_NAME} } @{$sth->{TYPE}};
|
my @types = map { $dbh->type_info($_)->{TYPE_NAME} } @{$sth->{TYPE}};
|
||||||
my @nullable = map { $dbh->type_info($_)->{NULLABLE} == 1 ? 1 : 0 } @{$sth->{TYPE}};
|
my @nullable = map { $dbh->type_info($_)->{NULLABLE} == 1 ? 1 : 0 } @{$sth->{TYPE}};
|
||||||
my @p = @{$sth->{PRECISION}};
|
|
||||||
my @s = @{$sth->{SCALE}};
|
|
||||||
|
|
||||||
my $struct = {
|
my $struct = {
|
||||||
cols => \@cols,
|
cols => \@cols,
|
||||||
@@ -114,11 +112,16 @@ sub get_result_set_struct {
|
|||||||
$struct->{is_nullable}->{$col} = $nullable[$i];
|
$struct->{is_nullable}->{$col} = $nullable[$i];
|
||||||
$struct->{is_numeric}->{$col}
|
$struct->{is_numeric}->{$col}
|
||||||
= ($type =~ m/(?:(?:tiny|big|medium|small)?int|float|double|decimal|year)/ ? 1 : 0);
|
= ($type =~ m/(?:(?:tiny|big|medium|small)?int|float|double|decimal|year)/ ? 1 : 0);
|
||||||
|
|
||||||
|
# We no longer specify the (precision, scale) for double, float, and
|
||||||
|
# decimal because DBD::mysql isn't reliable and defaults should work.
|
||||||
|
# But char col sizes are important, e.g. varchar(16) and varchar(255)
|
||||||
|
# won't hold the same values.
|
||||||
|
# https://bugs.launchpad.net/percona-toolkit/+bug/926598
|
||||||
$struct->{size}->{$col}
|
$struct->{size}->{$col}
|
||||||
= ($type =~ m/(?:float|double)/) ? "($s[$i],$p[$i])"
|
= $type =~ m/(?:char|varchar)/ && $sth->{PRECISION}->[$i]
|
||||||
: ($type =~ m/(?:decimal)/) ? "($p[$i],$s[$i])"
|
? "($sth->{PRECISION}->[$i])"
|
||||||
: ($type =~ m/(?:char|varchar)/ && $p[$i]) ? "($p[$i])"
|
: undef;
|
||||||
: undef;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $struct;
|
return $struct;
|
||||||
|
@@ -169,8 +169,8 @@ SKIP: {
|
|||||||
size => {
|
size => {
|
||||||
id => undef,
|
id => undef,
|
||||||
i => undef,
|
i => undef,
|
||||||
f => '(31,12)',
|
f => undef,
|
||||||
d => $DBD::mysql::VERSION ge '4.001' ? '(7,2)' : '(7)',
|
d => undef,
|
||||||
dt => undef,
|
dt => undef,
|
||||||
ts => undef,
|
ts => undef,
|
||||||
c => '(1)',
|
c => '(1)',
|
||||||
|
@@ -16,12 +16,12 @@ use Sandbox;
|
|||||||
require "$trunk/bin/pt-upgrade";
|
require "$trunk/bin/pt-upgrade";
|
||||||
|
|
||||||
# This runs immediately if the server is already running, else it starts it.
|
# This runs immediately if the server is already running, else it starts it.
|
||||||
diag(`$trunk/sandbox/start-sandbox master 12347 >/dev/null`);
|
diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
|
||||||
|
|
||||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||||
my $dbh1 = $sb->get_dbh_for('master');
|
my $dbh1 = $sb->get_dbh_for('master');
|
||||||
my $dbh2 = $sb->get_dbh_for('slave2');
|
my $dbh2 = $sb->get_dbh_for('master1');
|
||||||
|
|
||||||
if ( !$dbh1 ) {
|
if ( !$dbh1 ) {
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
@@ -30,96 +30,109 @@ elsif ( !$dbh2 ) {
|
|||||||
plan skip_all => 'Cannot connect to second sandbox master';
|
plan skip_all => 'Cannot connect to second sandbox master';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plan tests => 10;
|
plan tests => 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sb->load_file('master', 't/pt-upgrade/samples/001/tables.sql');
|
my @host_args = ('h=127.1,P=12345', 'P=12348');
|
||||||
$sb->load_file('slave2', 't/pt-upgrade/samples/001/tables.sql');
|
my @op_args = (qw(-u msandbox -p msandbox),
|
||||||
|
'--compare', 'results,warnings',
|
||||||
|
'--zero-query-times',
|
||||||
|
);
|
||||||
|
my @args = (@host_args, @op_args);
|
||||||
|
my $sample = "t/pt-upgrade/samples";
|
||||||
|
my $log = "$trunk/$sample";
|
||||||
|
|
||||||
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12347 --compare results,warnings --zero-query-times";
|
# ###########################################################################
|
||||||
my @args = ('--compare', 'results,warnings', '--zero-query-times');
|
# Basic run.
|
||||||
my $sample = "$trunk/t/pt-upgrade/samples/";
|
# ###########################################################################
|
||||||
|
$sb->load_file('master', "$sample/001/tables.sql");
|
||||||
|
$sb->load_file('master1', "$sample/001/tables.sql");
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
"$cmd $trunk/t/pt-upgrade/samples/001/select-one.log",
|
sub { pt_upgrade::main(@args, "$log/001/select-one.log") },
|
||||||
't/pt-upgrade/samples/001/select-one.txt'
|
"$sample/001/select-one.txt",
|
||||||
),
|
),
|
||||||
'Report for a single query (checksum method)'
|
'Report for a single query (checksum method)'
|
||||||
);
|
);
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
"$cmd $trunk/t/pt-upgrade/samples/001/select-everyone.log",
|
sub { pt_upgrade::main(@args, "$log/001/select-everyone.log") },
|
||||||
't/pt-upgrade/samples/001/select-everyone.txt'
|
"$sample/001/select-everyone.txt"
|
||||||
),
|
),
|
||||||
'Report for multiple queries (checksum method)'
|
'Report for multiple queries (checksum method)'
|
||||||
);
|
);
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
"$cmd $trunk/t/pt-upgrade/samples/001/select-one.log --compare-results-method rows",
|
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-one.log",
|
||||||
't/pt-upgrade/samples/001/select-one-rows.txt'
|
"--compare-results-method", "rows") },
|
||||||
|
"$sample/001/select-one-rows.txt"
|
||||||
),
|
),
|
||||||
'Report for a single query (rows method)'
|
'Report for a single query (rows method)'
|
||||||
);
|
);
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
"$cmd $trunk/t/pt-upgrade/samples/001/select-everyone.log --compare-results-method rows",
|
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-everyone.log",
|
||||||
't/pt-upgrade/samples/001/select-everyone-rows.txt'
|
"--compare-results-method", "rows") },
|
||||||
|
"$sample/001/select-everyone-rows.txt"
|
||||||
),
|
),
|
||||||
'Report for multiple queries (rows method)'
|
'Report for multiple queries (rows method)'
|
||||||
);
|
);
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
"$cmd --reports queries,differences,errors $trunk/t/pt-upgrade/samples/001/select-everyone.log",
|
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-everyone.log",
|
||||||
't/pt-upgrade/samples/001/select-everyone-no-stats.txt'
|
"--reports", "queries,differences,errors") },
|
||||||
|
"$sample/001/select-everyone-no-stats.txt"
|
||||||
),
|
),
|
||||||
'Report without statistics'
|
'Report without statistics'
|
||||||
);
|
);
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
"$cmd --reports differences,errors,statistics $trunk/t/pt-upgrade/samples/001/select-everyone.log",
|
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-everyone.log",
|
||||||
't/pt-upgrade/samples/001/select-everyone-no-queries.txt'
|
"--reports", "differences,errors,statistics") },
|
||||||
|
"$sample/001/select-everyone-no-queries.txt"
|
||||||
),
|
),
|
||||||
'Report without per-query reports'
|
'Report without per-query reports'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$sb->wipe_clean($dbh1);
|
||||||
|
$sb->wipe_clean($dbh2);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Issue 951: mk-upgrade "I need a db argument" error with
|
# Issue 951: mk-upgrade "I need a db argument" error with
|
||||||
# compare-results-method=rows
|
# compare-results-method=rows
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$sb->load_file('master', 't/pt-upgrade/samples/002/tables.sql');
|
$sb->load_file('master', "$sample/002/tables.sql");
|
||||||
$sb->load_file('slave2', 't/pt-upgrade/samples/002/tables.sql');
|
$sb->load_file('master1', "$sample/002/tables.sql");
|
||||||
|
|
||||||
# Make a difference so diff_rows() is called.
|
# Make a difference on one host so diff_rows() is called.
|
||||||
$dbh1->do('insert into test.t values (5)');
|
$dbh1->do('insert into test.t values (5)');
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
sub { pt_upgrade::main(@args,
|
sub { pt_upgrade::main(@op_args, "$log/002/no-db.log",
|
||||||
'h=127.1,P=12345,u=msandbox,p=msandbox,D=test', 'P=12347,D=test',
|
'h=127.1,P=12345,D=test', 'P=12348,D=test',
|
||||||
"$sample/002/no-db.log",
|
|
||||||
qw(--compare-results-method rows --temp-database test)) },
|
qw(--compare-results-method rows --temp-database test)) },
|
||||||
't/pt-upgrade/samples/002/report-01.txt',
|
"$sample/002/report-01.txt",
|
||||||
),
|
),
|
||||||
'No db, compare results row, DSN D, --temp-database (issue 951)'
|
'No db, compare results row, DSN D, --temp-database (issue 951)'
|
||||||
);
|
);
|
||||||
|
|
||||||
$sb->load_file('master', 't/pt-upgrade/samples/002/tables.sql');
|
$sb->load_file('master', "$sample/002/tables.sql");
|
||||||
$sb->load_file('slave2', 't/pt-upgrade/samples/002/tables.sql');
|
$sb->load_file('master1', "$sample/002/tables.sql");
|
||||||
$dbh1->do('insert into test.t values (5)');
|
$dbh1->do('insert into test.t values (5)');
|
||||||
|
|
||||||
ok(
|
ok(
|
||||||
no_diff(
|
no_diff(
|
||||||
sub { pt_upgrade::main(@args,
|
sub { pt_upgrade::main(@op_args, "$log/002/no-db.log",
|
||||||
'h=127.1,P=12345,u=msandbox,p=msandbox,D=test', 'P=12347,D=test',
|
'h=127.1,P=12345,D=test', 'P=12348,D=test',
|
||||||
"$sample/002/no-db.log",
|
|
||||||
qw(--compare-results-method rows --temp-database tmp_db)) },
|
qw(--compare-results-method rows --temp-database tmp_db)) },
|
||||||
't/pt-upgrade/samples/002/report-01.txt',
|
"$sample/002/report-01.txt",
|
||||||
),
|
),
|
||||||
'No db, compare results row, DSN D'
|
'No db, compare results row, DSN D'
|
||||||
);
|
);
|
||||||
@@ -136,6 +149,35 @@ is_deeply(
|
|||||||
"Createed temp table in --temp-database"
|
"Createed temp table in --temp-database"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$sb->wipe_clean($dbh1);
|
||||||
|
$sb->wipe_clean($dbh2);
|
||||||
|
|
||||||
|
# #############################################################################
|
||||||
|
# Bug 926598: DBD::mysql bug causes pt-upgrade to use wrong
|
||||||
|
# precision (M) and scale (D)
|
||||||
|
# #############################################################################
|
||||||
|
$sb->load_file('master', "$sample/003/tables.sql");
|
||||||
|
$sb->load_file('master1', "$sample/003/tables.sql");
|
||||||
|
|
||||||
|
# Make a difference on one host so diff_rows() is called.
|
||||||
|
$dbh1->do('insert into test.t values (4, 1.00)');
|
||||||
|
|
||||||
|
ok(
|
||||||
|
no_diff(
|
||||||
|
sub { pt_upgrade::main(@args, "$log/003/double.log",
|
||||||
|
qw(--compare-results-method rows)) },
|
||||||
|
"$sample/003/report001.txt",
|
||||||
|
),
|
||||||
|
'M, D diff (bug 926598)',
|
||||||
|
);
|
||||||
|
|
||||||
|
my $row = $dbh1->selectrow_arrayref("show create table test.mk_upgrade_left");
|
||||||
|
like(
|
||||||
|
$row->[1],
|
||||||
|
qr/`SUM\(total\)`\s+double\sDEFAULT/,
|
||||||
|
"No M,D in table def (bug 926598)"
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
@@ -16,12 +16,12 @@ use Sandbox;
|
|||||||
require "$trunk/bin/pt-upgrade";
|
require "$trunk/bin/pt-upgrade";
|
||||||
|
|
||||||
# This runs immediately if the server is already running, else it starts it.
|
# This runs immediately if the server is already running, else it starts it.
|
||||||
diag(`$trunk/sandbox/start-sandbox master 12347 >/dev/null`);
|
diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
|
||||||
|
|
||||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||||
my $dbh1 = $sb->get_dbh_for('master');
|
my $dbh1 = $sb->get_dbh_for('master');
|
||||||
my $dbh2 = $sb->get_dbh_for('slave2');
|
my $dbh2 = $sb->get_dbh_for('master1');
|
||||||
|
|
||||||
if ( !$dbh1 ) {
|
if ( !$dbh1 ) {
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
@@ -33,7 +33,7 @@ else {
|
|||||||
plan tests => 1;
|
plan tests => 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12347 --compare results,warnings --zero-query-times";
|
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12348 --compare results,warnings --zero-query-times";
|
||||||
|
|
||||||
# Issue 391: Add --pid option to all scripts
|
# Issue 391: Add --pid option to all scripts
|
||||||
`touch /tmp/mk-script.pid`;
|
`touch /tmp/mk-script.pid`;
|
||||||
|
@@ -16,12 +16,12 @@ use Sandbox;
|
|||||||
require "$trunk/bin/pt-upgrade";
|
require "$trunk/bin/pt-upgrade";
|
||||||
|
|
||||||
# This runs immediately if the server is already running, else it starts it.
|
# This runs immediately if the server is already running, else it starts it.
|
||||||
diag(`$trunk/sandbox/start-sandbox master 12347 >/dev/null`);
|
diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
|
||||||
|
|
||||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||||
my $dbh1 = $sb->get_dbh_for('master');
|
my $dbh1 = $sb->get_dbh_for('master');
|
||||||
my $dbh2 = $sb->get_dbh_for('slave2');
|
my $dbh2 = $sb->get_dbh_for('master1');
|
||||||
|
|
||||||
if ( !$dbh1 ) {
|
if ( !$dbh1 ) {
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
@@ -34,11 +34,11 @@ else {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sb->load_file('master', 't/pt-upgrade/samples/001/tables.sql');
|
$sb->load_file('master', 't/pt-upgrade/samples/001/tables.sql');
|
||||||
$sb->load_file('slave2', 't/pt-upgrade/samples/001/tables.sql');
|
$sb->load_file('master1', 't/pt-upgrade/samples/001/tables.sql');
|
||||||
|
|
||||||
# Issue 747: Make mk-upgrade rewrite non-SELECT
|
# Issue 747: Make mk-upgrade rewrite non-SELECT
|
||||||
|
|
||||||
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345 P=12347 -u msandbox -p msandbox --compare results,warnings --zero-query-times --convert-to-select --fingerprints";
|
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345 P=12348 -u msandbox -p msandbox --compare results,warnings --zero-query-times --convert-to-select --fingerprints";
|
||||||
|
|
||||||
my $c1 = $dbh1->selectrow_arrayref('checksum table test.t')->[1];
|
my $c1 = $dbh1->selectrow_arrayref('checksum table test.t')->[1];
|
||||||
my $c2 = $dbh2->selectrow_arrayref('checksum table test.t')->[1];
|
my $c2 = $dbh2->selectrow_arrayref('checksum table test.t')->[1];
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
# warning counts 0
|
# warning counts 0
|
||||||
# warning levels 0
|
# warning levels 0
|
||||||
# warnings 0
|
# warnings 0
|
||||||
# 127.1:12345 127.1:12347
|
# 127.1:12345 127.1:12348
|
||||||
# Errors 0 0
|
# Errors 0 0
|
||||||
# Warnings 0 0
|
# Warnings 0 0
|
||||||
# Query_time
|
# Query_time
|
||||||
@@ -42,7 +42,7 @@ select * from t where id is not null
|
|||||||
# warning counts 0
|
# warning counts 0
|
||||||
# warning levels 0
|
# warning levels 0
|
||||||
# warnings 0
|
# warnings 0
|
||||||
# 127.1:12345 127.1:12347
|
# 127.1:12345 127.1:12348
|
||||||
# Errors 0 0
|
# Errors 0 0
|
||||||
# Warnings 0 0
|
# Warnings 0 0
|
||||||
# Query_time
|
# Query_time
|
||||||
@@ -75,7 +75,7 @@ select id from test.t where id > 3
|
|||||||
# warning counts 0
|
# warning counts 0
|
||||||
# warning levels 0
|
# warning levels 0
|
||||||
# warnings 0
|
# warnings 0
|
||||||
# 127.1:12345 127.1:12347
|
# 127.1:12345 127.1:12348
|
||||||
# Errors 0 0
|
# Errors 0 0
|
||||||
# Warnings 0 0
|
# Warnings 0 0
|
||||||
# Query_time
|
# Query_time
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
# warning counts 0
|
# warning counts 0
|
||||||
# warning levels 0
|
# warning levels 0
|
||||||
# warnings 0
|
# warnings 0
|
||||||
# 127.1:12345 127.1:12347
|
# 127.1:12345 127.1:12348
|
||||||
# Errors 0 0
|
# Errors 0 0
|
||||||
# Warnings 0 0
|
# Warnings 0 0
|
||||||
# Query_time
|
# Query_time
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
# warning counts 0
|
# warning counts 0
|
||||||
# warning levels 0
|
# warning levels 0
|
||||||
# warnings 0
|
# warnings 0
|
||||||
# P=12345,h=127.1,p=...,u=msandbox P=12347,h=127.1,p=...,u=msandbox
|
# P=12345,h=127.1,p=...,u=msandbox P=12348,h=127.1,p=...,u=msandbox
|
||||||
# Errors 1 1
|
# Errors 1 1
|
||||||
# Warnings 1 1
|
# Warnings 1 1
|
||||||
# Query_time
|
# Query_time
|
||||||
@@ -31,7 +31,7 @@ select borked
|
|||||||
# warning counts 0
|
# warning counts 0
|
||||||
# warning levels 0
|
# warning levels 0
|
||||||
# warnings 0
|
# warnings 0
|
||||||
# P=12345,h=127.1,p=...,u=msandbox P=12347,h=127.1,p=...,u=msandbox
|
# P=12345,h=127.1,p=...,u=msandbox P=12348,h=127.1,p=...,u=msandbox
|
||||||
# Errors 0 0
|
# Errors 0 0
|
||||||
# Warnings 0 0
|
# Warnings 0 0
|
||||||
# Query_time
|
# Query_time
|
||||||
@@ -55,7 +55,7 @@ select * from t where name='jane'
|
|||||||
# Errors
|
# Errors
|
||||||
# Query ID Host Error
|
# Query ID Host Error
|
||||||
# ================== ================================ ========================
|
# ================== ================================ ========================
|
||||||
# 3B323396273BC4C7-1 P=12347,h=127.1,p=...,u=msandbox Failed to execute query: DBD::mysql::st execute failed: Unknown column 'borked' in 'field list' [for Statement "select borked"] at mk-upgrade line 0, <$fh> line 2.
|
# 3B323396273BC4C7-1 P=12348,h=127.1,p=...,u=msandbox Failed to execute query: DBD::mysql::st execute failed: Unknown column 'borked' in 'field list' [for Statement "select borked"] at mk-upgrade line 0, <$fh> line 2.
|
||||||
|
|
||||||
# Statistics
|
# Statistics
|
||||||
# CompareResults_after_execute_skipped 2
|
# CompareResults_after_execute_skipped 2
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
# warning counts 0
|
# warning counts 0
|
||||||
# warning levels 0
|
# warning levels 0
|
||||||
# warnings 0
|
# warnings 0
|
||||||
# P=12345,h=127.1,p=...,u=msandbox P=12347,h=127.1,p=...,u=msandbox
|
# P=12345,h=127.1,p=...,u=msandbox P=12348,h=127.1,p=...,u=msandbox
|
||||||
# Errors 1 1
|
# Errors 1 1
|
||||||
# Warnings 0 0
|
# Warnings 0 0
|
||||||
# Query_time
|
# Query_time
|
||||||
@@ -31,7 +31,7 @@ select borked
|
|||||||
# warning counts 0
|
# warning counts 0
|
||||||
# warning levels 0
|
# warning levels 0
|
||||||
# warnings 0
|
# warnings 0
|
||||||
# P=12345,h=127.1,p=...,u=msandbox P=12347,h=127.1,p=...,u=msandbox
|
# P=12345,h=127.1,p=...,u=msandbox P=12348,h=127.1,p=...,u=msandbox
|
||||||
# Errors 0 0
|
# Errors 0 0
|
||||||
# Warnings 0 0
|
# Warnings 0 0
|
||||||
# Query_time
|
# Query_time
|
||||||
@@ -55,7 +55,7 @@ select * from t where name='jane'
|
|||||||
# Errors
|
# Errors
|
||||||
# Query ID Host Error
|
# Query ID Host Error
|
||||||
# ================== ================================ ========================
|
# ================== ================================ ========================
|
||||||
# 3B323396273BC4C7-1 P=12347,h=127.1,p=...,u=msandbox Failed to execute query: DBD::mysql::st execute failed: Unknown column 'borked' in 'field list' [for Statement "select borked"] at ../mk-upgrade line 7059, <$fh> line 2.
|
# 3B323396273BC4C7-1 P=12348,h=127.1,p=...,u=msandbox Failed to execute query: DBD::mysql::st execute failed: Unknown column 'borked' in 'field list' [for Statement "select borked"] at ../mk-upgrade line 7059, <$fh> line 2.
|
||||||
|
|
||||||
# Statistics
|
# Statistics
|
||||||
# CompareResults_after_execute_skipped 2
|
# CompareResults_after_execute_skipped 2
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
# warning counts 0
|
# warning counts 0
|
||||||
# warning levels 0
|
# warning levels 0
|
||||||
# warnings 0
|
# warnings 0
|
||||||
# 127.1:12345 127.1:12347
|
# 127.1:12345 127.1:12348
|
||||||
# Errors 0 0
|
# Errors 0 0
|
||||||
# Warnings 0 0
|
# Warnings 0 0
|
||||||
# Query_time
|
# Query_time
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
# warning counts 0
|
# warning counts 0
|
||||||
# warning levels 0
|
# warning levels 0
|
||||||
# warnings 0
|
# warnings 0
|
||||||
# 127.1:12345 127.1:12347
|
# 127.1:12345 127.1:12348
|
||||||
# Errors 0 0
|
# Errors 0 0
|
||||||
# Warnings 0 0
|
# Warnings 0 0
|
||||||
# Query_time
|
# Query_time
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
# warning counts 0
|
# warning counts 0
|
||||||
# warning levels 0
|
# warning levels 0
|
||||||
# warnings 0
|
# warnings 0
|
||||||
# 127.1:12345 127.1:12347
|
# 127.1:12345 127.1:12348
|
||||||
# Errors 0 0
|
# Errors 0 0
|
||||||
# Warnings 0 0
|
# Warnings 0 0
|
||||||
# Query_time
|
# Query_time
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
# warning counts 0
|
# warning counts 0
|
||||||
# warning levels 0
|
# warning levels 0
|
||||||
# warnings 0
|
# warnings 0
|
||||||
# 127.1:12345 127.1:12347
|
# 127.1:12345 127.1:12348
|
||||||
# Errors 0 0
|
# Errors 0 0
|
||||||
# Warnings 0 0
|
# Warnings 0 0
|
||||||
# Query_time
|
# Query_time
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
# warning counts 0
|
# warning counts 0
|
||||||
# warning levels 0
|
# warning levels 0
|
||||||
# warnings 0
|
# warnings 0
|
||||||
# 127.1:12345 127.1:12347
|
# 127.1:12345 127.1:12348
|
||||||
# Errors 0 0
|
# Errors 0 0
|
||||||
# Warnings 0 0
|
# Warnings 0 0
|
||||||
# Query_time
|
# Query_time
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
# warning counts 0
|
# warning counts 0
|
||||||
# warning levels 0
|
# warning levels 0
|
||||||
# warnings 0
|
# warnings 0
|
||||||
# 127.1:12345 127.1:12347
|
# 127.1:12345 127.1:12348
|
||||||
# Errors 0 0
|
# Errors 0 0
|
||||||
# Warnings 0 0
|
# Warnings 0 0
|
||||||
# Query_time
|
# Query_time
|
||||||
@@ -34,7 +34,7 @@ select i from t where i is not null
|
|||||||
|
|
||||||
|
|
||||||
# Row count differences
|
# Row count differences
|
||||||
# Query ID 127.1:12345 127.1:12347
|
# Query ID 127.1:12345 127.1:12348
|
||||||
# ================== =========== ===========
|
# ================== =========== ===========
|
||||||
# 3C830E3839B916D7-1 4 3
|
# 3C830E3839B916D7-1 4 3
|
||||||
|
|
||||||
|
4
t/pt-upgrade/samples/003/double.log
Normal file
4
t/pt-upgrade/samples/003/double.log
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# User@Host: root[root] @ localhost []
|
||||||
|
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
||||||
|
use test;
|
||||||
|
SELECT SUM(total) FROM test.t WHERE id > 0
|
42
t/pt-upgrade/samples/003/report001.txt
Normal file
42
t/pt-upgrade/samples/003/report001.txt
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
# Query 1: ID 0xC1B1E457814417E4 at byte 0 _______________________________
|
||||||
|
# Found 1 differences in 1 samples:
|
||||||
|
# column counts 0
|
||||||
|
# column types 0
|
||||||
|
# column values 1
|
||||||
|
# row counts 0
|
||||||
|
# warning counts 0
|
||||||
|
# warning levels 0
|
||||||
|
# warnings 0
|
||||||
|
# 127.1:12345 127.1:12348
|
||||||
|
# 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 SUM(total) FROM test.t WHERE id > 0
|
||||||
|
|
||||||
|
/* C1B1E457814417E4-1 */ SELECT SUM(total) FROM test.t WHERE id > 0
|
||||||
|
|
||||||
|
|
||||||
|
# Column value differences
|
||||||
|
# Query ID Column 127.1:12345 127.1:12348
|
||||||
|
# ================== ========== =========== ===========
|
||||||
|
# C1B1E457814417E4-1 SUM(total) 14.68 13.68
|
||||||
|
|
||||||
|
# Statistics
|
||||||
|
# events 1
|
11
t/pt-upgrade/samples/003/tables.sql
Normal file
11
t/pt-upgrade/samples/003/tables.sql
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
DROP DATABASE IF EXISTS test;
|
||||||
|
CREATE DATABASE test;
|
||||||
|
USE test;
|
||||||
|
CREATE TABLE t (
|
||||||
|
id INT NOT NULL PRIMARY KEY,
|
||||||
|
total DOUBLE NOT NULL
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
INSERT INTO test.t VALUES
|
||||||
|
(1, 1.23),
|
||||||
|
(2, 4.56),
|
||||||
|
(3, 7.89);
|
@@ -16,12 +16,12 @@ use Sandbox;
|
|||||||
require "$trunk/bin/pt-upgrade";
|
require "$trunk/bin/pt-upgrade";
|
||||||
|
|
||||||
# This runs immediately if the server is already running, else it starts it.
|
# This runs immediately if the server is already running, else it starts it.
|
||||||
diag(`$trunk/sandbox/start-sandbox master 12347 >/dev/null`);
|
diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
|
||||||
|
|
||||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||||
my $dbh1 = $sb->get_dbh_for('master');
|
my $dbh1 = $sb->get_dbh_for('master');
|
||||||
my $dbh2 = $sb->get_dbh_for('slave2');
|
my $dbh2 = $sb->get_dbh_for('master1');
|
||||||
|
|
||||||
if ( !$dbh1 ) {
|
if ( !$dbh1 ) {
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
@@ -34,9 +34,9 @@ else {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sb->load_file('master', 't/pt-upgrade/samples/001/tables.sql');
|
$sb->load_file('master', 't/pt-upgrade/samples/001/tables.sql');
|
||||||
$sb->load_file('slave2', 't/pt-upgrade/samples/001/tables.sql');
|
$sb->load_file('master1', 't/pt-upgrade/samples/001/tables.sql');
|
||||||
|
|
||||||
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12347 --compare results,warnings --zero-query-times";
|
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12348 --compare results,warnings --zero-query-times";
|
||||||
|
|
||||||
# Test that non-SELECT queries are skipped by default.
|
# Test that non-SELECT queries are skipped by default.
|
||||||
ok(
|
ok(
|
||||||
|
@@ -16,12 +16,12 @@ use Sandbox;
|
|||||||
require "$trunk/bin/pt-upgrade";
|
require "$trunk/bin/pt-upgrade";
|
||||||
|
|
||||||
# This runs immediately if the server is already running, else it starts it.
|
# This runs immediately if the server is already running, else it starts it.
|
||||||
diag(`$trunk/sandbox/start-sandbox master 12347 >/dev/null`);
|
diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
|
||||||
|
|
||||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||||
my $dbh1 = $sb->get_dbh_for('master');
|
my $dbh1 = $sb->get_dbh_for('master');
|
||||||
my $dbh2 = $sb->get_dbh_for('slave2');
|
my $dbh2 = $sb->get_dbh_for('master1');
|
||||||
|
|
||||||
if ( !$dbh1 ) {
|
if ( !$dbh1 ) {
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
@@ -34,10 +34,10 @@ else {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sb->load_file('master', 't/pt-upgrade/samples/001/tables.sql');
|
$sb->load_file('master', 't/pt-upgrade/samples/001/tables.sql');
|
||||||
$sb->load_file('slave2', 't/pt-upgrade/samples/001/tables.sql');
|
$sb->load_file('master1', 't/pt-upgrade/samples/001/tables.sql');
|
||||||
|
|
||||||
my $output;
|
my $output;
|
||||||
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12347 --compare results,warnings --zero-query-times --compare-results-method rows --limit 10";
|
my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12348 --compare results,warnings --zero-query-times --compare-results-method rows --limit 10";
|
||||||
|
|
||||||
# This test really deals with,
|
# This test really deals with,
|
||||||
# http://code.google.com/p/maatkit/issues/detail?id=754
|
# http://code.google.com/p/maatkit/issues/detail?id=754
|
||||||
@@ -63,7 +63,7 @@ diag(`$cmd $trunk/t/pt-upgrade/samples/001/one-error.log >/dev/null 2>&1`);
|
|||||||
$output = `$cmd $trunk/t/pt-upgrade/samples/001/one-error.log`;
|
$output = `$cmd $trunk/t/pt-upgrade/samples/001/one-error.log`;
|
||||||
like(
|
like(
|
||||||
$output,
|
$output,
|
||||||
qr/# 3B323396273BC4C7-1 127.1:12347 Failed to execute query.+Unknown column 'borked' in 'field list' \[for Statement "select borked"\] at .+?\n\n/,
|
qr/# 3B323396273BC4C7-1 127.1:12348 Failed to execute query.+Unknown column 'borked' in 'field list' \[for Statement "select borked"\] at .+?\n\n/,
|
||||||
'--clear-warnings',
|
'--clear-warnings',
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ like(
|
|||||||
$output = `$cmd --no-clear-warnings $trunk/t/pt-upgrade/samples/001/one-error.log`;
|
$output = `$cmd --no-clear-warnings $trunk/t/pt-upgrade/samples/001/one-error.log`;
|
||||||
like(
|
like(
|
||||||
$output,
|
$output,
|
||||||
qr/# 3B323396273BC4C7-1 127.1:12347 Failed to execute query.+Unknown column 'borked' in 'field list' \[for Statement "select borked"\] at .+?\n\n/,
|
qr/# 3B323396273BC4C7-1 127.1:12348 Failed to execute query.+Unknown column 'borked' in 'field list' \[for Statement "select borked"\] at .+?\n\n/,
|
||||||
'--no-clear-warnings'
|
'--no-clear-warnings'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user