@@ -37,33 +37,38 @@ public static OkPayload Create(ReadOnlySpan<byte> span, bool deprecateEof, bool
37
37
var warningCount = ( int ) reader . ReadUInt16 ( ) ;
38
38
string ? newSchema = null ;
39
39
40
- if ( clientSessionTrack && ( serverStatus & ServerStatus . SessionStateChanged ) == ServerStatus . SessionStateChanged )
40
+ if ( clientSessionTrack )
41
41
{
42
- reader . ReadLengthEncodedByteString ( ) ; // human-readable info
43
-
44
- // implies ProtocolCapabilities.SessionTrack
45
- var sessionStateChangeDataLength = checked ( ( int ) reader . ReadLengthEncodedInteger ( ) ) ;
46
- var endOffset = reader . Offset + sessionStateChangeDataLength ;
47
- while ( reader . Offset < endOffset )
42
+ if ( reader . BytesRemaining > 0 )
48
43
{
49
- var kind = ( SessionTrackKind ) reader . ReadByte ( ) ;
50
- var dataLength = ( int ) reader . ReadLengthEncodedInteger ( ) ;
51
- switch ( kind )
44
+ reader . ReadLengthEncodedByteString ( ) ; // human-readable info
45
+
46
+ if ( ( serverStatus & ServerStatus . SessionStateChanged ) == ServerStatus . SessionStateChanged && reader . BytesRemaining > 0 )
52
47
{
53
- case SessionTrackKind . Schema :
54
- newSchema = Encoding . UTF8 . GetString ( reader . ReadLengthEncodedByteString ( ) ) ;
55
- break ;
48
+ // implies ProtocolCapabilities.SessionTrack
49
+ var sessionStateChangeDataLength = checked ( ( int ) reader . ReadLengthEncodedInteger ( ) ) ;
50
+ var endOffset = reader . Offset + sessionStateChangeDataLength ;
51
+ while ( reader . Offset < endOffset )
52
+ {
53
+ var kind = ( SessionTrackKind ) reader . ReadByte ( ) ;
54
+ var dataLength = ( int ) reader . ReadLengthEncodedInteger ( ) ;
55
+ switch ( kind )
56
+ {
57
+ case SessionTrackKind . Schema :
58
+ newSchema = Encoding . UTF8 . GetString ( reader . ReadLengthEncodedByteString ( ) ) ;
59
+ break ;
56
60
57
- default :
58
- reader . Offset += dataLength ;
59
- break ;
61
+ default :
62
+ reader . Offset += dataLength ;
63
+ break ;
64
+ }
65
+ }
60
66
}
61
67
}
62
68
}
63
69
else
64
70
{
65
- // either "string<EOF> info" or "string<lenenc> info" (followed by no session change info)
66
- // ignore human-readable string in both cases
71
+ // ignore "string<EOF> info" human-readable string
67
72
}
68
73
69
74
if ( affectedRowCount == 0 && lastInsertId == 0 && warningCount == 0 && newSchema is null )
0 commit comments