From a2cd4dfba19bf896ed1703fe7c135968c5a43602 Mon Sep 17 00:00:00 2001 From: davidzhangbj Date: Tue, 5 Nov 2024 07:42:04 +0000 Subject: [PATCH 1/2] Fix the issue of not being able to retrieve the CHARSET in the OceanBase database --- bin/pt-archiver | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/pt-archiver b/bin/pt-archiver index 290ce0414..477a40dd7 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -1995,7 +1995,7 @@ sub parse { my ($keys, $clustered_key) = $self->get_keys($ddl, $opts, \%is_nullable); - my ($charset) = $ddl =~ m/DEFAULT CHARSET=(\w+)/; + my ($charset) = $ddl =~ m/DEFAULT CHARSET\s*=\s*(\w+)/; return { name => $name, From 44cee22db602826223ebc10e914188a62b6bef19 Mon Sep 17 00:00:00 2001 From: David Zhang Date: Tue, 14 Jan 2025 08:40:14 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8DOB=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=9C=A8=E4=B8=80=E4=B8=AASQL=E8=AF=AD=E5=8F=A5=E4=B8=AD?= =?UTF-8?q?=E6=8B=BF=E5=88=B0server=5Fid=E5=92=8Cconnection=5Fid=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/pt-online-schema-change | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index e107983d9..dbac1a311 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -4025,7 +4025,12 @@ sub set_dbh { my $sql = 'SELECT @@server_id /*!50038 , @@hostname*/, CONNECTION_ID() as connection_id'; PTDEBUG && _d($dbh, $sql); - my ($server_id, $hostname, $connection_id) = $dbh->selectrow_array($sql); + # my ($server_id, $hostname, $connection_id) = $dbh->selectrow_array($sql); + # 因为OB的server_id是在binlog执行的, CONNECTION_ID()是在observer执行的,ODP无法在一个SQL语句中同时拿到这两个变量 + # 所以需要分开拿这些变量 + my $server_id = $dbh->selectrow_array('SELECT @@server_id'); + my $hostname = $dbh->selectrow_array('SELECT @@hostname'); + my $connection_id = $dbh->selectrow_array('SELECT CONNECTION_ID() as connection_id'); PTDEBUG && _d($dbh, 'hostname:', $hostname, $server_id); if ( $self->{dbh} && $self->{dbh} == $dbh && $self->{dbh_set} && $self->{dbh_set} == $connection_id) {