mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 21:19:59 +00:00
PT-1860 make pt-osc respect case insesitive lookup on Windows and osx #516
- Run update-modules - Adjusted fix, so it does not create extra variable to hold $EVAL_ERROR - Adjusted test case, so it runs on Linux
This commit is contained in:
@@ -3470,11 +3470,29 @@ sub check_table {
|
|||||||
}
|
}
|
||||||
my ($dbh, $db, $tbl) = @args{@required_args};
|
my ($dbh, $db, $tbl) = @args{@required_args};
|
||||||
my $q = $self->{Quoter} || 'Quoter';
|
my $q = $self->{Quoter} || 'Quoter';
|
||||||
|
$self->{check_table_error} = undef;
|
||||||
|
|
||||||
|
|
||||||
|
my $lctn_sql = 'SELECT @@lower_case_table_names';
|
||||||
|
PTDEBUG && _d($lctn_sql);
|
||||||
|
|
||||||
|
my $lower_case_table_names;
|
||||||
|
eval { ($lower_case_table_names) = $dbh->selectrow_array($lctn_sql); };
|
||||||
|
if ( $EVAL_ERROR ) {
|
||||||
|
PTDEBUG && _d($EVAL_ERROR);
|
||||||
|
$self->{check_table_error} = $EVAL_ERROR;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PTDEBUG && _d("lower_case_table_names=$lower_case_table_names");
|
||||||
|
if ($lower_case_table_names > 0) {
|
||||||
|
PTDEBUG && _d("MySQL uses case-insensitive lookup, converting '$tbl' to lowercase");
|
||||||
|
$tbl = lc $tbl;
|
||||||
|
}
|
||||||
|
|
||||||
my $db_tbl = $q->quote($db, $tbl);
|
my $db_tbl = $q->quote($db, $tbl);
|
||||||
PTDEBUG && _d('Checking', $db_tbl);
|
PTDEBUG && _d('Checking', $db_tbl);
|
||||||
|
|
||||||
$self->{check_table_error} = undef;
|
|
||||||
|
|
||||||
my $sql = "SHOW TABLES FROM " . $q->quote($db)
|
my $sql = "SHOW TABLES FROM " . $q->quote($db)
|
||||||
. ' LIKE ' . $q->literal_like($tbl);
|
. ' LIKE ' . $q->literal_like($tbl);
|
||||||
PTDEBUG && _d($sql);
|
PTDEBUG && _d($sql);
|
||||||
|
@@ -339,9 +339,9 @@ sub check_table {
|
|||||||
|
|
||||||
my $lower_case_table_names;
|
my $lower_case_table_names;
|
||||||
eval { ($lower_case_table_names) = $dbh->selectrow_array($lctn_sql); };
|
eval { ($lower_case_table_names) = $dbh->selectrow_array($lctn_sql); };
|
||||||
if ( my $e = $EVAL_ERROR ) {
|
if ( $EVAL_ERROR ) {
|
||||||
PTDEBUG && _d($e);
|
PTDEBUG && _d($EVAL_ERROR);
|
||||||
$self->{check_table_error} = $e;
|
$self->{check_table_error} = $EVAL_ERROR;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,19 +12,11 @@ use English qw(-no_match_vars);
|
|||||||
use Test::More;
|
use Test::More;
|
||||||
use Time::HiRes qw(sleep);
|
use Time::HiRes qw(sleep);
|
||||||
|
|
||||||
$ENV{PTTEST_FAKE_TS} = 1;
|
|
||||||
$ENV{PERCONA_TOOLKIT_TEST_USE_DSN_NAMES} = 1;
|
|
||||||
|
|
||||||
use PerconaTest;
|
use PerconaTest;
|
||||||
use Sandbox;
|
use Sandbox;
|
||||||
require "$trunk/bin/pt-online-schema-change";
|
require "$trunk/bin/pt-online-schema-change";
|
||||||
require VersionParser;
|
require VersionParser;
|
||||||
|
|
||||||
use Data::Dumper;
|
|
||||||
$Data::Dumper::Indent = 1;
|
|
||||||
$Data::Dumper::Sortkeys = 1;
|
|
||||||
$Data::Dumper::Quotekeys = 0;
|
|
||||||
|
|
||||||
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 $master_dbh = $sb->get_dbh_for('master');
|
my $master_dbh = $sb->get_dbh_for('master');
|
||||||
@@ -33,23 +25,25 @@ if ( !$master_dbh ) {
|
|||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox master';
|
||||||
}
|
}
|
||||||
|
|
||||||
my $q = new Quoter();
|
|
||||||
my $tp = new TableParser(Quoter => $q);
|
|
||||||
my @args = qw(--set-vars innodb_lock_wait_timeout=3);
|
my @args = qw(--set-vars innodb_lock_wait_timeout=3);
|
||||||
my $output = "";
|
my $output = "";
|
||||||
my $dsn = "h=127.1,P=12345,u=msandbox,p=msandbox";
|
my $dsn = "h=127.1,P=12345,u=msandbox,p=msandbox";
|
||||||
my $exit = 0;
|
my $exit = 0;
|
||||||
my $sample = "t/pt-online-schema-change/samples";
|
my $sample = "t/pt-online-schema-change/samples";
|
||||||
my $rows;
|
|
||||||
|
|
||||||
# #############################################################################
|
my $lower_case_table_names = $master_dbh->selectrow_array('SELECT @@lower_case_table_names');
|
||||||
# Tool shouldn't run without --execute (bug 933232).
|
|
||||||
# #############################################################################
|
|
||||||
|
|
||||||
my ($lower_case_table_names) = $master_dbh->selectrow_array('SELECT @@lower_case_table_names');
|
if ( $lower_case_table_names == 0) {
|
||||||
plan skip_all => 'MySQL uses case sensitive lookup' if $lower_case_table_names == 0;
|
# Preparing test setup on Linux
|
||||||
|
diag(`$trunk/sandbox/stop-sandbox 12348 >/dev/null`);
|
||||||
|
diag(`EXTRA_DEFAULTS_FILE="$trunk/t/pt-online-schema-change/samples/lower_case_table_names_1.cnf" $trunk/sandbox/start-sandbox master 12348 >/dev/null`);
|
||||||
|
|
||||||
$sb->load_file('master', "$sample/basic_no_fks_innodb.sql");
|
$master_dbh = $sb->get_dbh_for('master1');
|
||||||
|
$dsn = "h=127.1,P=12348,u=msandbox,p=msandbox";
|
||||||
|
$sb->load_file('master1', "$sample/basic_no_fks_innodb.sql");
|
||||||
|
} else {
|
||||||
|
$sb->load_file('master', "$sample/basic_no_fks_innodb.sql");
|
||||||
|
}
|
||||||
|
|
||||||
($output, $exit) = full_output(
|
($output, $exit) = full_output(
|
||||||
sub { pt_online_schema_change::main(@args, "$dsn,D=pt_osc,t=T",
|
sub { pt_online_schema_change::main(@args, "$dsn,D=pt_osc,t=T",
|
||||||
@@ -78,7 +72,8 @@ is(
|
|||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
diag(`$trunk/sandbox/stop-sandbox 12348 >/dev/null`);
|
||||||
|
$master_dbh = $sb->get_dbh_for('master');
|
||||||
$sb->wipe_clean($master_dbh);
|
$sb->wipe_clean($master_dbh);
|
||||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||||
done_testing;
|
done_testing;
|
||||||
|
@@ -0,0 +1,2 @@
|
|||||||
|
[mysqld]
|
||||||
|
lower_case_table_names=1
|
Reference in New Issue
Block a user