mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-12-19 01:09:21 +08:00
Fix a number of SQL queries to work with ANSI_QUOTES
This commit is contained in:
@@ -340,7 +340,7 @@ sub is_master_of {
|
|||||||
or die "The server specified as a slave is not a slave";
|
or die "The server specified as a slave is not a slave";
|
||||||
my @connected = $self->get_connected_slaves($master)
|
my @connected = $self->get_connected_slaves($master)
|
||||||
or die "The server specified as a master has no connected slaves";
|
or die "The server specified as a master has no connected slaves";
|
||||||
my (undef, $port) = $master->selectrow_array('SHOW VARIABLES LIKE "port"');
|
my (undef, $port) = $master->selectrow_array("SHOW VARIABLES LIKE 'port'");
|
||||||
|
|
||||||
if ( $port != $slave_status->{master_port} ) {
|
if ( $port != $slave_status->{master_port} ) {
|
||||||
die "The slave is connected to $slave_status->{master_port} "
|
die "The slave is connected to $slave_status->{master_port} "
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ make_sandbox() {
|
|||||||
echo "skip-innodb" >> /tmp/$port/my.sandbox.cnf
|
echo "skip-innodb" >> /tmp/$port/my.sandbox.cnf
|
||||||
echo "default-storage-engine=myisam" >> /tmp/$port/my.sandbox.cnf
|
echo "default-storage-engine=myisam" >> /tmp/$port/my.sandbox.cnf
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$MODE_ANSI" ]; then
|
||||||
|
echo "sql_mode=ansi" >> /tmp/$port/my.sandbox.cnf
|
||||||
|
fi
|
||||||
|
|
||||||
# If the sandbox is a slave, set it read_only.
|
# If the sandbox is a slave, set it read_only.
|
||||||
if [ "$type" = "slave" ]; then
|
if [ "$type" = "slave" ]; then
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ SKIP: {
|
|||||||
|
|
||||||
$master_dbh->do('DROP TABLE IF EXISTS test.issue_371');
|
$master_dbh->do('DROP TABLE IF EXISTS test.issue_371');
|
||||||
$master_dbh->do('CREATE TABLE test.issue_371 (id INT, foo varchar(16), bar char)');
|
$master_dbh->do('CREATE TABLE test.issue_371 (id INT, foo varchar(16), bar char)');
|
||||||
$master_dbh->do('INSERT INTO test.issue_371 VALUES (1,"foo","a"),(2,"bar","b")');
|
$master_dbh->do("INSERT INTO test.issue_371 VALUES (1,'foo','a'),(2,'bar','b')");
|
||||||
|
|
||||||
$ch->fetch_back($master_dbh);
|
$ch->fetch_back($master_dbh);
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ isa_ok($cr, 'CompareResults');
|
|||||||
);
|
);
|
||||||
|
|
||||||
is_deeply(
|
is_deeply(
|
||||||
$dbh1->selectrow_arrayref('SHOW TABLES FROM test LIKE "dropme"'),
|
$dbh1->selectrow_arrayref("SHOW TABLES FROM test LIKE 'dropme'"),
|
||||||
['dropme'],
|
['dropme'],
|
||||||
'checksum: temp table exists'
|
'checksum: temp table exists'
|
||||||
);
|
);
|
||||||
@@ -145,7 +145,7 @@ is(
|
|||||||
);
|
);
|
||||||
|
|
||||||
is_deeply(
|
is_deeply(
|
||||||
$dbh1->selectall_arrayref('SHOW TABLES FROM test LIKE "dropme"'),
|
$dbh1->selectall_arrayref("SHOW TABLES FROM test LIKE 'dropme'"),
|
||||||
[],
|
[],
|
||||||
'checksum: before_execute() drops temp table'
|
'checksum: before_execute() drops temp table'
|
||||||
);
|
);
|
||||||
@@ -199,7 +199,7 @@ is(
|
|||||||
);
|
);
|
||||||
|
|
||||||
is_deeply(
|
is_deeply(
|
||||||
$dbh1->selectall_arrayref('SHOW TABLES FROM test LIKE "dropme"'),
|
$dbh1->selectall_arrayref("SHOW TABLES FROM test LIKE 'dropme'"),
|
||||||
[],
|
[],
|
||||||
'checksum: after_execute() drops temp table'
|
'checksum: after_execute() drops temp table'
|
||||||
);
|
);
|
||||||
@@ -335,7 +335,7 @@ isa_ok($cr, 'CompareResults');
|
|||||||
);
|
);
|
||||||
|
|
||||||
is_deeply(
|
is_deeply(
|
||||||
$dbh1->selectrow_arrayref('SHOW TABLES FROM test LIKE "dropme"'),
|
$dbh1->selectrow_arrayref("SHOW TABLES FROM test LIKE 'dropme'"),
|
||||||
['dropme'],
|
['dropme'],
|
||||||
'rows: temp table exists'
|
'rows: temp table exists'
|
||||||
);
|
);
|
||||||
@@ -349,7 +349,7 @@ is(
|
|||||||
);
|
);
|
||||||
|
|
||||||
is_deeply(
|
is_deeply(
|
||||||
$dbh1->selectrow_arrayref('SHOW TABLES FROM test LIKE "dropme"'),
|
$dbh1->selectrow_arrayref("SHOW TABLES FROM test LIKE 'dropme'"),
|
||||||
['dropme'],
|
['dropme'],
|
||||||
"rows: before_execute() doesn't drop temp table"
|
"rows: before_execute() doesn't drop temp table"
|
||||||
);
|
);
|
||||||
@@ -455,7 +455,7 @@ is_deeply(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
$dbh2->do('update test.t2 set c="should be c" where i=3');
|
$dbh2->do("update test.t2 set c='should be c' where i=3");
|
||||||
|
|
||||||
is_deeply(
|
is_deeply(
|
||||||
$dbh2->selectrow_arrayref('select c from test.t2 where i=3'),
|
$dbh2->selectrow_arrayref('select c from test.t2 where i=3'),
|
||||||
@@ -517,8 +517,8 @@ is_deeply(
|
|||||||
# Test max-different-rows.
|
# Test max-different-rows.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
$cr->reset();
|
$cr->reset();
|
||||||
$dbh2->do('update test.t2 set c="should be a" where i=1');
|
$dbh2->do("update test.t2 set c='should be a' where i=1");
|
||||||
$dbh2->do('update test.t2 set c="should be b" where i=2');
|
$dbh2->do("update test.t2 set c='should be b' where i=2");
|
||||||
proc('before_execute');
|
proc('before_execute');
|
||||||
proc('execute');
|
proc('execute');
|
||||||
|
|
||||||
|
|||||||
@@ -166,12 +166,12 @@ is_deeply(
|
|||||||
# #############################################################################
|
# #############################################################################
|
||||||
@events = (
|
@events = (
|
||||||
{
|
{
|
||||||
arg => 'insert into test.t values (-2,"hi2",2)',
|
arg => "insert into test.t values (-2,'hi2',2)",
|
||||||
fingerprint => 'insert into test.t values (?,?,?)',
|
fingerprint => 'insert into test.t values (?,?,?)',
|
||||||
sampleno => 1,
|
sampleno => 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg => 'insert into test.t values (-2,"hi2",2)',
|
arg => "insert into test.t values (-2,'hi2',2)",
|
||||||
fingerprint => 'insert into test.t values (?,?,?)',
|
fingerprint => 'insert into test.t values (?,?,?)',
|
||||||
sampleno => 1,
|
sampleno => 1,
|
||||||
},
|
},
|
||||||
@@ -341,7 +341,7 @@ is(
|
|||||||
|
|
||||||
is_deeply(
|
is_deeply(
|
||||||
[ $cw->samples('insert into test.t values (?,?,?)') ],
|
[ $cw->samples('insert into test.t values (?,?,?)') ],
|
||||||
[ '1', 'insert into test.t values (-2,"hi2",2)' ],
|
[ '1', "insert into test.t values (-2,'hi2',2)" ],
|
||||||
'samples()'
|
'samples()'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ if ( !$dbh ) {
|
|||||||
plan skip_all => 'Cannot connect to MySQL';
|
plan skip_all => 'Cannot connect to MySQL';
|
||||||
|
|
||||||
}
|
}
|
||||||
elsif ( !@{$dbh->selectcol_arrayref('SHOW DATABASES LIKE "sakila"')} ) {
|
elsif ( !@{$dbh->selectcol_arrayref("SHOW DATABASES LIKE 'sakila'")} ) {
|
||||||
plan skip_all => "Sandbox master does not have the sakila database";
|
plan skip_all => "Sandbox master does not have the sakila database";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -461,23 +461,25 @@ SKIP: {
|
|||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Issue 801: DSNParser clobbers SQL_MODE
|
# Issue 801: DSNParser clobbers SQL_MODE
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
SKIP: {
|
diag('Setting SQL mode globally on 12345');
|
||||||
diag(`SQL_MODE="no_zero_date" $trunk/sandbox/start-sandbox master 12348 >/dev/null`);
|
my $old_mode = `/tmp/12345/use -ss -e 'select \@\@sql_mode'`;
|
||||||
my $dsn = $dp->parse('h=127.1,P=12348,u=msandbox,p=msandbox');
|
chomp $old_mode;
|
||||||
my $dbh = $dp->get_dbh($dp->get_cxn_params($dsn), {});
|
diag("Old SQL mode: $old_mode");
|
||||||
|
diag(`/tmp/12345/use -e 'set global sql_mode=no_zero_date'`);
|
||||||
|
my $new_mode = `/tmp/12345/use -ss -e 'select \@\@sql_mode'`;
|
||||||
|
chomp $new_mode;
|
||||||
|
diag("New SQL mode: $new_mode");
|
||||||
|
my $dsn = $dp->parse('h=127.1,P=12345,u=msandbox,p=msandbox');
|
||||||
|
my $mdbh = $dp->get_dbh($dp->get_cxn_params($dsn), {});
|
||||||
|
|
||||||
skip 'Cannot connect to second sandbox master', 1 unless $dbh;
|
my $row = $mdbh->selectrow_arrayref('select @@sql_mode');
|
||||||
|
is(
|
||||||
my $row = $dbh->selectrow_arrayref('select @@sql_mode');
|
$row->[0],
|
||||||
is(
|
'NO_AUTO_VALUE_ON_ZERO,NO_ZERO_DATE',
|
||||||
$row->[0],
|
"Did not clobber server SQL mode"
|
||||||
'NO_AUTO_VALUE_ON_ZERO,NO_ZERO_DATE',
|
);
|
||||||
"Did not clobber server SQL mode"
|
diag(`/tmp/12345/use -e "set global sql_mode='$old_mode'"`);
|
||||||
);
|
$mdbh->disconnect;
|
||||||
|
|
||||||
$dbh->disconnect();
|
|
||||||
diag(`$trunk/sandbox/stop-sandbox 12348 >/dev/null`);
|
|
||||||
};
|
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Passwords with commas don't work, expose part of password
|
# Passwords with commas don't work, expose part of password
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ is_deeply(
|
|||||||
SKIP: {
|
SKIP: {
|
||||||
skip "Cannot connect to sandbox master", 5 unless $dbh;
|
skip "Cannot connect to sandbox master", 5 unless $dbh;
|
||||||
skip "Sakila database is not loaded", 5
|
skip "Sakila database is not loaded", 5
|
||||||
unless @{ $dbh->selectall_arrayref('show databases like "sakila"') };
|
unless @{ $dbh->selectall_arrayref("show databases like 'sakila'") };
|
||||||
|
|
||||||
# Use mk-index-usage to create all the save results tables.
|
# Use mk-index-usage to create all the save results tables.
|
||||||
# Must --databases foo so it won't find anything, else it will
|
# Must --databases foo so it won't find anything, else it will
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ is(
|
|||||||
# ############################################################################
|
# ############################################################################
|
||||||
# a-y w/ chunk-size 5, even nibbles
|
# a-y w/ chunk-size 5, even nibbles
|
||||||
# ############################################################################
|
# ############################################################################
|
||||||
$dbh->do('delete from test.t where c="z"');
|
$dbh->do("delete from test.t where c='z'");
|
||||||
my $all_rows = $dbh->selectall_arrayref('select * from test.t order by c');
|
my $all_rows = $dbh->selectall_arrayref('select * from test.t order by c');
|
||||||
$ni = make_nibble_iter(
|
$ni = make_nibble_iter(
|
||||||
db => 'test',
|
db => 'test',
|
||||||
@@ -254,7 +254,7 @@ is_deeply(
|
|||||||
# ############################################################################
|
# ############################################################################
|
||||||
# single row table
|
# single row table
|
||||||
# ############################################################################
|
# ############################################################################
|
||||||
$dbh->do('delete from test.t where c != "d"');
|
$dbh->do("delete from test.t where c != 'd'");
|
||||||
$ni = make_nibble_iter(
|
$ni = make_nibble_iter(
|
||||||
db => 'test',
|
db => 'test',
|
||||||
tbl => 't',
|
tbl => 't',
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ SKIP: {
|
|||||||
# ########################################################################
|
# ########################################################################
|
||||||
SKIP: {
|
SKIP: {
|
||||||
skip 'Sandbox master does not have the sakila database', 1
|
skip 'Sandbox master does not have the sakila database', 1
|
||||||
unless @{$dbh->selectcol_arrayref('SHOW DATABASES LIKE "sakila"')};
|
unless @{$dbh->selectcol_arrayref("SHOW DATABASES LIKE 'sakila'")};
|
||||||
|
|
||||||
test_so(
|
test_so(
|
||||||
filters => [qw(-d sakila)],
|
filters => [qw(-d sakila)],
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ is(
|
|||||||
# #############################################################################
|
# #############################################################################
|
||||||
SKIP: {
|
SKIP: {
|
||||||
skip 'Sandbox master does not have the sakila database', 21
|
skip 'Sandbox master does not have the sakila database', 21
|
||||||
unless @{$dbh->selectcol_arrayref('SHOW DATABASES LIKE "sakila"')};
|
unless @{$dbh->selectcol_arrayref("SHOW DATABASES LIKE 'sakila'")};
|
||||||
|
|
||||||
my @chunks;
|
my @chunks;
|
||||||
|
|
||||||
@@ -1115,7 +1115,7 @@ sub count_rows {
|
|||||||
|
|
||||||
SKIP: {
|
SKIP: {
|
||||||
skip 'Sandbox master does not have the sakila database', 1
|
skip 'Sandbox master does not have the sakila database', 1
|
||||||
unless @{$dbh->selectcol_arrayref('SHOW DATABASES LIKE "sakila"')};
|
unless @{$dbh->selectcol_arrayref("SHOW DATABASES LIKE 'sakila'")};
|
||||||
|
|
||||||
my @chunks;
|
my @chunks;
|
||||||
|
|
||||||
@@ -1228,7 +1228,7 @@ ok( @chunks, "calculate_chunks picks a sane default for chunk_range" );
|
|||||||
# #############################################################################
|
# #############################################################################
|
||||||
SKIP: {
|
SKIP: {
|
||||||
skip 'Sandbox master does not have the sakila database', 1
|
skip 'Sandbox master does not have the sakila database', 1
|
||||||
unless @{$dbh->selectcol_arrayref('SHOW DATABASES LIKE "sakila"')};
|
unless @{$dbh->selectcol_arrayref("SHOW DATABASES LIKE 'sakila'")};
|
||||||
|
|
||||||
my @chunks;
|
my @chunks;
|
||||||
$t = $tp->parse( load_file('t/lib/samples/sakila.film.sql') );
|
$t = $tp->parse( load_file('t/lib/samples/sakila.film.sql') );
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ my $sample = "t/lib/samples/tables/";
|
|||||||
SKIP: {
|
SKIP: {
|
||||||
skip "Cannot connect to sandbox master", 2 unless $dbh;
|
skip "Cannot connect to sandbox master", 2 unless $dbh;
|
||||||
skip 'Sandbox master does not have the sakila database', 2
|
skip 'Sandbox master does not have the sakila database', 2
|
||||||
unless @{$dbh->selectcol_arrayref('SHOW DATABASES LIKE "sakila"')};
|
unless @{$dbh->selectcol_arrayref("SHOW DATABASES LIKE 'sakila'")};
|
||||||
|
|
||||||
is(
|
is(
|
||||||
$tp->get_create_table($dbh, 'sakila', 'FOO'),
|
$tp->get_create_table($dbh, 'sakila', 'FOO'),
|
||||||
@@ -702,7 +702,7 @@ SKIP: {
|
|||||||
|
|
||||||
SKIP: {
|
SKIP: {
|
||||||
skip 'Sandbox master does not have the sakila database', 2
|
skip 'Sandbox master does not have the sakila database', 2
|
||||||
unless $dbh && @{$dbh->selectcol_arrayref('SHOW DATABASES LIKE "sakila"')};
|
unless $dbh && @{$dbh->selectcol_arrayref("SHOW DATABASES LIKE 'sakila'")};
|
||||||
is_deeply(
|
is_deeply(
|
||||||
[$tp->find_possible_keys(
|
[$tp->find_possible_keys(
|
||||||
$dbh, 'sakila', 'film_actor', $q, 'film_id > 990 and actor_id > 1')],
|
$dbh, 'sakila', 'film_actor', $q, 'film_id > 990 and actor_id > 1')],
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ $sb->create_dbs($dbh, [qw(test)]);
|
|||||||
|
|
||||||
SKIP: {
|
SKIP: {
|
||||||
skip 'Sandbox master does not have the sakila database', 1
|
skip 'Sandbox master does not have the sakila database', 1
|
||||||
unless @{$dbh->selectcol_arrayref('SHOW DATABASES LIKE "sakila"')};
|
unless @{$dbh->selectcol_arrayref("SHOW DATABASES LIKE 'sakila'")};
|
||||||
|
|
||||||
$output = `$cmd --source F=$cnf,h=127.1,D=sakila,t=film --no-check-charset --where "film_id < 100" --purge --dry-run --port 12345 | diff $trunk/t/pt-archiver/samples/issue-248.txt -`;
|
$output = `$cmd --source F=$cnf,h=127.1,D=sakila,t=film --no-check-charset --where "film_id < 100" --purge --dry-run --port 12345 | diff $trunk/t/pt-archiver/samples/issue-248.txt -`;
|
||||||
is(
|
is(
|
||||||
@@ -87,8 +87,8 @@ SKIP: {
|
|||||||
$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
|
$sb->load_file('master', 't/pt-archiver/samples/tables1-4.sql');
|
||||||
|
|
||||||
# Change passwords so defaults files won't work.
|
# Change passwords so defaults files won't work.
|
||||||
$dbh->do('SET PASSWORD FOR msandbox = PASSWORD("foo")');
|
$dbh->do("SET PASSWORD FOR msandbox = PASSWORD('foo')");
|
||||||
$dbh2->do('SET PASSWORD FOR msandbox = PASSWORD("foo")');
|
$dbh2->do("SET PASSWORD FOR msandbox = PASSWORD('foo')");
|
||||||
|
|
||||||
$dbh2->do('TRUNCATE TABLE test.table_2');
|
$dbh2->do('TRUNCATE TABLE test.table_2');
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ like(
|
|||||||
|
|
||||||
SKIP: {
|
SKIP: {
|
||||||
skip 'Sandbox master does not have the sakila database', 17
|
skip 'Sandbox master does not have the sakila database', 17
|
||||||
unless @{$dbh->selectcol_arrayref('SHOW DATABASES LIKE "sakila"')};
|
unless @{$dbh->selectcol_arrayref("SHOW DATABASES LIKE 'sakila'")};
|
||||||
|
|
||||||
# ########################################################################
|
# ########################################################################
|
||||||
# First, test actions: --exec*, print*, etc.
|
# First, test actions: --exec*, print*, etc.
|
||||||
|
|||||||
@@ -503,7 +503,7 @@ test_alter_table(
|
|||||||
|
|
||||||
SKIP: {
|
SKIP: {
|
||||||
skip 'Sandbox master does not have the sakila database', 7
|
skip 'Sandbox master does not have the sakila database', 7
|
||||||
unless @{$master_dbh->selectcol_arrayref('SHOW DATABASES LIKE "sakila"')};
|
unless @{$master_dbh->selectcol_arrayref("SHOW DATABASES LIKE 'sakila'")};
|
||||||
|
|
||||||
# This test will use the drop_swap method because the child tables
|
# This test will use the drop_swap method because the child tables
|
||||||
# are large. To prove this, change check_fks to rebuild_constraints
|
# are large. To prove this, change check_fks to rebuild_constraints
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ my $dbh = $sb->get_dbh_for('slave1');
|
|||||||
if ( !$dbh ) {
|
if ( !$dbh ) {
|
||||||
plan skip_all => 'Cannot connect to MySQL slave.';
|
plan skip_all => 'Cannot connect to MySQL slave.';
|
||||||
}
|
}
|
||||||
elsif ( !@{$dbh->selectcol_arrayref('SHOW DATABASES LIKE "sakila"')} ) {
|
elsif ( !@{$dbh->selectcol_arrayref("SHOW DATABASES LIKE 'sakila'")} ) {
|
||||||
plan skip_all => 'sakila db not loaded';
|
plan skip_all => 'sakila db not loaded';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ my $dbh = $sb->get_dbh_for('slave1');
|
|||||||
if ( !$dbh ) {
|
if ( !$dbh ) {
|
||||||
plan skip_all => 'Cannot connect to MySQL slave.';
|
plan skip_all => 'Cannot connect to MySQL slave.';
|
||||||
}
|
}
|
||||||
elsif ( !@{$dbh->selectcol_arrayref('SHOW DATABASES LIKE "sakila"')} ) {
|
elsif ( !@{$dbh->selectcol_arrayref("SHOW DATABASES LIKE 'sakila'")} ) {
|
||||||
plan skip_all => 'sakila db not loaded';
|
plan skip_all => 'sakila db not loaded';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user