DSNParser clobbered sql_mode variable set by user - lp1506748

This commit is contained in:
frank-cizmich
2016-02-01 22:50:07 -03:00
parent f6feb8ee03
commit 7c0054fa5d
27 changed files with 241 additions and 164 deletions
+3 -3
View File
@@ -46,7 +46,6 @@ my $exit = 0;
my $sample = "t/pt-online-schema-change/samples";
my $rows;
# #############################################################################
# Tool shouldn't run without --execute (bug 933232).
# #############################################################################
@@ -686,7 +685,6 @@ test_alter_table(
],
);
# #############################################################################
# --statistics
# #############################################################################
@@ -709,7 +707,7 @@ my $res_file = "$sample/stats-execute.txt";
if ($sandbox_version eq '5.5' && $db_flavor !~ m/XtraDB Cluster/) {
$res_file = "$sample/stats-execute-5.5.txt";
} elsif ($sandbox_version eq '5.6' && $db_flavor !~ m/XtraDB Cluster/) {
$res_file = "$sample/stats-execute.txt";
$res_file = "$sample/stats-execute-5.6.txt";
} elsif ($sandbox_version eq '5.7' && $db_flavor !~ m/XtraDB Cluster/) {
$res_file = "$sample/stats-execute-5.7.txt";
}
@@ -723,10 +721,12 @@ ok(
'--recursion-method', 'none'),
},
$res_file,
keep_output=>1,
),
"--statistics --execute"
) or diag($test_diff);
# #############################################################################
# --chunk-size-limit=0 must not skip tables that would be chunked
# in one nibble
+35 -1
View File
@@ -14,7 +14,7 @@ use Test::More;
use Data::Dumper;
use PerconaTest;
use Sandbox;
use SqlModes;
require "$trunk/bin/pt-online-schema-change";
my $dp = new DSNParser(opts=>$dsn_opts);
@@ -38,6 +38,7 @@ my $output;
my $exit_status;
my $sample = "t/pt-online-schema-change/samples/";
# ############################################################################
# https://bugs.launchpad.net/percona-toolkit/+bug/1336734
# pt-online-schema-change 2.2.17 adds --null-to-not-null feature
@@ -510,6 +511,39 @@ like(
"Bug 1446928: Avoid error trapping loop when --alter is invalid",
);
# ############################################################################
# https://bugs.launchpad.net/percona-toolkit/+bug/1506748
# test that setting sql_mode via --set-vars works
# ############################################################################
# first we create a table with a valid default date
$sb->load_file('master', "$sample/sql_mode_issue_lp1506748.sql");
my $modes = new SqlModes($master_dbh, global =>1);
# We clear all modes. In this state, setting an invalid default date generates
# an error.
$modes->set_mode_string('');
# Now we run the command, but set sql_mode to allow invalid dates for
# the session.
# While we're at it, test that we can set more than one mode by double escaping
# the commas. (must be explained in docs)
($output, $exit_status) = full_output(
sub { pt_online_schema_change::main(@args,
"$master_dsn,D=test,t=lp1506748",
"--execute",
"--set-vars", "sql_mode=\'STRICT_ALL_TABLES\\,ALLOW_INVALID_DATES\'",
"--alter", "MODIFY COLUMN birthday DATE DEFAULT '1970-02-31'",
) },
);
ok ((!$exit_status && $output =~ /success/i) , "--set-vars sql_mode=\\'a\\\\,b\\' works" )
or diag("[$output][$exit_status]");
$master_dbh->do("drop database test");
$modes->restore_original_modes();
# #############################################################################
# Done.
# #############################################################################
@@ -0,0 +1,4 @@
create database if not exists test;
create table if not exists test.lp1506748 (id int PRIMARY KEY, birthday date default '1970-01-01');
@@ -0,0 +1,30 @@
No slaves found. See --recursion-method if host h=127.1,P=12345 has slaves.
Not checking slave lag because no slaves were found and --check-slave-lag was not specified.
Operation, tries, wait:
analyze_table, 10, 1
copy_rows, 10, 0.25
create_triggers, 10, 1
drop_triggers, 10, 1
swap_tables, 10, 1
update_foreign_keys, 10, 1
Altering `bug_1045317`.`bits`...
TS Dropping triggers...
TS Dropped triggers OK.
# Event Count
# ================== =====
# INSERT 1
# mysql_warning_1592 1
Successfully altered `bug_1045317`.`bits`.
Creating new table...
Created new table bug_1045317._bits_new OK.
Altering new table...
Altered `bug_1045317`.`_bits_new` OK.
TS Creating triggers...
TS Created triggers OK.
TS Copying approximately 3 rows...
TS Copied rows OK.
TS Analyzing new table...
TS Swapping tables...
TS Swapped original and new tables OK.
TS Dropping old table...
TS Dropped old table `bug_1045317`.`_bits_old` OK.