bool Parse_PrepareOk_Header(MySqlStreamReader reader) { //this is first step *** if (!reader.Ensure(PACKET_HEADER_LENGTH + 1)) { return(_needMoreData = true); } _currentHeader = reader.ReadPacketHeader(); byte type = reader.PeekByte(); switch (type) { case ERROR_CODE: _parsingState = PrepareResponseParseState.Error_Content; break; case EOF_CODE: case OK_CODE: _parsingState = PrepareResponseParseState.OkPrepare_Content; break; default: throw new NotSupportedException("Packet type don't match!!"); } return(false); }
//---------------------------------------------------- bool Parse_ColumnField_Header(MySqlStreamReader reader) { if (!reader.Ensure(PACKET_HEADER_LENGTH + 1)) { return(_needMoreData = true); } _currentHeader = reader.ReadPacketHeader(); byte type = reader.PeekByte();//1 switch (type) { case ERROR_CODE: _parsingState = PrepareResponseParseState.Error_Content; break; case EOF_CODE: //? _parsingState = PrepareResponseParseState.ColumnField_EOF; break; default: _parsingState = PrepareResponseParseState.ColumnField_Content; break; } return(false); }
bool Parse_Field_Header(MySqlStreamReader reader) { if (!reader.Ensure(PACKET_HEADER_LENGTH + 1)) //check if length is enough to parse { return(_needMoreData = true); } _currentHeader = reader.ReadPacketHeader(); byte packetType = reader.PeekByte(); switch (packetType) { case ERROR_CODE: _parsingState = ResultPacketState.Error_Content; break; case EOF_CODE: case OK_CODE: _parsingState = ResultPacketState.Field_EOF; break; default: //next state => field content of this field _parsingState = ResultPacketState.Field_Content; break; } return(false); }
public override void Parse(MySqlStreamReader reader) { _finalResult = null; //1.create connection frame //_writer.Reset(); PacketHeader header = reader.ReadPacketHeader(); _handshake = new HandshakePacket(header); //check if _handshake.ParsePacketContent(reader); _finalResult = new MySqlHandshakeResult(_handshake); }
bool Parse_Row_Header(MySqlStreamReader reader) { if (!reader.Ensure(PACKET_HEADER_LENGTH + 1)) { return(_needMoreData = true); } _currentHeader = reader.ReadPacketHeader(); if (_currentHeader.ContentLength == Packet.MAX_PACKET_LENGTH) { //need more than 1 packet for row content _needMoreThan1Packet = true; _parsingState = ResultPacketState.Row_Content; return(false); } else if (_currentHeader.ContentLength > Packet.MAX_PACKET_LENGTH) { throw new NotSupportedException("???"); } if (_needMoreThan1Packet) { //switch to row content _parsingState = ResultPacketState.Row_Content; } else { byte packetType = reader.PeekByte(); switch (packetType) { case ERROR_CODE: _parsingState = ResultPacketState.Error_Content; break; case EOF_CODE: //0x00 or 0xfe the OK packet header _parsingState = ResultPacketState.Row_EOF; break; default: _parsingState = ResultPacketState.Row_Content; break; } } return(false); }
//---------------------------------------------------- bool Parse_ColumnField_Header(MySqlStreamReader reader) { if (!reader.Ensure(PACKET_HEADER_LENGTH + 1)) { return _needMoreData = true; } _currentHeader = reader.ReadPacketHeader(); byte type = reader.PeekByte();//1 switch (type) { case ERROR_CODE: _parsingState = PrepareResponseParseState.Error_Content; break; case EOF_CODE: //? _parsingState = PrepareResponseParseState.ColumnField_EOF; break; default: _parsingState = PrepareResponseParseState.ColumnField_Content; break; } return false; }
bool Parse_PrepareOk_Header(MySqlStreamReader reader) { //this is first step *** if (!reader.Ensure(PACKET_HEADER_LENGTH + 1)) { return _needMoreData = true; } _currentHeader = reader.ReadPacketHeader(); byte type = reader.PeekByte(); switch (type) { case ERROR_CODE: _parsingState = PrepareResponseParseState.Error_Content; break; case EOF_CODE: case OK_CODE: _parsingState = PrepareResponseParseState.OkPrepare_Content; break; default: throw new NotSupportedException("Packet type don't match!!"); } return false; }
bool Parse_Row_Header(MySqlStreamReader reader) { if (!reader.Ensure(PACKET_HEADER_LENGTH + 1)) { return _needMoreData = true; } _currentHeader = reader.ReadPacketHeader(); if (_currentHeader.ContentLength == Packet.MAX_PACKET_LENGTH) { //need more than 1 packet for row content _parsingState = ResultPacketState.Row_Content; return false; } else if (_currentHeader.ContentLength > Packet.MAX_PACKET_LENGTH) { throw new NotSupportedException("???"); } byte packetType = reader.PeekByte(); switch (packetType) { case ERROR_CODE: _parsingState = ResultPacketState.Error_Content; break; case EOF_CODE://0x00 or 0xfe the OK packet header _parsingState = ResultPacketState.Row_EOF; break; default: _parsingState = ResultPacketState.Row_Content; break; } return false; }
bool Parse_Field_Header(MySqlStreamReader reader) { if (!reader.Ensure(PACKET_HEADER_LENGTH + 1)) //check if length is enough to parse { return _needMoreData = true; } _currentHeader = reader.ReadPacketHeader(); byte packetType = reader.PeekByte(); switch (packetType) { case ERROR_CODE: _parsingState = ResultPacketState.Error_Content; break; case EOF_CODE: case OK_CODE: _parsingState = ResultPacketState.Field_EOF; break; default: //next state => field content of this field _parsingState = ResultPacketState.Field_Content; break; } return false; }