Remove MySQL 4.0 checks from several libraries, losing the VP dependency

This commit is contained in:
Brian Fraser
2012-07-19 13:19:26 -03:00
parent de625a873c
commit 64c14e18f4
4 changed files with 7 additions and 27 deletions

View File

@@ -111,23 +111,15 @@ sub best_algorithm {
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
|| $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
if ( $version < '4.1.1' ) {
PTDEBUG && _d('Cannot use BIT_XOR algorithm because MySQL < 4.1.1');
@choices = grep { $_ ne 'BIT_XOR' } @choices;
}
# Choose the best (fastest) among the remaining choices. # Choose the best (fastest) among the remaining choices.
if ( $alg && grep { $_ eq $alg } @choices ) { if ( $alg && grep { $_ eq $alg } @choices ) {

View File

@@ -26,8 +26,6 @@
# $tbl is the return value from the sub below, parse(). # $tbl is the return value from the sub below, parse().
# #
# 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
# VersionParser->new()
package TableParser; package TableParser;
use strict; use strict;
@@ -420,12 +418,6 @@ 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 '4.1'
&& $engine =~ m/HEAP|MEMORY/i )
{
$type = 'HASH'; # MySQL pre-4.1 supports only HASH indexes on HEAP
}
my ($name) = $key =~ m/(PRIMARY|`[^`]*`)/; my ($name) = $key =~ m/(PRIMARY|`[^`]*`)/;
my $unique = $key =~ m/PRIMARY|UNIQUE/ ? 1 : 0; my $unique = $key =~ m/PRIMARY|UNIQUE/ ? 1 : 0;
my @cols; my @cols;

View File

@@ -143,16 +143,13 @@ 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 = ((VersionParser->new($src->{dbh}) >= '4.0.9'
&& VersionParser->new($dst->{dbh}) >= '4.0.9') ? 'FORCE' : 'USE')
. ' 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');
$index_hint = "$hint (" . $q->quote($args{chunk_index}) . ")"; $index_hint = "FORCE INDEX (" . $q->quote($args{chunk_index}) . ")";
} }
elsif ( $plugin_args{chunk_index} && $args{index_hint} ) { elsif ( $plugin_args{chunk_index} && $args{index_hint} ) {
PTDEBUG && _d('Using chunk index chosen by plugin for index hint'); PTDEBUG && _d('Using chunk index chosen by plugin for index hint');
$index_hint = "$hint (" . $q->quote($plugin_args{chunk_index}) . ")"; $index_hint = "FORCE INDEX (" . $q->quote($plugin_args{chunk_index}) . ")";
} }
PTDEBUG && _d('Index hint:', $index_hint); PTDEBUG && _d('Index hint:', $index_hint);

View File

@@ -11,7 +11,6 @@ use warnings FATAL => 'all';
use English qw(-no_match_vars); use English qw(-no_match_vars);
use Test::More; use Test::More;
use VersionParser;
use TableChecksum; use TableChecksum;
use TableParser; use TableParser;
use Quoter; use Quoter;
@@ -118,8 +117,8 @@ is (
algorithm => 'CHECKSUM', algorithm => 'CHECKSUM',
dbh => '4.0.0', dbh => '4.0.0',
), ),
'ACCUM', 'CHECKSUM',
'CHECKSUM and BIT_XOR eliminated by version', 'Ignore version, always use CHECKSUM',
); );
is ( is (
@@ -136,8 +135,8 @@ is (
algorithm => 'BIT_XOR', algorithm => 'BIT_XOR',
dbh => '4.0.0', dbh => '4.0.0',
), ),
'ACCUM', 'BIT_XOR',
'BIT_XOR eliminated by version', 'Ignore version, always use BIT_XOR',
); );
is ( is (