Skip to content

Commit 625c483

Browse files
committed
Add missing MySQL 8.0+ binlog event types and handle unknown types gracefully
The ConstEventType enum is missing all event types added in MySQL 8.0+ (types 36-42), causing a ValueError crash when the library encounters any of them. The most commonly triggered one is PARTIAL_UPDATE_ROWS_EVENT (type 39), emitted when binlog_row_value_options=PARTIAL_JSON is enabled. Changes: - Add all missing MySQL 8.0+ event types to ConstEventType: - TRANSACTION_CONTEXT_EVENT (36) - VIEW_CHANGE_EVENT (37) - XA_PREPARE_LOG_EVENT (38) - PARTIAL_UPDATE_ROWS_EVENT (39) - TRANSACTION_PAYLOAD_EVENT (40) - HEARTBEAT_LOG_EVENT_V2 (41) - GTID_TAGGED_LOG_EVENT (42) - Use tryFrom() instead of from() in EventInfo to gracefully handle any future unrecognized event types instead of crashing Ref: https://github.com/mysql/mysql-server/blob/824e2b4064053f7daf17d7f3f84b7a3ed92e5fb4/libs/mysql/binlog/event/binlog_event.h#L285
1 parent 2cb76cd commit 625c483

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/MySQLReplication/Definitions/ConstEventType.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ enum ConstEventType: int
5757
case MARIA_UPDATE_ROWS_COMPRESSED_EVENT = 170;
5858
case MARIA_GTID_EVENT = 162;
5959

60+
// MySQL 8.0+ event types
61+
case TRANSACTION_CONTEXT_EVENT = 36;
62+
case VIEW_CHANGE_EVENT = 37;
63+
case XA_PREPARE_LOG_EVENT = 38;
64+
case PARTIAL_UPDATE_ROWS_EVENT = 39;
65+
case TRANSACTION_PAYLOAD_EVENT = 40;
66+
case HEARTBEAT_LOG_EVENT_V2 = 41;
67+
case GTID_TAGGED_LOG_EVENT = 42;
68+
6069
//Transaction ID for 2PC, written whenever a COMMIT is expected.
6170

6271
// Row-Based Binary Logging

src/MySQLReplication/Event/EventInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(
2828
$this->binLogCurrent->setBinLogPosition($pos);
2929
}
3030
$this->sizeNoHeader = $this->dateTime = null;
31-
$this->typeName = ConstEventType::from($this->type)->name;
31+
$this->typeName = ConstEventType::tryFrom($this->type)?->name;
3232
}
3333

3434
public function getTypeName(): ?string

0 commit comments

Comments
 (0)