diff --git a/bin/pt-archiver b/bin/pt-archiver index acc61b109..392b5168c 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, diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index 1f13f9c61..3256bd300 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -4028,7 +4028,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) {