Skip to content

Commit

Permalink
Preserve threadId in QUERY_EVENT. (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
mklepaczewski authored Jan 12, 2024
1 parent 4ea690f commit 95f852a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/MySQLReplication/Event/DTO/QueryDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ class QueryDTO extends EventDTO
private $query;
private $database;
private $type = ConstEventsNames::QUERY;
private $threadId;

public function __construct(
EventInfo $eventInfo,
string $database,
int $executionTime,
string $query
string $query,
int $threadId
) {
parent::__construct($eventInfo);

$this->executionTime = $executionTime;
$this->query = $query;
$this->database = $database;
$this->threadId = $threadId;
}

public function getDatabase(): string
Expand All @@ -46,6 +49,11 @@ public function getType(): string
return $this->type;
}

public function getThreadId(): int
{
return $this->threadId;
}

public function __toString(): string
{
return PHP_EOL .
Expand Down
5 changes: 3 additions & 2 deletions src/MySQLReplication/Event/QueryEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class QueryEvent extends EventCommon
{
public function makeQueryDTO(): QueryDTO
{
$this->binaryDataReader->advance(4);
$threadId = $this->binaryDataReader->readUInt32();
$executionTime = $this->binaryDataReader->readUInt32();
$schemaLength = $this->binaryDataReader->readUInt8();
$this->binaryDataReader->advance(2);
Expand All @@ -26,7 +26,8 @@ public function makeQueryDTO(): QueryDTO
$this->eventInfo,
$schema,
$executionTime,
$query
$query,
$threadId
);
}
}

0 comments on commit 95f852a

Please sign in to comment.