mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-23 21:05:00 +00:00
Fix quote_val() calls in TableSyncNibble.pm by removing 2nd arg which was ignored anyway. Use more real tbl_struct in TableSyncGroupBy.t so auto-vivification doesn't cause sort_cols() to print the expected results. Remove have_all_privs() tests from TableSyncer.t.
This commit is contained in:
@@ -286,7 +286,7 @@ sub __get_boundaries {
|
||||
# any lower boundary the table rows should be > the lower boundary.)
|
||||
my $i = 0;
|
||||
$ub = $s->{boundaries}->{'<='};
|
||||
$ub =~ s/\?/$q->quote_val($row->{$s->{scols}->[$i]}, $self->{tbl_struct}->{is_numeric}->{$s->{scols}->[$i++]} || 0)/eg;
|
||||
$ub =~ s/\?/$q->quote_val($row->{$s->{scols}->[$i++]})/eg;
|
||||
}
|
||||
else {
|
||||
# This usually happens at the end of the table, after we've nibbled
|
||||
@@ -331,7 +331,7 @@ sub __make_boundary_sql {
|
||||
my $tmp = $self->{cached_row};
|
||||
my $i = 0;
|
||||
$lb = $s->{boundaries}->{'>'};
|
||||
$lb =~ s/\?/$q->quote_val($tmp->{$s->{scols}->[$i]}, $self->{tbl_struct}->{is_numeric}->{$s->{scols}->[$i++]} || 0)/eg;
|
||||
$lb =~ s/\?/$q->quote_val($tmp->{$s->{scols}->[$i++]})/eg;
|
||||
$sql .= $args{where} ? " AND $lb" : " WHERE $lb";
|
||||
}
|
||||
$sql .= " ORDER BY " . join(',', map { $q->quote($_) } @{$self->{key_cols}})
|
||||
|
@@ -9,7 +9,8 @@ BEGIN {
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 5;
|
||||
use Test::More;
|
||||
use Data::Dumper;
|
||||
|
||||
use TableSyncGroupBy;
|
||||
use Quoter;
|
||||
@@ -19,7 +20,11 @@ use ChangeHandler;
|
||||
use PerconaTest;
|
||||
|
||||
my $q = new Quoter();
|
||||
my $tbl_struct = { is_col => {} }; # fake tbl_struct
|
||||
my $tbl_struct = {
|
||||
type_for => { a => 'int', b => 'int', c => 'int' },
|
||||
col_posn => { a => 1, b => 2, c => 3 },
|
||||
is_col => { a => 1, b => 2, c => 3 },
|
||||
};
|
||||
my @rows;
|
||||
|
||||
throws_ok(
|
||||
@@ -40,6 +45,7 @@ my $ch = new ChangeHandler(
|
||||
replace => 0,
|
||||
actions => [ sub { push @rows, $_[0] }, ],
|
||||
queue => 0,
|
||||
tbl_struct => $tbl_struct,
|
||||
);
|
||||
|
||||
$t->prepare_to_sync(
|
||||
@@ -93,7 +99,7 @@ $d->compare_sets(
|
||||
{ a => 4, b => 2, c => 3, __maatkit_count => 1 },
|
||||
),
|
||||
syncer => $t,
|
||||
tbl_struct => {},
|
||||
tbl_struct => $tbl_struct,
|
||||
);
|
||||
|
||||
is_deeply(
|
||||
@@ -107,4 +113,10 @@ is_deeply(
|
||||
"DELETE FROM `test`.`foo` WHERE `a`='4' AND `b`='2' AND `c`='3' LIMIT 1",
|
||||
],
|
||||
'rows from handler',
|
||||
);
|
||||
) or diag(Dumper(\@rows));
|
||||
|
||||
# #############################################################################
|
||||
# Done
|
||||
# #############################################################################
|
||||
done_testing;
|
||||
exit;
|
||||
|
@@ -49,9 +49,6 @@ if ( !$src_dbh || !$dbh ) {
|
||||
elsif ( !$dst_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox slave';
|
||||
}
|
||||
else {
|
||||
plan tests => 61;
|
||||
}
|
||||
|
||||
$sb->create_dbs($dbh, ['test']);
|
||||
$sb->load_file('master', 't/lib/samples/before-TableSyncChunk.sql');
|
||||
@@ -636,52 +633,8 @@ is(
|
||||
# Test check_permissions().
|
||||
# #############################################################################
|
||||
|
||||
SKIP: {
|
||||
skip "Not tested on MySQL $sandbox_version", 5
|
||||
unless $sandbox_version gt '4.0';
|
||||
|
||||
# Re-using issue_96.t from above.
|
||||
is(
|
||||
$syncer->have_all_privs($src->{dbh}, 'issue_96', 't'),
|
||||
1,
|
||||
'Have all privs'
|
||||
);
|
||||
|
||||
diag(`/tmp/12345/use -u root -e "CREATE USER 'bob'\@'\%' IDENTIFIED BY 'bob'"`);
|
||||
diag(`/tmp/12345/use -u root -e "GRANT select ON issue_96.t TO 'bob'\@'\%'"`);
|
||||
my $bob_dbh = DBI->connect(
|
||||
"DBI:mysql:;host=127.0.0.1;port=12345", 'bob', 'bob',
|
||||
{ PrintError => 0, RaiseError => 1 });
|
||||
|
||||
is(
|
||||
$syncer->have_all_privs($bob_dbh, 'issue_96', 't'),
|
||||
0,
|
||||
"Don't have all privs, just select"
|
||||
);
|
||||
|
||||
diag(`/tmp/12345/use -u root -e "GRANT insert ON issue_96.t TO 'bob'\@'\%'"`);
|
||||
is(
|
||||
$syncer->have_all_privs($bob_dbh, 'issue_96', 't'),
|
||||
0,
|
||||
"Don't have all privs, just select and insert"
|
||||
);
|
||||
|
||||
diag(`/tmp/12345/use -u root -e "GRANT update ON issue_96.t TO 'bob'\@'\%'"`);
|
||||
is(
|
||||
$syncer->have_all_privs($bob_dbh, 'issue_96', 't'),
|
||||
0,
|
||||
"Don't have all privs, just select, insert and update"
|
||||
);
|
||||
|
||||
diag(`/tmp/12345/use -u root -e "GRANT delete ON issue_96.t TO 'bob'\@'\%'"`);
|
||||
is(
|
||||
$syncer->have_all_privs($bob_dbh, 'issue_96', 't'),
|
||||
1,
|
||||
"Bob got his privs"
|
||||
);
|
||||
|
||||
diag(`/tmp/12345/use -u root -e "DROP USER 'bob'"`);
|
||||
}
|
||||
# have_all_privs() removed due to
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1036747
|
||||
|
||||
# ###########################################################################
|
||||
# Test that the calback gives us the src and dst sql.
|
||||
@@ -930,6 +883,7 @@ SKIP: {
|
||||
);
|
||||
|
||||
diag(`$trunk/sandbox/stop-sandbox 12348 >/dev/null &`);
|
||||
$dbh3->disconnect();
|
||||
}
|
||||
|
||||
# #############################################################################
|
||||
@@ -1066,7 +1020,9 @@ like(
|
||||
qr/Complete test coverage/,
|
||||
'_d() works'
|
||||
);
|
||||
$sb->wipe_clean($src_dbh);
|
||||
$sb->wipe_clean($dst_dbh);
|
||||
$src_dbh->disconnect() if $src_dbh;
|
||||
$dst_dbh->disconnect() if $dst_dbh;
|
||||
$sb->wipe_clean($dbh);
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
done_testing;
|
||||
exit;
|
||||
|
Reference in New Issue
Block a user