Skip to content

Commit

Permalink
fix for varchars longer then signed int #63
Browse files Browse the repository at this point in the history
  • Loading branch information
krowinski committed Apr 15, 2020
1 parent 6584412 commit 49833ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release Notes

## v6.2.2 (2020-04-15)
- Fixed: varchars table length should be read as unsigned int (#63)

## v6.2.1 (2020-03-24)
- Fixed: maraidb bad binlog when parsing event (#62)
- Added: BinLogServerInfo::getRevision()
Expand Down
25 changes: 13 additions & 12 deletions src/MySQLReplication/Event/RowEvent/ColumnDTO.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

namespace MySQLReplication\Event\RowEvent;
Expand Down Expand Up @@ -59,18 +60,18 @@ public static function make(
$bytes = 0;

if ($columnType === ConstFieldType::VARCHAR) {
$maxLength = $binaryDataReader->readInt16();
} else if ($columnType === ConstFieldType::DOUBLE) {
$maxLength = $binaryDataReader->readUInt16();
} elseif ($columnType === ConstFieldType::DOUBLE) {
$size = $binaryDataReader->readUInt8();
} else if ($columnType === ConstFieldType::FLOAT) {
} elseif ($columnType === ConstFieldType::FLOAT) {
$size = $binaryDataReader->readUInt8();
} else if ($columnType === ConstFieldType::TIMESTAMP2) {
} elseif ($columnType === ConstFieldType::TIMESTAMP2) {
$fsp = $binaryDataReader->readUInt8();
} else if ($columnType === ConstFieldType::DATETIME2) {
} elseif ($columnType === ConstFieldType::DATETIME2) {
$fsp = $binaryDataReader->readUInt8();
} else if ($columnType === ConstFieldType::TIME2) {
} elseif ($columnType === ConstFieldType::TIME2) {
$fsp = $binaryDataReader->readUInt8();
} else if ($columnType === ConstFieldType::VAR_STRING || $columnType === ConstFieldType::STRING) {
} elseif ($columnType === ConstFieldType::VAR_STRING || $columnType === ConstFieldType::STRING) {
$metadata = ($binaryDataReader->readUInt8() << 8) + $binaryDataReader->readUInt8();
$realType = $metadata >> 8;
if ($realType === ConstFieldType::SET || $realType === ConstFieldType::ENUM) {
Expand All @@ -79,16 +80,16 @@ public static function make(
} else {
$maxLength = ((($metadata >> 4) & 0x300) ^ 0x300) + ($metadata & 0x00ff);
}
} else if ($columnType === ConstFieldType::BLOB || $columnType === ConstFieldType::IGNORE) {
} elseif ($columnType === ConstFieldType::BLOB || $columnType === ConstFieldType::IGNORE) {
$lengthSize = $binaryDataReader->readUInt8();
} else if ($columnType === ConstFieldType::GEOMETRY) {
} elseif ($columnType === ConstFieldType::GEOMETRY) {
$lengthSize = $binaryDataReader->readUInt8();
} else if ($columnType === ConstFieldType::JSON) {
} elseif ($columnType === ConstFieldType::JSON) {
$lengthSize = $binaryDataReader->readUInt8();
} else if ($columnType === ConstFieldType::NEWDECIMAL) {
} elseif ($columnType === ConstFieldType::NEWDECIMAL) {
$precision = $binaryDataReader->readUInt8();
$decimals = $binaryDataReader->readUInt8();
} else if ($columnType === ConstFieldType::BIT) {
} elseif ($columnType === ConstFieldType::BIT) {
$bits = $binaryDataReader->readUInt8();
$bytes = $binaryDataReader->readUInt8();

Expand Down

0 comments on commit 49833ee

Please sign in to comment.