mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-19 00:43:58 +00:00
Updated the fles in /lib to use the new VersionParser
This commit is contained in:
@@ -279,8 +279,7 @@ sub get_connected_slaves {
|
|||||||
# user with USER(), quote it, and then add it to statement.
|
# user with USER(), quote it, and then add it to statement.
|
||||||
my $show = "SHOW GRANTS FOR ";
|
my $show = "SHOW GRANTS FOR ";
|
||||||
my $user = 'CURRENT_USER()';
|
my $user = 'CURRENT_USER()';
|
||||||
my $vp = $self->{VersionParser};
|
if ( VersionParser->new($dbh) < '4.1.2' ) {
|
||||||
if ( $vp && !$vp->version_ge($dbh, '4.1.2') ) {
|
|
||||||
$user = $dbh->selectrow_arrayref('SELECT USER()')->[0];
|
$user = $dbh->selectrow_arrayref('SELECT USER()')->[0];
|
||||||
$user =~ s/([^@]+)@(.+)/'$1'\@'$2'/;
|
$user =~ s/([^@]+)@(.+)/'$1'\@'$2'/;
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,7 @@ our %ALGOS = (
|
|||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ( $class, %args ) = @_;
|
||||||
foreach my $arg ( qw(Quoter VersionParser) ) {
|
foreach my $arg ( qw(Quoter) ) {
|
||||||
die "I need a $arg argument" unless defined $args{$arg};
|
die "I need a $arg argument" unless defined $args{$arg};
|
||||||
}
|
}
|
||||||
my $self = { %args };
|
my $self = { %args };
|
||||||
@@ -107,23 +107,24 @@ sub get_crc_type {
|
|||||||
sub best_algorithm {
|
sub best_algorithm {
|
||||||
my ( $self, %args ) = @_;
|
my ( $self, %args ) = @_;
|
||||||
my ( $alg, $dbh ) = @args{ qw(algorithm dbh) };
|
my ( $alg, $dbh ) = @args{ qw(algorithm dbh) };
|
||||||
my $vp = $self->{VersionParser};
|
|
||||||
my @choices = sort { $ALGOS{$a}->{pref} <=> $ALGOS{$b}->{pref} } keys %ALGOS;
|
my @choices = sort { $ALGOS{$a}->{pref} <=> $ALGOS{$b}->{pref} } keys %ALGOS;
|
||||||
die "Invalid checksum algorithm $alg"
|
die "Invalid checksum algorithm $alg"
|
||||||
if $alg && !$ALGOS{$alg};
|
if $alg && !$ALGOS{$alg};
|
||||||
|
|
||||||
|
my $version = VersionParser->new($dbh);
|
||||||
|
|
||||||
# CHECKSUM is eliminated by lots of things...
|
# CHECKSUM is eliminated by lots of things...
|
||||||
if (
|
if (
|
||||||
$args{where} || $args{chunk} # CHECKSUM does whole table
|
$args{where} || $args{chunk} # CHECKSUM does whole table
|
||||||
|| $args{replicate} # CHECKSUM can't do INSERT.. SELECT
|
|| $args{replicate} # CHECKSUM can't do INSERT.. SELECT
|
||||||
|| !$vp->version_ge($dbh, '4.1.1')) # CHECKSUM doesn't exist
|
|| $version < '4.1.1') # CHECKSUM doesn't exist
|
||||||
{
|
{
|
||||||
PTDEBUG && _d('Cannot use CHECKSUM algorithm');
|
PTDEBUG && _d('Cannot use CHECKSUM algorithm');
|
||||||
@choices = grep { $_ ne 'CHECKSUM' } @choices;
|
@choices = grep { $_ ne 'CHECKSUM' } @choices;
|
||||||
}
|
}
|
||||||
|
|
||||||
# BIT_XOR isn't available till 4.1.1 either
|
# BIT_XOR isn't available till 4.1.1 either
|
||||||
if ( !$vp->version_ge($dbh, '4.1.1') ) {
|
if ( $version < '4.1.1' ) {
|
||||||
PTDEBUG && _d('Cannot use BIT_XOR algorithm because MySQL < 4.1.1');
|
PTDEBUG && _d('Cannot use BIT_XOR algorithm because MySQL < 4.1.1');
|
||||||
@choices = grep { $_ ne 'BIT_XOR' } @choices;
|
@choices = grep { $_ ne 'BIT_XOR' } @choices;
|
||||||
}
|
}
|
||||||
|
@@ -27,8 +27,7 @@
|
|||||||
#
|
#
|
||||||
# And some subs have an optional $opts param which is a hashref of options.
|
# And some subs have an optional $opts param which is a hashref of options.
|
||||||
# $opts->{mysql_version} is typically used, which is the return value from
|
# $opts->{mysql_version} is typically used, which is the return value from
|
||||||
# VersionParser::parser() (which returns a zero-padded MySQL version,
|
# VersionParser->new()
|
||||||
# e.g. 004001000 for 4.1.0).
|
|
||||||
package TableParser;
|
package TableParser;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
@@ -421,7 +420,7 @@ sub get_keys {
|
|||||||
my ( $type, $cols ) = $key =~ m/(?:USING (\w+))? \((.+)\)/;
|
my ( $type, $cols ) = $key =~ m/(?:USING (\w+))? \((.+)\)/;
|
||||||
my ( $special ) = $key =~ m/(FULLTEXT|SPATIAL)/;
|
my ( $special ) = $key =~ m/(FULLTEXT|SPATIAL)/;
|
||||||
$type = $type || $special || 'BTREE';
|
$type = $type || $special || 'BTREE';
|
||||||
if ( $opts->{mysql_version} && $opts->{mysql_version} lt '004001000'
|
if ( $opts->{mysql_version} && $opts->{mysql_version} lt '4.1'
|
||||||
&& $engine =~ m/HEAP|MEMORY/i )
|
&& $engine =~ m/HEAP|MEMORY/i )
|
||||||
{
|
{
|
||||||
$type = 'HASH'; # MySQL pre-4.1 supports only HASH indexes on HEAP
|
$type = 'HASH'; # MySQL pre-4.1 supports only HASH indexes on HEAP
|
||||||
|
@@ -35,13 +35,12 @@ $Data::Dumper::Quotekeys = 0;
|
|||||||
# Arguments:
|
# Arguments:
|
||||||
# * MasterSlave A MasterSlave module
|
# * MasterSlave A MasterSlave module
|
||||||
# * Quoter A Quoter module
|
# * Quoter A Quoter module
|
||||||
# * VersionParser A VersionParser module
|
|
||||||
# * TableChecksum A TableChecksum module
|
# * TableChecksum A TableChecksum module
|
||||||
# * Retry A Retry module
|
# * Retry A Retry module
|
||||||
# * DSNParser (optional)
|
# * DSNParser (optional)
|
||||||
sub new {
|
sub new {
|
||||||
my ( $class, %args ) = @_;
|
my ( $class, %args ) = @_;
|
||||||
my @required_args = qw(MasterSlave Quoter VersionParser TableChecksum Retry);
|
my @required_args = qw(MasterSlave Quoter TableChecksum Retry);
|
||||||
foreach my $arg ( @required_args ) {
|
foreach my $arg ( @required_args ) {
|
||||||
die "I need a $arg argument" unless defined $args{$arg};
|
die "I need a $arg argument" unless defined $args{$arg};
|
||||||
}
|
}
|
||||||
@@ -127,7 +126,6 @@ sub sync_table {
|
|||||||
$args{timeout_ok} ||= 0;
|
$args{timeout_ok} ||= 0;
|
||||||
|
|
||||||
my $q = $self->{Quoter};
|
my $q = $self->{Quoter};
|
||||||
my $vp = $self->{VersionParser};
|
|
||||||
|
|
||||||
# ########################################################################
|
# ########################################################################
|
||||||
# Get and prepare the first plugin that can sync this table.
|
# Get and prepare the first plugin that can sync this table.
|
||||||
@@ -145,8 +143,8 @@ sub sync_table {
|
|||||||
# Make an index hint for either the explicitly given chunk_index
|
# Make an index hint for either the explicitly given chunk_index
|
||||||
# or the chunk_index chosen by the plugin if index_hint is true.
|
# or the chunk_index chosen by the plugin if index_hint is true.
|
||||||
my $index_hint;
|
my $index_hint;
|
||||||
my $hint = ($vp->version_ge($src->{dbh}, '4.0.9')
|
my $hint = ((VersionParser->new($src->{dbh}) >= '4.0.9'
|
||||||
&& $vp->version_ge($dst->{dbh}, '4.0.9') ? 'FORCE' : 'USE')
|
&& VersionParser->new($dst->{dbh}) >= '4.0.9') ? 'FORCE' : 'USE')
|
||||||
. ' INDEX';
|
. ' INDEX';
|
||||||
if ( $args{chunk_index} ) {
|
if ( $args{chunk_index} ) {
|
||||||
PTDEBUG && _d('Using given chunk index for index hint');
|
PTDEBUG && _d('Using given chunk index for index hint');
|
||||||
|
@@ -539,27 +539,11 @@ sub get_rules {
|
|||||||
my ( %args ) = @_;
|
my ( %args ) = @_;
|
||||||
my $mysql_version = $args{mysql_version};
|
my $mysql_version = $args{mysql_version};
|
||||||
return 0 unless $mysql_version;
|
return 0 unless $mysql_version;
|
||||||
my ($major, $minor, $patch) = $mysql_version =~ m/(\d{3})/g;
|
return 1 if ($mysql_version eq '3' && $mysql_version lt '3.23')
|
||||||
if ( $major eq '003' ) {
|
|| ($mysql_version eq '4' && $mysql_version lt '4.1.20')
|
||||||
return $mysql_version lt '003023000' ? 1 : 0; # 3.23.x
|
|| ($mysql_version eq '5.0' && $mysql_version lt '5.0.37')
|
||||||
}
|
|| ($mysql_version eq '5.1' && $mysql_version lt '5.1.30');
|
||||||
elsif ( $major eq '004' ) {
|
|
||||||
return $mysql_version lt '004001020' ? 1 : 0; # 4.1.20
|
|
||||||
}
|
|
||||||
elsif ( $major eq '005' ) {
|
|
||||||
if ( $minor eq '000' ) {
|
|
||||||
return $mysql_version lt '005000037' ? 1 : 0; # 5.0.37
|
|
||||||
}
|
|
||||||
elsif ( $minor eq '001' ) {
|
|
||||||
return $mysql_version lt '005001030' ? 1 : 0; # 5.1.30
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -568,7 +552,7 @@ sub get_rules {
|
|||||||
my ( %args ) = @_;
|
my ( %args ) = @_;
|
||||||
my $mysql_version = $args{mysql_version};
|
my $mysql_version = $args{mysql_version};
|
||||||
return 0 unless $mysql_version;
|
return 0 unless $mysql_version;
|
||||||
return $mysql_version lt '005001000' ? 1 : 0; # 5.1.x
|
return $mysql_version lt '5.1' ? 1 : 0; # 5.1.x
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user