Only use LOCK IN SHARE MODE with MySQL 5.1+.

This commit is contained in:
Daniel Nichter
2012-12-11 16:54:24 +00:00
parent 5e619bf213
commit b41ae476ae
2 changed files with 36 additions and 2 deletions

View File

@@ -7860,10 +7860,15 @@ sub main {
# Although triggers were introduced in 5.0.2, "Prior to MySQL 5.0.10, # Although triggers were introduced in 5.0.2, "Prior to MySQL 5.0.10,
# triggers cannot contain direct references to tables by name." # triggers cannot contain direct references to tables by name."
# ######################################################################## # ########################################################################
if ( VersionParser->new($cxn->dbh()) < '5.0.10' ) { my $server_version = VersionParser->new($cxn->dbh());
if ( $server_version < '5.0.10' ) {
die "This tool requires MySQL 5.0.10 or newer.\n"; die "This tool requires MySQL 5.0.10 or newer.\n";
} }
# Use LOCK IN SHARE mode unless MySQL 5.0 because there's a bug like
# http://bugs.mysql.com/bug.php?id=45694
my $lock_in_share_mode = $server_version < '5.1' ? 0 : 1;
# ######################################################################## # ########################################################################
# Setup lag and load monitors. # Setup lag and load monitors.
# ######################################################################## # ########################################################################
@@ -8698,7 +8703,7 @@ sub main {
dml => $dml, dml => $dml,
select => $select, select => $select,
callbacks => $callbacks, callbacks => $callbacks,
lock_in_share_mode => 1, lock_in_share_mode => $lock_in_share_mode,
OptionParser => $o, OptionParser => $o,
Quoter => $q, Quoter => $q,
TableParser => $tp, TableParser => $tp,

View File

@@ -235,6 +235,35 @@ $sb->load_file('master', "$sample/del-trg-bug-1062324.sql");
); );
} }
# #############################################################################
# Something like http://bugs.mysql.com/bug.php?id=45694 means we should not
# use LOCK IN SHARE MODE with MySQL 5.0.
# #############################################################################
$sb->load_file('master', "$sample/basic_no_fks_innodb.sql");
($output, $exit_status) = full_output(
sub { pt_online_schema_change::main(@args,
"$master_dsn,D=pt_osc,t=t",
"--alter", "add column (foo int)",
qw(--execute --print))
},
);
if ( $sandbox_version eq '5.0' ) {
unlike(
$output,
qr/LOCK IN SHARE MODE/,
"No LOCK IN SHARE MODE for MySQL $sandbox_version"
);
}
else {
like(
$output,
qr/LOCK IN SHARE MODE/,
"LOCK IN SHARE MODE for MySQL $sandbox_version",
);
}
# ############################################################################# # #############################################################################
# Done. # Done.
# ############################################################################# # #############################################################################