Skip to content

Commit

Permalink
- Fixed: maraidb bad binlog when parsing event (#62)
Browse files Browse the repository at this point in the history
- Added: BinLogServerInfo::getRevision()
  • Loading branch information
krowinski committed Mar 24, 2020
1 parent 41866bf commit 6584412
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes

## v6.2.1 (2020-03-24)
- Fixed: maraidb bad binlog when parsing event (#62)
- Added: BinLogServerInfo::getRevision()

## v6.2.0 (2020-02-18)
- Added symfony 5 support #61
- Removed support for symfony 2.3
Expand Down
11 changes: 11 additions & 0 deletions src/MySQLReplication/BinLog/BinLogServerInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static function parsePackage(string $data, string $version): void
}

self::$serverInfo['version_name'] = self::parseVersion($version);
self::$serverInfo['version_revision'] = self::parseRevision($version);
}

public static function getSalt(): string
Expand All @@ -102,6 +103,11 @@ private static function parseVersion(string $version): string
return self::MYSQL_VERSION_GENERIC;
}

public static function getRevision(): float
{
return self::$serverInfo['version_revision'];
}

public static function getVersion(): string
{
return self::$serverInfo['version_name'];
Expand All @@ -121,4 +127,9 @@ public static function isGeneric(): bool
{
return self::MYSQL_VERSION_GENERIC === self::getVersion();
}

private static function parseRevision(string $version): float
{
return (float)$version;
}
}
2 changes: 1 addition & 1 deletion src/MySQLReplication/Event/RotateEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function makeRotateEventDTO(): RotateDTO

private function getSizeToRemoveByVersion(): int
{
if (BinLogServerInfo::isMariaDb()) {
if (BinLogServerInfo::isMariaDb() && BinLogServerInfo::getRevision() <= 10) {
return 0;
}

Expand Down
31 changes: 28 additions & 3 deletions tests/Integration/BasicTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace MySQLReplication\Tests\Integration;
Expand All @@ -7,6 +8,7 @@
use MySQLReplication\Definitions\ConstEventType;
use MySQLReplication\Event\DTO\DeleteRowsDTO;
use MySQLReplication\Event\DTO\QueryDTO;
use MySQLReplication\Event\DTO\RotateDTO;
use MySQLReplication\Event\DTO\TableMapDTO;
use MySQLReplication\Event\DTO\UpdateRowsDTO;
use MySQLReplication\Event\DTO\WriteRowsDTO;
Expand Down Expand Up @@ -228,7 +230,10 @@ public function shouldTruncateTable(): void
self::assertSame('TRUNCATE TABLE test_truncate_column', $event->getQuery());
}

public function testMysql8JsonSetPartialUpdateWithHoles(): void
/**
* @test
*/
public function shouldJsonSetPartialUpdateWithHoles(): void
{
if ($this->checkForVersion(5.7) || BinLogServerInfo::isMariaDb()) {
$this->markTestIncomplete('Only for mysql 5.7 or higher');
Expand Down Expand Up @@ -261,7 +266,10 @@ public function testMysql8JsonSetPartialUpdateWithHoles(): void
);
}

public function testMysql8JsonRemovePartialUpdateWithHoles(): void
/**
* @test
*/
public function shouldJsonRemovePartialUpdateWithHoles(): void
{
if ($this->checkForVersion(5.7) || BinLogServerInfo::isMariaDb()) {
$this->markTestIncomplete('Only for mysql 5.7 or higher');
Expand Down Expand Up @@ -294,7 +302,10 @@ public function testMysql8JsonRemovePartialUpdateWithHoles(): void
);
}

public function testMysql8JsonReplacePartialUpdateWithHoles(): void
/**
* @test
*/
public function shouldJsonReplacePartialUpdateWithHoles(): void
{
if ($this->checkForVersion(5.7) || BinLogServerInfo::isMariaDb()) {
$this->markTestIncomplete('Only for mysql 5.7 or higher');
Expand Down Expand Up @@ -325,6 +336,20 @@ public function testMysql8JsonReplacePartialUpdateWithHoles(): void
'{"age":22,"addr":{"code":100,"detail":{"ab":"9707"}},"name":"Alice"}',
$event->getValues()[0]['after']['j']
);
}

/**
* @test
*/
public function shouldRoteLog(): void
{
$this->connection->exec('FLUSH LOGS');

self::assertInstanceOf(RotateDTO::class, $this->getEvent());

self::assertRegExp(
'/^[a-z-]+\.[\d]+$/',
$this->getEvent()->getEventInfo()->getBinLogCurrent()->getBinFileName()
);
}
}

0 comments on commit 6584412

Please sign in to comment.