/**
  * @param BinaryDataReader $packet
  * @param array $columnSchema
  * @throws ConfigException
  */
 private static function getFieldSpecial(BinaryDataReader $packet, array $columnSchema)
 {
     $metadata = ($packet->readUInt8() << 8) + $packet->readUInt8();
     $real_type = $metadata >> 8;
     if ($real_type === ConstFieldType::SET || $real_type === ConstFieldType::ENUM) {
         self::$field['type'] = $real_type;
         self::$field['size'] = $metadata & 0xff;
         self::getFieldSpecialValues($columnSchema);
     } else {
         self::$field['max_length'] = ($metadata >> 4 & 0x300 ^ 0x300) + ($metadata & 0xff);
     }
 }
 /**
  * @return string
  */
 public function getEncoded()
 {
     $s = BinaryDataReader::pack64bit($this->count());
     /** @var Gtid $gtid */
     foreach ($this->toArray() as $gtid) {
         $s .= $gtid->getEncoded();
     }
     return $s;
 }
Example #3
0
 /**
  * @return string
  */
 public function getEncoded()
 {
     $buffer = pack('H*', $this->sid);
     $buffer .= BinaryDataReader::pack64bit(count($this->intervals));
     foreach ($this->intervals as $interval) {
         if (count($interval) !== 1) {
             $buffer .= BinaryDataReader::pack64bit($interval[0]);
             $buffer .= BinaryDataReader::pack64bit($interval[1]);
         } else {
             $buffer .= BinaryDataReader::pack64bit($interval[0]);
             $buffer .= BinaryDataReader::pack64bit($interval[0] + 1);
         }
     }
     return $buffer;
 }
 private function parseScalar($type)
 {
     if (self::LITERAL === $type) {
         $this->parseBoolean();
     } else {
         if (self::INT16 === $type) {
             $this->jsonBinaryDecoderFormatter->formatValue($this->binaryDataReader->readInt16());
         } else {
             if (self::INT32 === $type) {
                 $this->jsonBinaryDecoderFormatter->formatValue($this->binaryDataReader->readInt32());
             } else {
                 if (self::INT64 === $type) {
                     $this->jsonBinaryDecoderFormatter->formatValue($this->binaryDataReader->readInt64());
                 } else {
                     if (self::UINT16 === $type) {
                         $this->jsonBinaryDecoderFormatter->formatValue($this->binaryDataReader->readUInt16());
                     } else {
                         if (self::UINT64 === $type) {
                             $this->jsonBinaryDecoderFormatter->formatValue($this->binaryDataReader->readUInt64());
                         } else {
                             if (self::DOUBLE === $type) {
                                 $this->jsonBinaryDecoderFormatter->formatValue($this->binaryDataReader->readDouble());
                             } else {
                                 if (self::STRING === $type) {
                                     $this->jsonBinaryDecoderFormatter->formatValue($this->binaryDataReader->read($this->readVariableInt()));
                                 } else {
                                     throw new JsonBinaryDecoderException(JsonBinaryDecoderException::UNKNOWN_JSON_TYPE_MESSAGE . $type, JsonBinaryDecoderException::UNKNOWN_JSON_TYPE_CODE);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * @see https://dev.mysql.com/doc/internals/en/com-binlog-dump-gtid.html
  * @throws BinLogException
  * @throws GtidException
  */
 private function setBinLogDumpGtid()
 {
     $collection = $this->gtidService->makeCollectionFromString($this->config->getGtid());
     $prelude = pack('l', 26 + $collection->getEncodedLength()) . chr(ConstCommand::COM_BINLOG_DUMP_GTID);
     $prelude .= pack('S', 0);
     $prelude .= pack('I', $this->config->getSlaveId());
     $prelude .= pack('I', 3);
     $prelude .= chr(0);
     $prelude .= chr(0);
     $prelude .= chr(0);
     $prelude .= BinaryDataReader::pack64bit(4);
     $prelude .= pack('I', $collection->getEncodedLength());
     $prelude .= $collection->getEncoded();
     $this->writeToSocket($prelude);
     $this->getPacket();
 }