From 5989d2883cdbb9c9685fdd9efe9cad9604c7e547 Mon Sep 17 00:00:00 2001 From: Taehyung Lim Date: Mon, 19 May 2025 20:09:04 +0900 Subject: [PATCH 1/2] remove check to fix the 'table does not exist' problem when lower_case_table_names=2 is set --- bin/pt-archiver | 2 +- bin/pt-duplicate-key-checker | 2 +- bin/pt-find | 2 +- bin/pt-heartbeat | 2 +- bin/pt-index-usage | 2 +- bin/pt-kill | 2 +- bin/pt-online-schema-change | 2 +- bin/pt-query-digest | 2 +- bin/pt-table-checksum | 2 +- bin/pt-table-sync | 2 +- bin/pt-table-usage | 2 +- lib/TableParser.pm | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bin/pt-archiver b/bin/pt-archiver index acc61b10..9eaa72c7 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -2135,7 +2135,7 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] || $row->[0] ne $tbl ) { + if ( !$row->[0] ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-duplicate-key-checker b/bin/pt-duplicate-key-checker index 88410b1b..2f87f4e9 100755 --- a/bin/pt-duplicate-key-checker +++ b/bin/pt-duplicate-key-checker @@ -525,7 +525,7 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] || $row->[0] ne $tbl ) { + if ( !$row->[0] ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-find b/bin/pt-find index 49225b90..113d4eec 100755 --- a/bin/pt-find +++ b/bin/pt-find @@ -2082,7 +2082,7 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] || $row->[0] ne $tbl ) { + if ( !$row->[0] ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-heartbeat b/bin/pt-heartbeat index b4a316a6..2cd72dac 100755 --- a/bin/pt-heartbeat +++ b/bin/pt-heartbeat @@ -3956,7 +3956,7 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] || $row->[0] ne $tbl ) { + if ( !$row->[0] ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-index-usage b/bin/pt-index-usage index 88886bed..344738ff 100755 --- a/bin/pt-index-usage +++ b/bin/pt-index-usage @@ -3334,7 +3334,7 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] || $row->[0] ne $tbl ) { + if ( !$row->[0] ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-kill b/bin/pt-kill index 27d08554..c722a263 100755 --- a/bin/pt-kill +++ b/bin/pt-kill @@ -3205,7 +3205,7 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] || $row->[0] ne $tbl ) { + if ( !$row->[0] ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index 1f13f9c6..05b40871 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -3524,7 +3524,7 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] || $row->[0] ne $tbl ) { + if ( !$row->[0] ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-query-digest b/bin/pt-query-digest index f6bf5d52..6dac21ab 100755 --- a/bin/pt-query-digest +++ b/bin/pt-query-digest @@ -9085,7 +9085,7 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] || $row->[0] ne $tbl ) { + if ( !$row->[0] ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index 8892fbeb..172b0943 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -4718,7 +4718,7 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] || $row->[0] ne $tbl ) { + if ( !$row->[0] ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-table-sync b/bin/pt-table-sync index d0e44217..e11a7888 100755 --- a/bin/pt-table-sync +++ b/bin/pt-table-sync @@ -3062,7 +3062,7 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] || $row->[0] ne $tbl ) { + if ( !$row->[0] ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-table-usage b/bin/pt-table-usage index 20d600c3..62d76c44 100755 --- a/bin/pt-table-usage +++ b/bin/pt-table-usage @@ -7072,7 +7072,7 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] || $row->[0] ne $tbl ) { + if ( !$row->[0] ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/lib/TableParser.pm b/lib/TableParser.pm index c6c05ec4..8bfa8bb7 100644 --- a/lib/TableParser.pm +++ b/lib/TableParser.pm @@ -362,7 +362,7 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] || $row->[0] ne $tbl ) { + if ( !$row->[0] ) { PTDEBUG && _d('Table does not exist'); return 0; } From 75feef2f963af73354066671206d7bb4f75ba864 Mon Sep 17 00:00:00 2001 From: Sveta Smirnova Date: Fri, 15 Aug 2025 17:16:37 +0300 Subject: [PATCH 2/2] PT-2401 - pt-online-schema-change 'table does not exist' on macos - Modified code, so it still checks table name but based on the lower_case_table_names option --- bin/pt-archiver | 10 +++------- bin/pt-duplicate-key-checker | 10 +++------- bin/pt-find | 10 +++------- bin/pt-heartbeat | 10 +++------- bin/pt-index-usage | 10 +++------- bin/pt-kill | 10 +++------- bin/pt-online-schema-change | 10 +++------- bin/pt-query-digest | 10 +++------- bin/pt-table-checksum | 10 +++------- bin/pt-table-sync | 10 +++------- bin/pt-table-usage | 10 +++------- lib/TableParser.pm | 10 +++------- 12 files changed, 36 insertions(+), 84 deletions(-) diff --git a/bin/pt-archiver b/bin/pt-archiver index 9eaa72c7..20b6b4dd 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -2114,12 +2114,6 @@ sub check_table { return 0; } - PTDEBUG && _d("lower_case_table_names=$lower_case_table_names"); - if ($lower_case_table_names > 0) { - PTDEBUG && _d("MySQL uses case-insensitive lookup, converting '$tbl' to lowercase"); - $tbl = lc $tbl; - } - my $db_tbl = $q->quote($db, $tbl); PTDEBUG && _d('Checking', $db_tbl); @@ -2135,7 +2129,9 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] ) { + if ( !$row->[0] + || ( $lower_case_table_names == 0 && $row->[0] ne $tbl ) + || ( $lower_case_table_names > 0 && lc $row->[0] ne lc $tbl ) ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-duplicate-key-checker b/bin/pt-duplicate-key-checker index 2f87f4e9..af9a0dea 100755 --- a/bin/pt-duplicate-key-checker +++ b/bin/pt-duplicate-key-checker @@ -504,12 +504,6 @@ sub check_table { return 0; } - PTDEBUG && _d("lower_case_table_names=$lower_case_table_names"); - if ($lower_case_table_names > 0) { - PTDEBUG && _d("MySQL uses case-insensitive lookup, converting '$tbl' to lowercase"); - $tbl = lc $tbl; - } - my $db_tbl = $q->quote($db, $tbl); PTDEBUG && _d('Checking', $db_tbl); @@ -525,7 +519,9 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] ) { + if ( !$row->[0] + || ( $lower_case_table_names == 0 && $row->[0] ne $tbl ) + || ( $lower_case_table_names > 0 && lc $row->[0] ne lc $tbl ) ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-find b/bin/pt-find index 113d4eec..f1f53a41 100755 --- a/bin/pt-find +++ b/bin/pt-find @@ -2061,12 +2061,6 @@ sub check_table { return 0; } - PTDEBUG && _d("lower_case_table_names=$lower_case_table_names"); - if ($lower_case_table_names > 0) { - PTDEBUG && _d("MySQL uses case-insensitive lookup, converting '$tbl' to lowercase"); - $tbl = lc $tbl; - } - my $db_tbl = $q->quote($db, $tbl); PTDEBUG && _d('Checking', $db_tbl); @@ -2082,7 +2076,9 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] ) { + if ( !$row->[0] + || ( $lower_case_table_names == 0 && $row->[0] ne $tbl ) + || ( $lower_case_table_names > 0 && lc $row->[0] ne lc $tbl ) ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-heartbeat b/bin/pt-heartbeat index 2cd72dac..e22121da 100755 --- a/bin/pt-heartbeat +++ b/bin/pt-heartbeat @@ -3935,12 +3935,6 @@ sub check_table { return 0; } - PTDEBUG && _d("lower_case_table_names=$lower_case_table_names"); - if ($lower_case_table_names > 0) { - PTDEBUG && _d("MySQL uses case-insensitive lookup, converting '$tbl' to lowercase"); - $tbl = lc $tbl; - } - my $db_tbl = $q->quote($db, $tbl); PTDEBUG && _d('Checking', $db_tbl); @@ -3956,7 +3950,9 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] ) { + if ( !$row->[0] + || ( $lower_case_table_names == 0 && $row->[0] ne $tbl ) + || ( $lower_case_table_names > 0 && lc $row->[0] ne lc $tbl ) ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-index-usage b/bin/pt-index-usage index 344738ff..aba66f6f 100755 --- a/bin/pt-index-usage +++ b/bin/pt-index-usage @@ -3313,12 +3313,6 @@ sub check_table { return 0; } - PTDEBUG && _d("lower_case_table_names=$lower_case_table_names"); - if ($lower_case_table_names > 0) { - PTDEBUG && _d("MySQL uses case-insensitive lookup, converting '$tbl' to lowercase"); - $tbl = lc $tbl; - } - my $db_tbl = $q->quote($db, $tbl); PTDEBUG && _d('Checking', $db_tbl); @@ -3334,7 +3328,9 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] ) { + if ( !$row->[0] + || ( $lower_case_table_names == 0 && $row->[0] ne $tbl ) + || ( $lower_case_table_names > 0 && lc $row->[0] ne lc $tbl ) ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-kill b/bin/pt-kill index c722a263..dbd5d4f6 100755 --- a/bin/pt-kill +++ b/bin/pt-kill @@ -3184,12 +3184,6 @@ sub check_table { return 0; } - PTDEBUG && _d("lower_case_table_names=$lower_case_table_names"); - if ($lower_case_table_names > 0) { - PTDEBUG && _d("MySQL uses case-insensitive lookup, converting '$tbl' to lowercase"); - $tbl = lc $tbl; - } - my $db_tbl = $q->quote($db, $tbl); PTDEBUG && _d('Checking', $db_tbl); @@ -3205,7 +3199,9 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] ) { + if ( !$row->[0] + || ( $lower_case_table_names == 0 && $row->[0] ne $tbl ) + || ( $lower_case_table_names > 0 && lc $row->[0] ne lc $tbl ) ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index 05b40871..3ca74de3 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -3503,12 +3503,6 @@ sub check_table { return 0; } - PTDEBUG && _d("lower_case_table_names=$lower_case_table_names"); - if ($lower_case_table_names > 0) { - PTDEBUG && _d("MySQL uses case-insensitive lookup, converting '$tbl' to lowercase"); - $tbl = lc $tbl; - } - my $db_tbl = $q->quote($db, $tbl); PTDEBUG && _d('Checking', $db_tbl); @@ -3524,7 +3518,9 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] ) { + if ( !$row->[0] + || ( $lower_case_table_names == 0 && $row->[0] ne $tbl ) + || ( $lower_case_table_names > 0 && lc $row->[0] ne lc $tbl ) ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-query-digest b/bin/pt-query-digest index 6dac21ab..22ead0ac 100755 --- a/bin/pt-query-digest +++ b/bin/pt-query-digest @@ -9064,12 +9064,6 @@ sub check_table { return 0; } - PTDEBUG && _d("lower_case_table_names=$lower_case_table_names"); - if ($lower_case_table_names > 0) { - PTDEBUG && _d("MySQL uses case-insensitive lookup, converting '$tbl' to lowercase"); - $tbl = lc $tbl; - } - my $db_tbl = $q->quote($db, $tbl); PTDEBUG && _d('Checking', $db_tbl); @@ -9085,7 +9079,9 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] ) { + if ( !$row->[0] + || ( $lower_case_table_names == 0 && $row->[0] ne $tbl ) + || ( $lower_case_table_names > 0 && lc $row->[0] ne lc $tbl ) ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index 172b0943..392e92b8 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -4697,12 +4697,6 @@ sub check_table { return 0; } - PTDEBUG && _d("lower_case_table_names=$lower_case_table_names"); - if ($lower_case_table_names > 0) { - PTDEBUG && _d("MySQL uses case-insensitive lookup, converting '$tbl' to lowercase"); - $tbl = lc $tbl; - } - my $db_tbl = $q->quote($db, $tbl); PTDEBUG && _d('Checking', $db_tbl); @@ -4718,7 +4712,9 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] ) { + if ( !$row->[0] + || ( $lower_case_table_names == 0 && $row->[0] ne $tbl ) + || ( $lower_case_table_names > 0 && lc $row->[0] ne lc $tbl ) ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-table-sync b/bin/pt-table-sync index e11a7888..2c984f96 100755 --- a/bin/pt-table-sync +++ b/bin/pt-table-sync @@ -3041,12 +3041,6 @@ sub check_table { return 0; } - PTDEBUG && _d("lower_case_table_names=$lower_case_table_names"); - if ($lower_case_table_names > 0) { - PTDEBUG && _d("MySQL uses case-insensitive lookup, converting '$tbl' to lowercase"); - $tbl = lc $tbl; - } - my $db_tbl = $q->quote($db, $tbl); PTDEBUG && _d('Checking', $db_tbl); @@ -3062,7 +3056,9 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] ) { + if ( !$row->[0] + || ( $lower_case_table_names == 0 && $row->[0] ne $tbl ) + || ( $lower_case_table_names > 0 && lc $row->[0] ne lc $tbl ) ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/bin/pt-table-usage b/bin/pt-table-usage index 62d76c44..fcfa180b 100755 --- a/bin/pt-table-usage +++ b/bin/pt-table-usage @@ -7051,12 +7051,6 @@ sub check_table { return 0; } - PTDEBUG && _d("lower_case_table_names=$lower_case_table_names"); - if ($lower_case_table_names > 0) { - PTDEBUG && _d("MySQL uses case-insensitive lookup, converting '$tbl' to lowercase"); - $tbl = lc $tbl; - } - my $db_tbl = $q->quote($db, $tbl); PTDEBUG && _d('Checking', $db_tbl); @@ -7072,7 +7066,9 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] ) { + if ( !$row->[0] + || ( $lower_case_table_names == 0 && $row->[0] ne $tbl ) + || ( $lower_case_table_names > 0 && lc $row->[0] ne lc $tbl ) ) { PTDEBUG && _d('Table does not exist'); return 0; } diff --git a/lib/TableParser.pm b/lib/TableParser.pm index 8bfa8bb7..46532558 100644 --- a/lib/TableParser.pm +++ b/lib/TableParser.pm @@ -341,12 +341,6 @@ sub check_table { return 0; } - PTDEBUG && _d("lower_case_table_names=$lower_case_table_names"); - if ($lower_case_table_names > 0) { - PTDEBUG && _d("MySQL uses case-insensitive lookup, converting '$tbl' to lowercase"); - $tbl = lc $tbl; - } - my $db_tbl = $q->quote($db, $tbl); PTDEBUG && _d('Checking', $db_tbl); @@ -362,7 +356,9 @@ sub check_table { $self->{check_table_error} = $e; return 0; } - if ( !$row->[0] ) { + if ( !$row->[0] + || ( $lower_case_table_names == 0 && $row->[0] ne $tbl ) + || ( $lower_case_table_names > 0 && lc $row->[0] ne lc $tbl ) ) { PTDEBUG && _d('Table does not exist'); return 0; }