mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-12 14:18:32 +00:00
PT-1572 Updated tests
This commit is contained in:
@@ -5520,11 +5520,32 @@ sub new {
|
||||
);
|
||||
PTDEBUG && _d('Ascend params:', Dumper($asc));
|
||||
|
||||
my $force_concat_enums = $o->has('force-concat-enums') && $o->get('force-concat-enums');
|
||||
for my $index (@{$index_cols}) {
|
||||
if ($tbl->{tbl_struct}->{type_for}->{$index} eq 'enum') {
|
||||
if ($tbl->{tbl_struct}->{defs}->{$index} =~ m/enum\s*\((.*?)\)/) {
|
||||
my @items = split(/,\s*/, $1);
|
||||
my $sorted = 1; # Asume the items list is sorted to later check if this is true
|
||||
for (my $i=1; $i < scalar(@items); $i++) {
|
||||
if ($items[$i-1] gt $items[$i]) {
|
||||
$sorted = 0;
|
||||
last;
|
||||
}
|
||||
}
|
||||
if (!$force_concat_enums && !$sorted) {
|
||||
die "The index " . $index . " in table " . $tbl->{name} .
|
||||
" has unsorted enum items.\nPlease read the documentation for the --force-concat-enums parameter\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
my $from = "$tbl->{name} FORCE INDEX(`$index`)";
|
||||
my $order_by = join(', ', map { $tbl->{tbl_struct}->{type_for}->{$_} eq 'enum'
|
||||
my $order_by = join(', ', map { $tbl->{tbl_struct}->{type_for}->{$_} eq 'enum' && $force_concat_enums
|
||||
? "CONCAT(".$q->quote($_).")" : $q->quote($_)} @{$index_cols});
|
||||
|
||||
my $order_by_dec = join(' DESC,', map { $tbl->{tbl_struct}->{type_for}->{$_} eq 'enum'
|
||||
my $order_by_dec = join(' DESC,', map { $tbl->{tbl_struct}->{type_for}->{$_} eq 'enum' && $force_concat_enums
|
||||
? "CONCAT(".$q->quote($_).")" : $q->quote($_)} @{$index_cols});
|
||||
|
||||
my $first_lb_sql
|
||||
@@ -12249,6 +12270,30 @@ duplicate rows and this data will be lost.
|
||||
|
||||
This options bypasses confirmation in case of using alter-foreign-keys-method = none , which might break foreign key constraints.
|
||||
|
||||
=item --force-concat-enums
|
||||
|
||||
The NibbleIterator in Percona Toolkit can detect indexes having ENUM fields and
|
||||
if the items it has are sorted or not. According to MySQL documentation at
|
||||
L<https://dev.mysql.com/doc/refman/8.0/en/enum.html>:
|
||||
|
||||
ENUM values are sorted based on their index numbers, which depend on the order in
|
||||
which the enumeration members were listed in the column specification.
|
||||
For example, 'b' sorts before 'a' for ENUM('b', 'a').
|
||||
The empty string sorts before nonempty strings, and NULL values sort before all other
|
||||
enumeration values.
|
||||
|
||||
To prevent unexpected results when using the ORDER BY clause on an ENUM column,
|
||||
use one of these techniques:
|
||||
- Specify the ENUM list in alphabetic order.
|
||||
- Make sure that the column is sorted lexically rather than by index number by coding
|
||||
ORDER BY CAST(col AS CHAR) or ORDER BY CONCAT(col).
|
||||
|
||||
The NibbleIterator in Percona Toolkit uses CONCAT(col) but, doing that, adds overhead
|
||||
since MySQL cannot use the column directly and has to calculate the result of CONCAT
|
||||
for every row.
|
||||
To make this scenario vissible to the user, if there are indexes having ENUM fields
|
||||
with usorted items, it is necessary to specify the C<--force-concat-enums> parameter.
|
||||
|
||||
=item --help
|
||||
|
||||
Show help and exit.
|
||||
|
@@ -6371,11 +6371,32 @@ sub new {
|
||||
);
|
||||
PTDEBUG && _d('Ascend params:', Dumper($asc));
|
||||
|
||||
my $force_concat_enums = $o->has('force-concat-enums') && $o->get('force-concat-enums');
|
||||
for my $index (@{$index_cols}) {
|
||||
if ($tbl->{tbl_struct}->{type_for}->{$index} eq 'enum') {
|
||||
if ($tbl->{tbl_struct}->{defs}->{$index} =~ m/enum\s*\((.*?)\)/) {
|
||||
my @items = split(/,\s*/, $1);
|
||||
my $sorted = 1; # Asume the items list is sorted to later check if this is true
|
||||
for (my $i=1; $i < scalar(@items); $i++) {
|
||||
if ($items[$i-1] gt $items[$i]) {
|
||||
$sorted = 0;
|
||||
last;
|
||||
}
|
||||
}
|
||||
if (!$force_concat_enums && !$sorted) {
|
||||
die "The index " . $index . " in table " . $tbl->{name} .
|
||||
" has unsorted enum items.\nPlease read the documentation for the --force-concat-enums parameter\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
my $from = "$tbl->{name} FORCE INDEX(`$index`)";
|
||||
my $order_by = join(', ', map { $tbl->{tbl_struct}->{type_for}->{$_} eq 'enum'
|
||||
my $order_by = join(', ', map { $tbl->{tbl_struct}->{type_for}->{$_} eq 'enum' && $force_concat_enums
|
||||
? "CONCAT(".$q->quote($_).")" : $q->quote($_)} @{$index_cols});
|
||||
|
||||
my $order_by_dec = join(' DESC,', map { $tbl->{tbl_struct}->{type_for}->{$_} eq 'enum'
|
||||
my $order_by_dec = join(' DESC,', map { $tbl->{tbl_struct}->{type_for}->{$_} eq 'enum' && $force_concat_enums
|
||||
? "CONCAT(".$q->quote($_).")" : $q->quote($_)} @{$index_cols});
|
||||
|
||||
my $first_lb_sql
|
||||
@@ -13264,7 +13285,27 @@ values 1.008 and 1.009 will be rounded to 1.01, and will checksum as equal.
|
||||
|
||||
=item --force-concat-enums
|
||||
|
||||
bla bla bla bla bla
|
||||
The NibbleIterator in Percona Toolkit can detect indexes having ENUM fields and
|
||||
if the items it has are sorted or not. According to MySQL documentation at
|
||||
L<https://dev.mysql.com/doc/refman/8.0/en/enum.html>:
|
||||
|
||||
ENUM values are sorted based on their index numbers, which depend on the order in
|
||||
which the enumeration members were listed in the column specification.
|
||||
For example, 'b' sorts before 'a' for ENUM('b', 'a').
|
||||
The empty string sorts before nonempty strings, and NULL values sort before all other
|
||||
enumeration values.
|
||||
|
||||
To prevent unexpected results when using the ORDER BY clause on an ENUM column,
|
||||
use one of these techniques:
|
||||
- Specify the ENUM list in alphabetic order.
|
||||
- Make sure that the column is sorted lexically rather than by index number by coding
|
||||
ORDER BY CAST(col AS CHAR) or ORDER BY CONCAT(col).
|
||||
|
||||
The NibbleIterator in Percona Toolkit uses CONCAT(col) but, doing that, adds overhead
|
||||
since MySQL cannot use the column directly and has to calculate the result of CONCAT
|
||||
for every row.
|
||||
To make this scenario vissible to the user, if there are indexes having ENUM fields
|
||||
with usorted items, it is necessary to specify the C<--force-concat-enums> parameter.
|
||||
|
||||
=item --function
|
||||
|
||||
|
@@ -12408,6 +12408,30 @@ the values are converted to strings by the CONCAT() function, and MySQL chooses
|
||||
the string representation. If you specify a value of 2, for example, then the
|
||||
values 1.008 and 1.009 will be rounded to 1.01, and will checksum as equal.
|
||||
|
||||
=item --force-concat-enums
|
||||
|
||||
The NibbleIterator in Percona Toolkit can detect indexes having ENUM fields and
|
||||
if the items it has are sorted or not. According to MySQL documentation at
|
||||
L<https://dev.mysql.com/doc/refman/8.0/en/enum.html>:
|
||||
|
||||
ENUM values are sorted based on their index numbers, which depend on the order in
|
||||
which the enumeration members were listed in the column specification.
|
||||
For example, 'b' sorts before 'a' for ENUM('b', 'a').
|
||||
The empty string sorts before nonempty strings, and NULL values sort before all other
|
||||
enumeration values.
|
||||
|
||||
To prevent unexpected results when using the ORDER BY clause on an ENUM column,
|
||||
use one of these techniques:
|
||||
- Specify the ENUM list in alphabetic order.
|
||||
- Make sure that the column is sorted lexically rather than by index number by coding
|
||||
ORDER BY CAST(col AS CHAR) or ORDER BY CONCAT(col).
|
||||
|
||||
The NibbleIterator in Percona Toolkit uses CONCAT(col) but, doing that, adds overhead
|
||||
since MySQL cannot use the column directly and has to calculate the result of CONCAT
|
||||
for every row.
|
||||
To make this scenario vissible to the user, if there are indexes having ENUM fields
|
||||
with usorted items, it is necessary to specify the C<--force-concat-enums> parameter.
|
||||
|
||||
=item --[no]foreign-key-checks
|
||||
|
||||
default: yes
|
||||
|
@@ -958,6 +958,8 @@ like(
|
||||
'_d() works'
|
||||
);
|
||||
|
||||
$dbh->do("DROP DATABASE test");
|
||||
|
||||
$sb->wipe_clean($dbh);
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
done_testing;
|
||||
|
@@ -45,7 +45,7 @@ elsif ( !@{$master_dbh->selectall_arrayref("show databases like 'sakila'")} ) {
|
||||
# so we need to specify --set-vars innodb_lock_wait_timeout=3 else the tool will die.
|
||||
my $master_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox';
|
||||
my $slave2_dsn = 'h=127.1,P=12347,u=msandbox,p=msandbox';
|
||||
my @args = ($master_dsn, qw(--set-vars innodb_lock_wait_timeout=3));
|
||||
my @args = ($master_dsn, qw(--set-vars innodb_lock_wait_timeout=3 --ignore-tables load_data));
|
||||
my $row;
|
||||
my $output;
|
||||
my $exit_status;
|
||||
|
@@ -23,7 +23,6 @@ ERRORS DIFFS ROWS SKIPPED TABLE
|
||||
0 0 0 0 mysql.time_zone_transition_type
|
||||
0 0 2 0 mysql.user
|
||||
0 0 22 0 percona_test.checksums
|
||||
0 0 1 0 percona_test.load_data
|
||||
0 0 1 0 percona_test.sentinel
|
||||
0 0 200 0 sakila.actor
|
||||
0 0 603 0 sakila.address
|
||||
|
@@ -25,7 +25,6 @@ ERRORS DIFFS ROWS SKIPPED TABLE
|
||||
0 0 0 0 mysql.time_zone_transition_type
|
||||
0 0 2 0 mysql.user
|
||||
0 0 23 0 percona_test.checksums
|
||||
0 0 1 0 percona_test.load_data
|
||||
0 0 1 0 percona_test.sentinel
|
||||
0 0 200 0 sakila.actor
|
||||
0 0 603 0 sakila.address
|
||||
|
@@ -27,7 +27,6 @@ ERRORS DIFFS ROWS SKIPPED TABLE
|
||||
0 0 0 0 mysql.time_zone_transition_type
|
||||
0 0 5 0 mysql.user
|
||||
0 0 27 0 percona_test.checksums
|
||||
0 0 1 0 percona_test.load_data
|
||||
0 0 1 0 percona_test.sentinel
|
||||
0 0 200 0 sakila.actor
|
||||
0 0 603 0 sakila.address
|
||||
|
@@ -2,7 +2,6 @@ if all tables be checksummed
|
||||
checksum ...
|
||||
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
|
||||
0 0 22 1 0 percona_test.checksums
|
||||
0 0 1 1 0 percona_test.load_data
|
||||
0 0 1 1 0 percona_test.sentinel
|
||||
0 0 200 1 0 sakila.actor
|
||||
0 0 603 1 0 sakila.address
|
||||
|
@@ -2,7 +2,6 @@ if all tables be checksummed
|
||||
checksum ...
|
||||
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
|
||||
0 0 23 1 0 percona_test.checksums
|
||||
0 0 1 1 0 percona_test.load_data
|
||||
0 0 1 1 0 percona_test.sentinel
|
||||
0 0 200 1 0 sakila.actor
|
||||
0 0 603 1 0 sakila.address
|
||||
|
@@ -2,7 +2,6 @@ if all tables be checksummed
|
||||
checksum ...
|
||||
ERRORS DIFFS ROWS CHUNKS SKIPPED TABLE
|
||||
0 0 27 1 0 percona_test.checksums
|
||||
0 0 1 1 0 percona_test.load_data
|
||||
0 0 1 1 0 percona_test.sentinel
|
||||
0 0 200 1 0 sakila.actor
|
||||
0 0 603 1 0 sakila.address
|
||||
|
Reference in New Issue
Block a user