@@ -1966,7 +1966,8 @@ internal TdsOperationStatus TryReadStringWithEncoding(int length, System.Text.En
1966
1966
1967
1967
if ( isPlp )
1968
1968
{
1969
- TdsOperationStatus result = TryReadPlpBytes ( ref buf , 0 , int . MaxValue , out length ) ;
1969
+ bool compatibilityMode = LocalAppContextSwitches . UseCompatibilityAsyncBehaviour ;
1970
+ TdsOperationStatus result = TryReadPlpBytes ( ref buf , 0 , int . MaxValue , out length , canContinue && ! compatibilityMode , canContinue && ! compatibilityMode , compatibilityMode ) ;
1970
1971
if ( result != TdsOperationStatus . Done )
1971
1972
{
1972
1973
value = null ;
@@ -2128,12 +2129,10 @@ internal int ReadPlpBytesChunk(byte[] buff, int offset, int len)
2128
2129
internal TdsOperationStatus TryReadPlpBytes ( ref byte [ ] buff , int offset , int len , out int totalBytesRead )
2129
2130
{
2130
2131
bool canContinue = false ;
2131
- bool isStarting = false ;
2132
- bool isContinuing = false ;
2133
2132
bool compatibilityMode = LocalAppContextSwitches . UseCompatibilityAsyncBehaviour ;
2134
2133
if ( ! compatibilityMode )
2135
2134
{
2136
- ( canContinue , isStarting , isContinuing ) = GetSnapshotStatuses ( ) ;
2135
+ ( canContinue , _ , _ ) = GetSnapshotStatuses ( ) ;
2137
2136
}
2138
2137
return TryReadPlpBytes ( ref buff , offset , len , out totalBytesRead , canContinue , canContinue , compatibilityMode ) ;
2139
2138
}
@@ -2157,7 +2156,16 @@ internal TdsOperationStatus TryReadPlpBytes(ref byte[] buff, int offset, int len
2157
2156
}
2158
2157
2159
2158
AssertValidState ( ) ;
2160
- totalBytesRead = 0 ;
2159
+ if ( writeDataSizeToSnapshot && canContinue && _snapshot != null )
2160
+ {
2161
+ // if there is a snapshot which it contains a stored plp buffer take it
2162
+ // and try to use it if it is the right length
2163
+ buff = TryTakeSnapshotStorage ( ) as byte [ ] ;
2164
+ if ( buff != null )
2165
+ {
2166
+ totalBytesRead = _snapshot . GetPacketDataOffset ( ) ;
2167
+ }
2168
+ }
2161
2169
return TdsOperationStatus . Done ; // No data
2162
2170
}
2163
2171
0 commit comments