Пример #1
0
        //----------------------------------------------------
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
        public override void ParsePacketContent(MySqlStreamReader r)
        {

            _fieldCount = r.ReadByte();
            _errno = r.U2();//2
            if (r.PeekByte() == 0x23)
            {
                _sqlStateMarker = r.ReadChar();
                _sqlState = r.ReadString(5);
            }

            message = r.ReadPacketTerminatedString();
#if DEBUG
            throw new Exception(_sqlStateMarker + _sqlState + " " + message);
#endif
        }
 //----------------------------------------------------
 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;
        }