Skip to content

Commit cd35e17

Browse files
committed
bin position as string
1 parent 9314c8d commit cd35e17

File tree

12 files changed

+36
-42
lines changed

12 files changed

+36
-42
lines changed

CHANGELOG.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
- Change: drop support for < 8.2
66
- Change: moved to enums, promoted properties
77
- Added: logger for more socket info
8-
- Added: slave_uuid support
9-
- Change: config no longer static
8+
- Added: slave_uuid support (#99)
9+
- Change: EventInfo->id is now EventInfo->serverId (#83)
10+
- Change: config no longer static (#94)
1011
- Chore: typos in README/code
11-
- Chore: replace/remove old urls from code
12-
- Chore: changed variables to underscore
13-
- Added: support caching_sha2_password
12+
- Chore: replace/remove old dead doc urls from code
13+
- Chore: changed variables to underscore
14+
- Added: support caching_sha2_password (#102)
1415
- Change: BinLogServerInfo static calls removed also added method getServerInfo to MySQLReplicationFactory
16+
- Change: type of bin log position is now string as it can be bigger then php can hande 2^64-1 (#84)
1517

1618
## v7.0.1 (2021-03-09)
1719

src/MySQLReplication/BinLog/BinLogCurrent.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88

99
class BinLogCurrent implements JsonSerializable
1010
{
11-
private int $binLogPosition;
11+
private string $binLogPosition;
1212

1313
private string $binFileName;
1414

1515
private string $gtid;
1616

1717
private string $mariaDbGtid;
1818

19-
public function getBinLogPosition(): int
19+
public function getBinLogPosition(): string
2020
{
2121
return $this->binLogPosition;
2222
}
2323

24-
public function setBinLogPosition(int $binLogPosition): void
24+
public function setBinLogPosition(string $binLogPosition): void
2525
{
2626
$this->binLogPosition = $binLogPosition;
2727
}

src/MySQLReplication/BinLog/BinLogSocketConnect.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ private function setBinLogDump(): void
296296
$binFilePos = $this->config->binLogPosition;
297297
$binFileName = $this->config->binLogFileName;
298298
// if not set start from newest binlog
299-
if ($binFilePos === 0 && $binFileName === '') {
299+
if ($binFilePos === '' && $binFileName === '') {
300300
$masterStatusDTO = $this->repository->getMasterStatus();
301301
$binFilePos = $masterStatusDTO->position;
302302
$binFileName = $masterStatusDTO->file;

src/MySQLReplication/Config/Config.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function __construct(
1818
public string $mariaDbGtid,
1919
public int $slaveId,
2020
public string $binLogFileName,
21-
public int $binLogPosition,
21+
public string $binLogPosition,
2222
public array $eventsOnly,
2323
public array $eventsIgnore,
2424
public array $tablesOnly,
@@ -74,11 +74,7 @@ public function validate(): void
7474
ConfigException::SLAVE_ID_ERROR_CODE
7575
);
7676
}
77-
if (filter_var($this->binLogPosition, FILTER_VALIDATE_INT, [
78-
'options' => [
79-
'min_range' => 0,
80-
],
81-
]) === false) {
77+
if (bccomp($this->binLogPosition, '0') === -1) {
8278
throw new ConfigException(
8379
ConfigException::BIN_LOG_FILE_POSITION_ERROR_MESSAGE,
8480
ConfigException::BIN_LOG_FILE_POSITION_ERROR_CODE

src/MySQLReplication/Config/ConfigBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ConfigBuilder
2222

2323
private string $binLogFileName = '';
2424

25-
private int $binLogPosition = 0;
25+
private string $binLogPosition = '';
2626

2727
private array $eventsOnly = [];
2828

@@ -105,7 +105,7 @@ public function withBinLogFileName(string $binLogFileName): self
105105
return $this;
106106
}
107107

108-
public function withBinLogPosition(int $binLogPosition): self
108+
public function withBinLogPosition(string $binLogPosition): self
109109
{
110110
$this->binLogPosition = $binLogPosition;
111111

src/MySQLReplication/Event/DTO/RotateDTO.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class RotateDTO extends EventDTO
1313

1414
public function __construct(
1515
EventInfo $eventInfo,
16-
public readonly int $position,
16+
public readonly string $position,
1717
public readonly string $nextBinlog
1818
) {
1919
parent::__construct($eventInfo);

src/MySQLReplication/Event/Event.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private function createEventInfo(BinaryDataReader $binaryDataReader): EventInfo
134134
$binaryDataReader->readUInt8(),
135135
$binaryDataReader->readInt32(),
136136
$binaryDataReader->readInt32(),
137-
$binaryDataReader->readInt32(),
137+
(string)$binaryDataReader->readInt32(),
138138
$binaryDataReader->readUInt16(),
139139
$this->binLogSocketConnect->getCheckSum(),
140140
$this->binLogSocketConnect->getBinLogCurrent()

src/MySQLReplication/Event/EventInfo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class EventInfo implements JsonSerializable
1717
public function __construct(
1818
public readonly int $timestamp,
1919
public readonly int $type,
20-
public readonly int $id,
20+
public readonly int $serverId,
2121
public readonly int $size,
22-
public readonly int $pos,
22+
public readonly string $pos,
2323
public readonly int $flag,
2424
public readonly bool $checkSum,
2525
public readonly BinLogCurrent $binLogCurrent

src/MySQLReplication/Event/RotateEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class RotateEvent extends EventCommon
1313
{
1414
public function makeRotateEventDTO(): RotateDTO
1515
{
16-
$binFilePos = (int)$this->binaryDataReader->readUInt64();
16+
$binFilePos = $this->binaryDataReader->readUInt64();
1717
$binFileName = $this->binaryDataReader->read(
1818
$this->eventInfo->getSizeNoHeader() - $this->getSizeToRemoveByVersion()
1919
);

src/MySQLReplication/Repository/MasterStatusDTO.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
readonly class MasterStatusDTO
88
{
99
public function __construct(
10-
public int $position,
10+
public string $position,
1111
public string $file
1212
) {
1313
}
1414

1515
public static function makeFromArray(array $data): self
1616
{
17-
return new self((int)$data['Position'], (string)$data['File']);
17+
return new self((string)$data['Position'], (string)$data['File']);
1818
}
1919
}

0 commit comments

Comments
 (0)