Ejemplo n.º 1
0
        internal void DrainData(TdsParserStateObject stateObj)
        {
            try
            {
                SqlDataReader.SharedState sharedState = stateObj._readerState;
                if (sharedState != null && sharedState._dataReady)
                {
                    var metadata = stateObj._cleanupMetaData;
                    if (stateObj._partialHeaderBytesRead > 0)
                    {
                        if (!stateObj.TryProcessHeader())
                        {
                            throw SQL.SynchronousCallMayNotPend();
                        }
                    }
                    if (0 == sharedState._nextColumnHeaderToRead)
                    {
                        // i. user called read but didn't fetch anything
                        if (!stateObj.Parser.TrySkipRow(stateObj._cleanupMetaData, stateObj))
                        {
                            throw SQL.SynchronousCallMayNotPend();
                        }
                    }
                    else
                    {
                        // iia.  if we still have bytes left from a partially read column, skip
                        if (sharedState._nextColumnDataToRead < sharedState._nextColumnHeaderToRead)
                        {
                            if ((sharedState._nextColumnHeaderToRead > 0) && (metadata[sharedState._nextColumnHeaderToRead - 1].metaType.IsPlp))
                            {
                                if (stateObj._longlen != 0)
                                {
                                    ulong ignored;
                                    if (!TrySkipPlpValue(UInt64.MaxValue, stateObj, out ignored))
                                    {
                                        throw SQL.SynchronousCallMayNotPend();
                                    }
                                }
                            }

                            else if (0 < sharedState._columnDataBytesRemaining)
                            {
                                if (!stateObj.TrySkipLongBytes(sharedState._columnDataBytesRemaining))
                                {
                                    throw SQL.SynchronousCallMayNotPend();
                                }
                            }
                        }


                        // Read the remaining values off the wire for this row
                        if (!stateObj.Parser.TrySkipRow(metadata, sharedState._nextColumnHeaderToRead, stateObj))
                        {
                            throw SQL.SynchronousCallMayNotPend();
                        }
                    }
                }
                Run(RunBehavior.Clean, null, null, null, stateObj);
            }
            catch
            {
                _connHandler.DoomThisConnection();
                throw;
            }
        }
Ejemplo n.º 2
0
        internal void DrainData(TdsParserStateObject stateObj) {
            RuntimeHelpers.PrepareConstrainedRegions();
            try {
#if DEBUG
                TdsParser.ReliabilitySection tdsReliabilitySection = new TdsParser.ReliabilitySection();

                RuntimeHelpers.PrepareConstrainedRegions();
                try {
                    tdsReliabilitySection.Start();
#else
                  {
#endif //DEBUG
                    try {
                        SqlDataReader.SharedState sharedState = stateObj._readerState;
                        if (sharedState != null && sharedState._dataReady) {
                            var metadata = stateObj._cleanupMetaData;
                            if (stateObj._partialHeaderBytesRead > 0) {
                                if (!stateObj.TryProcessHeader()) {
                                    throw SQL.SynchronousCallMayNotPend();
                                }
                            }
                            if (0 == sharedState._nextColumnHeaderToRead) {
                                // i. user called read but didn't fetch anything
                                if (!stateObj.Parser.TrySkipRow(stateObj._cleanupMetaData, stateObj)) {
                                    throw SQL.SynchronousCallMayNotPend();
                                }
                            }
                            else {
                                // iia.  if we still have bytes left from a partially read column, skip
                                if (sharedState._nextColumnDataToRead < sharedState._nextColumnHeaderToRead) {
                                    if ((sharedState._nextColumnHeaderToRead > 0) && (metadata[sharedState._nextColumnHeaderToRead - 1].metaType.IsPlp)) {
                                        if (stateObj._longlen != 0) {
                                            ulong ignored;
                                            if (!TrySkipPlpValue(UInt64.MaxValue, stateObj, out ignored)) {
                                                throw SQL.SynchronousCallMayNotPend();
                                            }
                                        }
                                    }

                                    else if (0 < sharedState._columnDataBytesRemaining) {
                                        if (!stateObj.TrySkipLongBytes(sharedState._columnDataBytesRemaining)) {
                                            throw SQL.SynchronousCallMayNotPend();
                                        }
                                    }

                                }


                                // iib.
                                // now read the remaining values off the wire for this row
                                if (!stateObj.Parser.TrySkipRow(metadata, sharedState._nextColumnHeaderToRead, stateObj)) {
                                    throw SQL.SynchronousCallMayNotPend();
                                }

                            }
                        }
                        Run(RunBehavior.Clean, null, null, null, stateObj);
                    }
                    catch {
                        _connHandler.DoomThisConnection();
                        throw;
                    }
                }
#if DEBUG
                finally {
                    tdsReliabilitySection.Stop();
                }
#endif //DEBUG
            }
            catch (System.OutOfMemoryException) {
                _connHandler.DoomThisConnection();
                throw;
            }
            catch (System.StackOverflowException) {
                _connHandler.DoomThisConnection();
                throw;
            }
            catch (System.Threading.ThreadAbortException) {
                _connHandler.DoomThisConnection();
                throw;
            }
        }