From 6ac449a5ef9c91277a8834333866c5be0f2ec4fb Mon Sep 17 00:00:00 2001 From: svetasmirnova Date: Fri, 10 Feb 2023 18:52:05 +0300 Subject: [PATCH] PT-2114 Incorrect casting of BIT columns by pt-archiver - Improved fix for PT-2123, so it works with 5.7 - Fixed tests for PT-2114, so they work with 5.7 --- bin/pt-archiver | 4 +++- t/pt-archiver/pt-2114.t | 16 ++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bin/pt-archiver b/bin/pt-archiver index 1634662e..2a3bdb81 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -6603,7 +6603,9 @@ sub main { . ($o->get('replace') ? ' REPLACE' : '') . ($o->get('ignore') ? ' IGNORE' : '') . " INTO TABLE $dst->{db_tbl}" - . ($got_charset ? "CHARACTER SET $got_charset" : "") + . ($got_charset ? "CHARACTER SET $got_charset" : + ( $src->{info}->{charset} && $src->{info}->{charset} =~ /utf/ ? + "CHARACTER SET utf8mb4" : "" )) . "(" . join(",", map { $q->quote($_) } @{$ins_stmt->{cols}} ) . ")"; diff --git a/t/pt-archiver/pt-2114.t b/t/pt-archiver/pt-2114.t index 37fa67df..d8497c86 100644 --- a/t/pt-archiver/pt-2114.t +++ b/t/pt-archiver/pt-2114.t @@ -38,7 +38,7 @@ my $exit_status; $output = output( sub { $exit_status = pt_archiver::main( - '--source', 'h=127.1,P=12345,D=pt_2114,t=t1,u=msandbox,p=msandbox', + '--source', 'h=127.1,P=12345,D=pt_2114,t=t1,u=msandbox,p=msandbox,A=utf8mb4', '--where', '(val) in (select a.val from pt_2114.t1_tmp a where id =2)', '--purge') }, @@ -75,8 +75,8 @@ my $one_rows = $dbh->selectall_arrayref('select id, hex(val) from pt_2114.t1 whe $output = output( sub { $exit_status = pt_archiver::main( - '--source', 'h=127.1,P=12345,D=pt_2114,t=t1,u=msandbox,p=msandbox', - '--dest', 'h=127.1,P=12345,D=pt_2114,t=t2,u=msandbox,p=msandbox', + '--source', 'h=127.1,P=12345,D=pt_2114,t=t1,u=msandbox,p=msandbox,A=utf8mb4', + '--dest', 'h=127.1,P=12345,D=pt_2114,t=t2,u=msandbox,p=msandbox,A=utf8mb4', '--where', '(val) in (select a.val from pt_2114.t1_tmp a where id =2)', ) }, @@ -119,8 +119,8 @@ $sb->load_file('master', 't/pt-archiver/samples/pt-2114.sql'); $output = output( sub { $exit_status = pt_archiver::main( - '--source', 'h=127.1,P=12345,D=pt_2114,t=t1,u=msandbox,p=msandbox,L=yes', - '--dest', 'h=127.1,P=12345,D=pt_2114,t=t2,u=msandbox,p=msandbox,L=yes', + '--source', 'h=127.1,P=12345,D=pt_2114,t=t1,u=msandbox,p=msandbox,A=utf8mb4,L=yes', + '--dest', 'h=127.1,P=12345,D=pt_2114,t=t2,u=msandbox,p=msandbox,A=utf8mb4,L=yes', '--where', '(val) in (select a.val from pt_2114.t1_tmp a where id =2)', '--bulk-insert', '--limit', '10') }, @@ -163,7 +163,7 @@ $sb->load_file('master', 't/pt-archiver/samples/pt-2114.sql'); $output = output( sub { $exit_status = pt_archiver::main( - '--source', 'h=127.1,P=12345,D=pt_2114,t=t1,u=msandbox,p=msandbox,L=yes', + '--source', 'h=127.1,P=12345,D=pt_2114,t=t1,u=msandbox,p=msandbox,A=utf8mb4,L=yes', '--where', '(val) in (select a.val from pt_2114.t1_tmp a where id =2)', '--bulk-delete', '--purge', '--limit', '10') }, @@ -200,7 +200,7 @@ $sb->load_file('master', 't/pt-archiver/samples/pt-2114.sql'); $output = output( sub { $exit_status = pt_archiver::main( '--where', '(val) in (select a.val from pt_2114.t1_tmp a where id =2)', - '--source', 'h=127.1,P=12345,D=pt_2114,t=t1,u=msandbox,p=msandbox,L=yes', + '--source', 'h=127.1,P=12345,D=pt_2114,t=t1,u=msandbox,p=msandbox,A=utf8mb4,L=yes', '--file', 'archive.%D.%t', '-c', 'id' ) }, @@ -249,7 +249,7 @@ my $not_archived_rows = $dbh->selectall_arrayref("select id, hex(val) from pt_21 $output = output( sub { $exit_status = pt_archiver::main( - '--source', 'h=127.1,P=12345,D=pt_2114,t=t1,u=msandbox,p=msandbox', + '--source', 'h=127.1,P=12345,D=pt_2114,t=t1,u=msandbox,p=msandbox,A=utf8mb4', '--where', '(val) in (select a.val from pt_2114.t1_tmp a where id =2)', '--purge') },