Пример #1
0
        bool Parse_Row_Content(MySqlStreamReader reader)
        {
            if (!reader.Ensure(_currentHeader.ContentLength))
            {
                return(_needMoreData = true);
            }
            if (_currentHeader.ContentLength > Packet.MAX_PACKET_LENGTH)
            {
                throw new NotSupportedException("???");
            }
            else if (_currentHeader.ContentLength >= Packet.MAX_PACKET_LENGTH)
            {
                //can't complete in this round
                //so store data into temp extra large buffer
                //and set isLargeData= true
                StoreBuffer(reader, (int)_currentHeader.ContentLength);
                isLargeData = true;
                //we still in the row content state
                _parsingState = ResultPacketState.Row_Header;
                return(false);
            }
            //--------------------------------

            if (_generateResultMode)
            {
                //this is normal mode (opposite to JustFlushOutMode)
                //in this mode we parse packet content
                //and add it to the output rows
                //----------------------------------
                //in  this version row buffer len must < int.MaxLength
                if (_currentHeader.ContentLength > int.MaxValue)
                {
                    throw new NotSupportedException("not support this length");
                }
                //------------------------------------
                if (isLargeData)
                {
                    if (ms == null)
                    {                                      //it should not be null here
                        throw new NotSupportedException(); //?
                    }
                    ms.Write(reader.ReadBuffer((int)_currentHeader.ContentLength), 0,
                             (int)_currentHeader.ContentLength);
                    _rows.Add(new DataRowPacket(_currentHeader, ms.ToArray()));

#if NET20
                    ms.Close();
#endif
                    ms.Dispose();
                    ms = null;

                    isLargeData = false; //reset
                }
                else
                {
                    _rows.Add(new DataRowPacket(_currentHeader,
                                                reader.ReadBuffer((int)_currentHeader.ContentLength)));
                }
            }
            else
            {
                //just flush data***
                //not create data row
                if (_currentHeader.ContentLength > int.MaxValue)
                {
                    throw new Exception("not support content length> int.MaxValue");
                }
                reader.SkipForward((int)_currentHeader.ContentLength);
            }
            //-----------------------------------------------------------------------
            //after this row, next state = next row header
            _parsingState = ResultPacketState.Row_Header;
            return(false);
        }
        bool Parse_Row_Content(MySqlStreamReader reader)
        {
            if (!reader.Ensure(_currentHeader.ContentLength))
            {
                return _needMoreData = true;
            }
            if (_currentHeader.ContentLength > Packet.MAX_PACKET_LENGTH)
            {
                throw new NotSupportedException("???");
            }
            else if (_currentHeader.ContentLength >= Packet.MAX_PACKET_LENGTH)
            {
                //can't complete in this round 
                //so store data into temp extra large buffer 
                //and set isLargeData= true
                StoreBuffer(reader, (int)_currentHeader.ContentLength);
                isLargeData = true;
                //we still in the row content state
                _parsingState = ResultPacketState.Row_Header;
                return false;
            }
            //--------------------------------       

            if (_generateResultMode)
            {
                //this is normal mode (opposite to JustFlushOutMode)
                //in this mode we parse packet content 
                //and add it to the output rows 
                //----------------------------------
                //in  this version row buffer len must < int.MaxLength
                if (_currentHeader.ContentLength > int.MaxValue)
                {
                    throw new NotSupportedException("not support this length");
                }
                //------------------------------------  
                if (isLargeData)
                {
                    if (ms == null)
                    {   //it should not be null here
                        throw new NotSupportedException();//?   
                    }
                    ms.Write(reader.ReadBuffer((int)_currentHeader.ContentLength), 0,
                        (int)_currentHeader.ContentLength);
                    _rows.Add(new DataRowPacket(_currentHeader, ms.ToArray()));

                    ms.Close();
                    ms.Dispose();
                    ms = null;

                    isLargeData = false; //reset
                }
                else
                {
                    _rows.Add(new DataRowPacket(_currentHeader,
                    reader.ReadBuffer((int)_currentHeader.ContentLength)));
                }

            }
            else
            {
                //just flush data*** 
                //not create data row
                if (_currentHeader.ContentLength > int.MaxValue)
                {
                    throw new Exception("not support content length> int.MaxValue");
                }
                reader.SkipForward((int)_currentHeader.ContentLength);
            }
            //-----------------------------------------------------------------------
            //after this row, next state = next row header
            _parsingState = ResultPacketState.Row_Header;
            return false;
        }