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"
if $alg && !$ALGOS{$alg};
my $version = VersionParser->new($dbh);
# CHECKSUM is eliminated by lots of things...
if (
$args{where} || $args{chunk} # CHECKSUM does whole table
|| $args{replicate} # CHECKSUM can't do INSERT.. SELECT
|| $version < '4.1.1') # CHECKSUM doesn't exist
|| $args{replicate}) # CHECKSUM can't do INSERT.. SELECT
{
PTDEBUG && _d('Cannot use CHECKSUM algorithm');
@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.
if ( $alg && grep { $_ eq $alg } @choices ) {

View File

@@ -26,8 +26,6 @@
# $tbl is the return value from the sub below, parse().
#
# 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;
use strict;
@@ -420,12 +418,6 @@ sub get_keys {
my ( $type, $cols ) = $key =~ m/(?:USING (\w+))? \((.+)\)/;
my ( $special ) = $key =~ m/(FULLTEXT|SPATIAL)/;
$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 $unique = $key =~ m/PRIMARY|UNIQUE/ ? 1 : 0;
my @cols;

View File

@@ -143,16 +143,13 @@ sub sync_table {
# Make an index hint for either the explicitly given chunk_index
# or the chunk_index chosen by the plugin if index_hint is true.
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} ) {
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} ) {
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);

View File

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