File tree Expand file tree Collapse file tree 4 files changed +29
-7
lines changed Expand file tree Collapse file tree 4 files changed +29
-7
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
namespace MySQLReplication \BinLog ;
3
3
4
+ use MySQLReplication \BinaryDataReader \BinaryDataReader ;
4
5
use MySQLReplication \BinLog \Exception \BinLogException ;
5
6
use MySQLReplication \Config \Config ;
6
7
use MySQLReplication \Repository \MySQLRepository ;
@@ -253,7 +254,7 @@ private function getBinlogStream()
253
254
$ prelude .= chr (0 );
254
255
$ prelude .= chr (0 );
255
256
$ prelude .= chr (0 );
256
- $ prelude .= pack ( ' Q ' , 4 );
257
+ $ prelude .= BinaryDataReader:: pack64bit ( 4 );
257
258
258
259
$ prelude .= pack ('I ' , $ this ->gtidCollection ->getEncodedLength ());
259
260
$ prelude .= $ this ->gtidCollection ->getEncoded ();
Original file line number Diff line number Diff line change @@ -417,4 +417,22 @@ public function isComplete($size)
417
417
}
418
418
return true ;
419
419
}
420
+
421
+ /**
422
+ * @param int $value
423
+ * @return string
424
+ */
425
+ public static function pack64bit ($ value )
426
+ {
427
+ return pack ('C8 ' ,
428
+ ($ value >> 0 ) & 0xFF ,
429
+ ($ value >> 8 ) & 0xFF ,
430
+ ($ value >> 16 ) & 0xFF ,
431
+ ($ value >> 24 ) & 0xFF ,
432
+ ($ value >> 32 ) & 0xFF ,
433
+ ($ value >> 40 ) & 0xFF ,
434
+ ($ value >> 48 ) & 0xFF ,
435
+ ($ value >> 56 ) & 0xFF
436
+ );
437
+ }
420
438
}
Original file line number Diff line number Diff line change 2
2
3
3
namespace MySQLReplication \Gtid ;
4
4
5
+ use MySQLReplication \BinaryDataReader \BinaryDataReader ;
6
+
5
7
/**
6
8
* Class Gtid
7
9
* @package MySQLReplication\Gtid
@@ -43,19 +45,19 @@ public function __construct($gtid)
43
45
public function getEncoded ()
44
46
{
45
47
$ buffer = pack ('H* ' , $ this ->sid );
46
- $ buffer .= pack ( ' Q ' , count ($ this ->intervals ));
48
+ $ buffer .= BinaryDataReader:: pack64bit ( count ($ this ->intervals ));
47
49
48
50
foreach ($ this ->intervals as $ interval )
49
51
{
50
52
if (count ($ interval ) != 1 )
51
53
{
52
- $ buffer .= pack ( ' Q ' , $ interval [0 ]);
53
- $ buffer .= pack ( ' Q ' , $ interval [1 ]);
54
+ $ buffer .= BinaryDataReader:: pack64bit ( $ interval [0 ]);
55
+ $ buffer .= BinaryDataReader:: pack64bit ( $ interval [1 ]);
54
56
}
55
57
else
56
58
{
57
- $ buffer .= pack ( ' Q ' , $ interval [0 ]);
58
- $ buffer .= pack ( ' Q ' , $ interval [0 ] + 1 );
59
+ $ buffer .= BinaryDataReader:: pack64bit ( $ interval [0 ]);
60
+ $ buffer .= BinaryDataReader:: pack64bit ( $ interval [0 ] + 1 );
59
61
}
60
62
}
61
63
Original file line number Diff line number Diff line change 3
3
namespace MySQLReplication \Gtid ;
4
4
5
5
use Doctrine \Common \Collections \ArrayCollection ;
6
+ use MySQLReplication \BinaryDataReader \BinaryDataReader ;
6
7
7
8
/**
8
9
* Class GtidSet
@@ -29,7 +30,7 @@ public function getEncodedLength()
29
30
*/
30
31
public function getEncoded ()
31
32
{
32
- $ s = pack ( ' Q ' , $ this ->count ());
33
+ $ s = BinaryDataReader:: pack64bit ( $ this ->count ());
33
34
/** @var Gtid $gtid */
34
35
foreach ($ this ->toArray () as $ gtid )
35
36
{
You can’t perform that action at this time.
0 commit comments