mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
PT-1757 Fixed NibbleIterator undef
This commit is contained in:
@@ -177,12 +177,14 @@ sub test_alter_table {
|
||||
) or $fail = 1;
|
||||
|
||||
# Rows in the original and new table should be identical.
|
||||
my $query = "SELECT $cols FROM $table ORDER BY `$pk_col`";
|
||||
my $new_rows = $master_dbh->selectall_arrayref("SELECT $cols FROM $table ORDER BY `$pk_col`");
|
||||
my $should_diag;
|
||||
is_deeply(
|
||||
$new_rows,
|
||||
$orig_rows,
|
||||
"$name rows"
|
||||
) or $fail = 1;
|
||||
) or $fail=1;
|
||||
|
||||
if ( grep { $_ eq '--preserve-triggers' } @$cmds ) {
|
||||
my $new_triggers = $master_dbh->selectall_arrayref($triggers_sql);
|
||||
@@ -341,6 +343,8 @@ sub test_alter_table {
|
||||
|
||||
my $db_flavor = VersionParser->new($master_dbh)->flavor();
|
||||
if ( $db_flavor =~ m/XtraDB Cluster/ ) {
|
||||
diag('====================================================================================================');
|
||||
diag($db_flavor);
|
||||
test_alter_table(
|
||||
name => "Basic no fks --dry-run",
|
||||
table => "pt_osc.t",
|
||||
|
@@ -50,8 +50,6 @@ $sb->load_file('master', "$sample/long_fk_constraints.sql");
|
||||
qw(--execute)) },
|
||||
);
|
||||
|
||||
warn $output;
|
||||
|
||||
my $query = <<_SQL;
|
||||
SELECT TABLE_NAME, CONSTRAINT_NAME
|
||||
FROM information_schema.KEY_COLUMN_USAGE
|
||||
@@ -62,8 +60,11 @@ ORDER BY TABLE_NAME, CONSTRAINT_NAME
|
||||
_SQL
|
||||
my $constraints = $master_dbh->selectall_arrayref($query);
|
||||
|
||||
# why we need to sort? Depending on the MySQL version and the characters set, the ORDER BY clause
|
||||
# in the query will return different values so, it is better to rely on our own sorted results.
|
||||
my @sorted_constraints = sort { @$a[0].@$a[1] cmp @$b[0].@$b[1] } @$constraints;
|
||||
is_deeply(
|
||||
$constraints,
|
||||
\@sorted_constraints,
|
||||
[
|
||||
[ 'Table1', '__fkey1a' ],
|
||||
[ 'Table1', '__fkey_SALES_RECURRING_PROFILE_CUSTOMER_CUSTOMER_ENTITY_ENTITY_I' ],
|
||||
|
@@ -22,7 +22,6 @@ my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $master_dbh = $sb->get_dbh_for('master');
|
||||
|
||||
my $vp = VersionParser->new($master_dbh);
|
||||
warn Data::Dumper::Dumper($vp);
|
||||
|
||||
if ($vp->cmp('8.0.14') > -1 && $vp->flavor() !~ m/maria/i) {
|
||||
plan skip_all => 'Cannot run this test under the current MySQL version';
|
||||
@@ -65,11 +64,14 @@ my $query = <<__SQL;
|
||||
and CONSTRAINT_NAME LIKE '%fkey%'
|
||||
ORDER BY TABLE_NAME, CONSTRAINT_NAME
|
||||
__SQL
|
||||
my $constraints = $master_dbh->selectall_arrayref($query);
|
||||
|
||||
my $constraints = $master_dbh->selectall_arrayref($query);
|
||||
# why we need to sort? Depending on the MySQL version and the characters set, the ORDER BY clause
|
||||
# in the query will return different values so, it is better to rely on our own sorted results.
|
||||
my @sorted_constraints = sort { @$a[0].@$a[1] cmp @$b[0].@$b[1] } @$constraints;
|
||||
|
||||
is_deeply(
|
||||
$constraints,
|
||||
\@sorted_constraints,
|
||||
[
|
||||
['Table1', '__fkey1a'],
|
||||
['Table1', '_fkey1b'],
|
||||
@@ -79,8 +81,6 @@ is_deeply(
|
||||
"First run adds or removes underscore from constraint names, accordingly"
|
||||
);
|
||||
|
||||
|
||||
|
||||
# run second time: we expect constraint names to be prefixed with one underscore
|
||||
# if they havre't one, and to remove 2 if they have 2
|
||||
($output, $exit_status) = full_output(
|
||||
@@ -91,10 +91,10 @@ is_deeply(
|
||||
);
|
||||
|
||||
$constraints = $master_dbh->selectall_arrayref("SELECT TABLE_NAME, CONSTRAINT_NAME FROM information_schema.KEY_COLUMN_USAGE WHERE table_schema='bug1215587' and (TABLE_NAME='Table1' OR TABLE_NAME='Table2') and CONSTRAINT_NAME LIKE '%fkey%' ORDER BY TABLE_NAME, CONSTRAINT_NAME");
|
||||
|
||||
@sorted_constraints = sort { @$a[0].@$a[1] cmp @$b[0].@$b[1] } @$constraints; # read above why we need to sort
|
||||
|
||||
is_deeply(
|
||||
$constraints,
|
||||
\@sorted_constraints,
|
||||
[
|
||||
['Table1', '__fkey1b'],
|
||||
['Table1', 'fkey1a'],
|
||||
@@ -113,10 +113,10 @@ is_deeply(
|
||||
);
|
||||
|
||||
$constraints = $master_dbh->selectall_arrayref("SELECT TABLE_NAME, CONSTRAINT_NAME FROM information_schema.KEY_COLUMN_USAGE WHERE table_schema='bug1215587' and (TABLE_NAME='Table1' OR TABLE_NAME='Table2') and CONSTRAINT_NAME LIKE '%fkey%' ORDER BY TABLE_NAME, CONSTRAINT_NAME");
|
||||
|
||||
@sorted_constraints = sort { @$a[0].@$a[1] cmp @$b[0].@$b[1] } @$constraints; # read above why we need to sort
|
||||
|
||||
is_deeply(
|
||||
$constraints,
|
||||
\@sorted_constraints,
|
||||
[
|
||||
['Table1', '_fkey1a'],
|
||||
['Table1', 'fkey1b'],
|
||||
|
@@ -116,7 +116,7 @@ like(
|
||||
$output,
|
||||
qr/Failed to find a unique new table name/,
|
||||
"Doesn't try forever to find a new table name"
|
||||
);
|
||||
) or diag($output);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
|
Reference in New Issue
Block a user