@@ -37,33 +37,38 @@ public static OkPayload Create(ReadOnlySpan<byte> span, bool deprecateEof, bool
3737 var warningCount = ( int ) reader . ReadUInt16 ( ) ;
3838 string ? newSchema = null ;
3939
40- if ( clientSessionTrack && ( serverStatus & ServerStatus . SessionStateChanged ) == ServerStatus . SessionStateChanged )
40+ if ( clientSessionTrack )
4141 {
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 )
4843 {
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 )
5247 {
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 ;
5660
57- default :
58- reader . Offset += dataLength ;
59- break ;
61+ default :
62+ reader . Offset += dataLength ;
63+ break ;
64+ }
65+ }
6066 }
6167 }
6268 }
6369 else
6470 {
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
6772 }
6873
6974 if ( affectedRowCount == 0 && lastInsertId == 0 && warningCount == 0 && newSchema is null )
0 commit comments