mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-26 05:58:16 +00:00
Fix a bazillion tests with ANSI sql_mode, and get rid of a bunch of MySQLDump usage.
This commit is contained in:
@@ -48,7 +48,7 @@ my $qv = new QueryReview(
|
||||
dbh => $dbh,
|
||||
db_tbl => '`test`.`query_review`',
|
||||
tbl_struct => $tbl_struct,
|
||||
ts_default => '"2009-01-01"',
|
||||
ts_default => "'2009-01-01'",
|
||||
quoter => $q,
|
||||
);
|
||||
|
||||
|
@@ -37,7 +37,7 @@ $sb->create_dbs($dbh1, ['test']);
|
||||
# Issue 386: Make mk-deadlock-logger auto-create the --dest table
|
||||
# #############################################################################
|
||||
is_deeply(
|
||||
$dbh1->selectall_arrayref('show tables from `test` like "issue_386"'),
|
||||
$dbh1->selectall_arrayref(q{show tables from `test` like 'issue_386'}),
|
||||
[],
|
||||
'Deadlocks table does not exit (issue 386)'
|
||||
);
|
||||
@@ -45,7 +45,7 @@ is_deeply(
|
||||
`$cmd --dest D=test,t=issue_386 --run-time 1s --interval 1s --create-dest-table`;
|
||||
|
||||
is_deeply(
|
||||
$dbh1->selectall_arrayref('show tables from `test` like "issue_386"'),
|
||||
$dbh1->selectall_arrayref(q{show tables from `test` like 'issue_386'}),
|
||||
[['issue_386']],
|
||||
'Deadlocks table created with --create-dest-table (issue 386)'
|
||||
);
|
||||
|
@@ -23,7 +23,7 @@ if ( !$dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
}
|
||||
else {
|
||||
plan tests => 21;
|
||||
plan tests => 23;
|
||||
}
|
||||
|
||||
my $output;
|
||||
@@ -40,10 +40,18 @@ like(
|
||||
'Prints tables without any tests'
|
||||
);
|
||||
|
||||
# These tests are going to be senstive to your sakila db. Hopefully,
|
||||
# it matches mine which I tend to load fresh and not modify. For example,
|
||||
# the next insert id for sakila.film is expected to be 1001. If this
|
||||
# becomes an issue, I may commit my copy of the sakila db to Google Code.
|
||||
$output = `$cmd --view .`;
|
||||
like(
|
||||
$output,
|
||||
qr/`sakila`.`sales_by_store`/,
|
||||
'Prints views'
|
||||
);
|
||||
unlike(
|
||||
$output,
|
||||
qr/`sakila`.`actor`/,
|
||||
'Does not print non-views'
|
||||
);
|
||||
|
||||
|
||||
SKIP: {
|
||||
skip 'Sandbox master does not have the sakila database', 17
|
||||
|
@@ -117,7 +117,7 @@ $dbh->do('drop table if exists test.heartbeat'); # This will kill it
|
||||
$dbh->do('drop table if exists test.heartbeat');
|
||||
diag(`$cmd --update --run-time 1s --database test --table heartbeat --create-table`);
|
||||
$dbh->do('use test');
|
||||
$output = $dbh->selectcol_arrayref('SHOW TABLES LIKE "heartbeat"');
|
||||
$output = $dbh->selectcol_arrayref("SHOW TABLES LIKE 'heartbeat'");
|
||||
is(
|
||||
$output->[0],
|
||||
'heartbeat',
|
||||
|
@@ -24,7 +24,7 @@ my $dbh = $sb->get_dbh_for('master');
|
||||
if ( !$dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
}
|
||||
if ( !@{ $dbh->selectall_arrayref('show databases like "sakila"') } ) {
|
||||
if ( !@{ $dbh->selectall_arrayref("show databases like 'sakila'") } ) {
|
||||
plan skip_all => "Sakila database is not loaded";
|
||||
}
|
||||
else {
|
||||
|
@@ -24,7 +24,7 @@ my $dbh = $sb->get_dbh_for('master');
|
||||
if ( !$dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
}
|
||||
if ( !@{ $dbh->selectall_arrayref('show databases like "sakila"') } ) {
|
||||
if ( !@{ $dbh->selectall_arrayref("show databases like 'sakila'") } ) {
|
||||
plan skip_all => "Sakila database is not loaded";
|
||||
}
|
||||
else {
|
||||
|
@@ -65,7 +65,7 @@ like(
|
||||
my $ddl = $master_dbh->selectrow_arrayref("show create table pt_osc.t");
|
||||
like(
|
||||
$ddl->[1],
|
||||
qr/^\s+`id`/m,
|
||||
qr/^\s+["`]id["`]/m,
|
||||
"Did not alter the table"
|
||||
);
|
||||
|
||||
@@ -196,7 +196,7 @@ sub test_alter_table {
|
||||
is(
|
||||
$orig_auto_inc,
|
||||
$new_auto_inc,
|
||||
"$name AUTO_INCREMENT=$orig_auto_inc"
|
||||
"$name AUTO_INCREMENT=" . ($orig_auto_inc || '<unknown>')
|
||||
) or $fail = 1;
|
||||
|
||||
# Check if the ALTER was actually done.
|
||||
|
@@ -31,7 +31,7 @@ elsif ( !$slave1_dbh ) {
|
||||
elsif ( !$slave2_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox slave2';
|
||||
}
|
||||
elsif ( !@{$master_dbh->selectall_arrayref('show databases like "sakila"')} ) {
|
||||
elsif ( !@{$master_dbh->selectall_arrayref("show databases like 'sakila'")} ) {
|
||||
plan skip_all => 'sakila database is not loaded';
|
||||
}
|
||||
else {
|
||||
|
@@ -59,10 +59,10 @@ is(
|
||||
"Empty --review table"
|
||||
);
|
||||
|
||||
$dbh->do('insert into test.query_review values
|
||||
(1, "select * from tbl where id=? order by col",
|
||||
"select * from tbl where id=42 order by col",
|
||||
NOW(), NOW(), NULL, NULL, NULL)');
|
||||
$dbh->do("insert into test.query_review values
|
||||
(1, 'select * from tbl where id=? order by col',
|
||||
'select * from tbl where id=42 order by col',
|
||||
NOW(), NOW(), NULL, NULL, NULL)");
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
@@ -72,10 +72,10 @@ ok(
|
||||
"--review with one bad query"
|
||||
);
|
||||
|
||||
$dbh->do('insert into test.query_review values
|
||||
(2, "select col from tbl2 where id=? order by col limit ?",
|
||||
"select col from tbl2 where id=52 order by col limit 10",
|
||||
NOW(), NOW(), NULL, NULL, NULL)');
|
||||
$dbh->do("insert into test.query_review values
|
||||
(2, 'select col from tbl2 where id=? order by col limit ?',
|
||||
'select col from tbl2 where id=52 order by col limit 10',
|
||||
NOW(), NOW(), NULL, NULL, NULL)");
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
|
@@ -56,7 +56,7 @@ ok(
|
||||
);
|
||||
|
||||
# Normalish output from EXPLAIN.
|
||||
$dbh->do('insert into trees values ("apple"),("orange"),("banana")');
|
||||
$dbh->do("insert into trees values ('apple'),('orange'),('banana')");
|
||||
|
||||
ok(
|
||||
no_diff(
|
||||
|
@@ -52,10 +52,10 @@ $cmd = "${run_with}slow006.txt --create-review-table --review "
|
||||
$output = `$cmd >/dev/null 2>&1`;
|
||||
|
||||
my ($table) = $dbh->selectrow_array(
|
||||
'show tables from test like "query_review"');
|
||||
"show tables from test like 'query_review'");
|
||||
is($table, 'query_review', '--create-review');
|
||||
($table) = $dbh->selectrow_array(
|
||||
'show tables from test like "query_review_history"');
|
||||
"show tables from test like 'query_review_history'");
|
||||
is($table, 'query_review_history', '--create-review-history-table');
|
||||
|
||||
$output = 'foo'; # clear previous test results
|
||||
|
@@ -38,7 +38,7 @@ if ( !$master_dbh ) {
|
||||
elsif ( !$slave1_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox slave1';
|
||||
}
|
||||
elsif ( !@{$master_dbh->selectall_arrayref('show databases like "sakila"')} ) {
|
||||
elsif ( !@{$master_dbh->selectall_arrayref("show databases like 'sakila'")} ) {
|
||||
plan skip_all => 'sakila database is not loaded';
|
||||
}
|
||||
else {
|
||||
|
@@ -43,7 +43,7 @@ my $output;
|
||||
$sb->create_dbs($dbh, [qw(test)]);
|
||||
$sb->load_file('master', 't/lib/samples/tables/issue-388.sql', 'test');
|
||||
|
||||
$dbh->do('insert into test.foo values (null, "john, smith")');
|
||||
$dbh->do("insert into test.foo values (null, 'john, smith')");
|
||||
|
||||
$output = output(
|
||||
sub { pt_table_checksum::main(@args, qw(-d test)) },
|
||||
|
@@ -38,7 +38,7 @@ if ( !$master_dbh ) {
|
||||
elsif ( !$slave1_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox slave1';
|
||||
}
|
||||
elsif ( !@{$master_dbh->selectall_arrayref('show databases like "sakila"')} ) {
|
||||
elsif ( !@{$master_dbh->selectall_arrayref("show databases like 'sakila'")} ) {
|
||||
plan skip_all => 'sakila database is not loaded';
|
||||
}
|
||||
else {
|
||||
|
@@ -413,9 +413,9 @@ $master_dbh->do("update percona.checksums set master_crc=NULL, master_cnt=NULL,
|
||||
# which means the tool was killed before $update_sth was called. So,
|
||||
# it should resume from chunk 11 of this table and overwrite chunk 12.
|
||||
|
||||
my $chunk11 = $master_dbh->selectall_arrayref('select * from percona.checksums where db="sakila" and tbl="rental" and chunk=11');
|
||||
my $chunk11 = $master_dbh->selectall_arrayref(q{select * from percona.checksums where db='sakila' and tbl='rental' and chunk=11});
|
||||
|
||||
my $chunk12 = $master_dbh->selectall_arrayref('select master_crc from percona.checksums where db="sakila" and tbl="rental" and chunk=12');
|
||||
my $chunk12 = $master_dbh->selectall_arrayref(q{select master_crc from percona.checksums where db='sakila' and tbl='rental' and chunk=12});
|
||||
is(
|
||||
$chunk12->[0]->[0],
|
||||
undef,
|
||||
@@ -450,12 +450,12 @@ ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
$master_dbh->selectall_arrayref('select * from percona.checksums where db="sakila" and tbl="rental" and chunk=11'),
|
||||
$master_dbh->selectall_arrayref(q{select * from percona.checksums where db='sakila' and tbl='rental' and chunk=11}),
|
||||
$chunk11,
|
||||
"Chunk 11 not updated"
|
||||
);
|
||||
|
||||
$chunk12 = $master_dbh->selectall_arrayref('select master_crc, master_cnt from percona.checksums where db="sakila" and tbl="rental" and chunk=12');
|
||||
$chunk12 = $master_dbh->selectall_arrayref(q{select master_crc, master_cnt from percona.checksums where db='sakila' and tbl='rental' and chunk=12});
|
||||
ok(
|
||||
defined $chunk12->[0]->[0],
|
||||
"Chunk 12 master_crc updated"
|
||||
|
@@ -174,7 +174,7 @@ ok(
|
||||
my $row = $dbh1->selectrow_arrayref("show create table test.mk_upgrade_left");
|
||||
like(
|
||||
$row->[1],
|
||||
qr/`SUM\(total\)`\s+double\sDEFAULT/i,
|
||||
qr/[`"]SUM\(total\)[`"]\s+double\sDEFAULT/i,
|
||||
"No M,D in table def (bug 926598)"
|
||||
);
|
||||
|
||||
|
@@ -45,13 +45,13 @@ my $cmd = "$trunk/bin/pt-upgrade h=127.1,P=12345,u=msandbox,p=msandbox P=12348 -
|
||||
|
||||
$dbh2->do('set global query_cache_size=1000000');
|
||||
|
||||
my $qc = $dbh2->selectrow_arrayref('show variables like "query_cache_size"')->[1];
|
||||
my $qc = $dbh2->selectrow_arrayref("show variables like 'query_cache_size'")->[1];
|
||||
ok(
|
||||
$qc > 999000,
|
||||
'Query size'
|
||||
);
|
||||
|
||||
$qc = $dbh2->selectrow_arrayref('show variables like "query_cache_type"')->[1];
|
||||
$qc = $dbh2->selectrow_arrayref("show variables like 'query_cache_type'")->[1];
|
||||
is(
|
||||
$qc,
|
||||
'ON',
|
||||
@@ -84,7 +84,7 @@ like(
|
||||
);
|
||||
|
||||
$dbh2->do('set global query_cache_size=0');
|
||||
$qc = $dbh2->selectrow_arrayref('show variables like "query_cache_size"')->[1];
|
||||
$qc = $dbh2->selectrow_arrayref("show variables like 'query_cache_size'")->[1];
|
||||
ok(
|
||||
$qc == 0,
|
||||
'Query size'
|
||||
|
Reference in New Issue
Block a user