Skip to content

Commit

Permalink
add reliability section aronud internal read shortcut for netfx
Browse files Browse the repository at this point in the history
  • Loading branch information
Wraith2 committed Sep 29, 2021
1 parent 8a6c14b commit 4eab8ec
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4393,7 +4393,7 @@ out dataLength
}
else
{
Debug.Assert(false, "we have read past the column somehow, this is an error");
//Debug.Assert(false, "we have read past the column somehow, this is an error");
}
}
else
Expand Down Expand Up @@ -5691,9 +5691,25 @@ private static Task<T> GetFieldValueAsyncExecute<T>(Task task, object state)

if (typeof(T) == typeof(Stream) || typeof(T) == typeof(TextReader) || typeof(T) == typeof(XmlReader))
{
if (reader.IsCommandBehavior(CommandBehavior.SequentialAccess) && reader._sharedState._dataReady && reader.TryReadColumnInternal(context._columnIndex, readHeaderOnly: true, forStreaming: false))
if (reader.IsCommandBehavior(CommandBehavior.SequentialAccess) && reader._sharedState._dataReady)
{
return Task.FromResult<T>(reader.GetFieldValueFromSqlBufferInternal<T>(reader._data[columnIndex], reader._metaData[columnIndex], isAsync: true));
bool internalReadSuccess = false;
TdsParser.ReliabilitySection tdsReliabilitySection = new TdsParser.ReliabilitySection();
RuntimeHelpers.PrepareConstrainedRegions();
try
{
tdsReliabilitySection.Start();
internalReadSuccess = reader.TryReadColumnInternal(context._columnIndex, readHeaderOnly: true, forStreaming: false);
}
finally
{
tdsReliabilitySection.Stop();
}

if (internalReadSuccess)
{
return Task.FromResult<T>(reader.GetFieldValueFromSqlBufferInternal<T>(reader._data[columnIndex], reader._metaData[columnIndex], isAsync: true));
}
}
}

Expand Down

0 comments on commit 4eab8ec

Please sign in to comment.