Skip to content

Commit 1d794b4

Browse files
committed
fix krowinski#115 for mysql 8.0.0
1 parent 6150f0e commit 1d794b4

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/MySQLReplication/BinLog/BinLogSocketConnect.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,14 @@ private function getBinlogStream(): void
192192
$this->executeSQL('SET @master_binlog_checksum = @@global.binlog_checksum');
193193
}
194194

195+
195196
if ($this->config->heartbeatPeriod > 0.00) {
196197
// master_heartbeat_period is in nanoseconds
197-
$this->executeSQL('SET @master_heartbeat_period = ' . $this->config->heartbeatPeriod * 1000000000);
198+
if(version_compare($this->repository->getVersion(),"8.4.0")>=0){
199+
$this->executeSQL('SET @source_heartbeat_period = ' . $this->config->heartbeatPeriod * 1000000000);
200+
}else{
201+
$this->executeSQL('SET @master_heartbeat_period = ' . $this->config->heartbeatPeriod * 1000000000);
202+
}
198203

199204
$this->logger->info('Heartbeat period set to ' . $this->config->heartbeatPeriod . ' seconds');
200205
}

src/MySQLReplication/Repository/MySQLRepository.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,22 @@ public function isCheckSum(): bool
5757

5858
public function getVersion(): string
5959
{
60-
$r = '';
61-
$versions = $this->getConnection()
62-
->fetchAllAssociative('SHOW VARIABLES LIKE "version%"');
63-
64-
foreach ($versions as $version) {
65-
$r .= $version['Value'];
66-
}
60+
$res = $this->getConnection()
61+
->fetchAssociative('SHOW VARIABLES LIKE "version"');
6762

68-
return $r;
63+
return $res['Value']??"";
6964
}
7065

7166
public function getMasterStatus(): MasterStatusDTO
7267
{
73-
$data = $this->getConnection()
74-
->fetchAssociative('SHOW MASTER STATUS');
68+
var_dump($this->getVersion());
69+
if(version_compare($this->getVersion(),"8.4.0")>=0){
70+
$data = $this->getConnection()
71+
->fetchAssociative('SHOW BINARY LOG STATUS');
72+
}else{
73+
$data = $this->getConnection()
74+
->fetchAssociative('SHOW MASTER STATUS');
75+
}
7576
if (empty($data)) {
7677
throw new BinLogException(
7778
MySQLReplicationException::BINLOG_NOT_ENABLED,

0 commit comments

Comments
 (0)