コード例 #1
0
        bool Parse_BindingField_Content(MySqlStreamReader reader)
        {
            if (!reader.Ensure(_currentHeader.ContentLength))
            {
                return(_needMoreData = true);
            }

            var field = new FieldPacket(_currentHeader, _isProtocol41);

            field.ParsePacketContent(reader);
            field.FieldIndex = _tableHeader.ColumnCount; //set this before  add to field list
            _tableHeader.AddField(field);
            //back to binding params field again
            _parsingState = PrepareResponseParseState.BindingField_Header;
            return(false);
        }
コード例 #2
0
        bool Parse_Field_Content(MySqlStreamReader reader)
        {
            if (!reader.Ensure(_currentHeader.ContentLength)) //check if length is enough to parse
            {
#if DEBUG
                reader.dbugMonitorData1 = true;
#endif
                return(_needMoreData = true);
            }


            var fieldPacket = new FieldPacket(_currentHeader, this._isProtocol41);
            fieldPacket.ParsePacketContent(reader);
            fieldPacket.FieldIndex = _tableHeader.ColumnCount; //set this before  add to field list
            _tableHeader.AddField(fieldPacket);

#if DEBUG
            //TODO:review here
            if (fieldPacket.dbugFailure)
            {
                throw new NotSupportedException();
            }
#endif

            //next state => field header of next field
            _parsingState = ResultPacketState.Field_Header;
            return(false);
        }
コード例 #3
0
ファイル: Query.cs プロジェクト: mzfhhhh/SharpConnect.MySql
        public void Prepare()
        {
            //prepare sql query
            _prepareContext = null;

            if (_cmdParams == null)
            {
                return;
            }

            _writer.Reset();

            string realSql = _sqlStrTemplate.BindValues(_cmdParams, true);
            ComPrepareStatementPacket preparePacket = new ComPrepareStatementPacket(realSql);

            preparePacket.WritePacket(_writer);
            SendPacket(_writer.ToArray());

            OkPrepareStmtPacket okPreparePacket = new OkPrepareStmtPacket();

            okPreparePacket = ParsePrepareResponse();
            if (okPreparePacket != null)
            {
                _prepareContext = new PreparedContext(okPreparePacket.statement_id, _sqlStrTemplate);

                if (okPreparePacket.num_params > 0)
                {
                    var tableHeader = new TableHeader();
                    tableHeader.TypeCast   = typeCast;
                    tableHeader.NestTables = nestTables;
                    tableHeader.ConnConfig = _conn.config;
                    for (int i = 0; i < okPreparePacket.num_params; i++)
                    {
                        //no meaing for each field?
                        FieldPacket field = ParseColumn();
                        tableHeader.AddField(field);
                    }

                    //set table after the table is ready!
                    _prepareContext.Setup(tableHeader);

                    ParseEOF();
                }
                if (okPreparePacket.num_columns > 0)
                {
                    _tableHeader            = new TableHeader();
                    _tableHeader.TypeCast   = typeCast;
                    _tableHeader.NestTables = nestTables;
                    _tableHeader.ConnConfig = _conn.config;

                    for (int i = 0; i < okPreparePacket.num_columns; i++)
                    {
                        FieldPacket field = ParseColumn();
                        _tableHeader.AddField(field);
                    }
                    ParseEOF();
                }
            }
        }
コード例 #4
0
ファイル: Query.cs プロジェクト: mzfhhhh/SharpConnect.MySql
        void ParseResultSet()
        {
            ResultSetHeaderPacket resultPacket = new ResultSetHeaderPacket();

            resultPacket.ParsePacket(_parser);

            this._tableHeader       = new TableHeader();
            _tableHeader.TypeCast   = typeCast;
            _tableHeader.NestTables = nestTables;
            _tableHeader.ConnConfig = _conn.config;

            bool protocol41 = _conn.IsProtocol41;

            while (_receiveBuffer[_parser.Position + 4] != EOF_CODE)
            {
                FieldPacket fieldPacket = ParseColumn();
                _tableHeader.AddField(fieldPacket);
            }

            EofPacket fieldEof = ParseEOF();

            //-----
            _lastRow = new RowDataPacket(_tableHeader);
        }