|
1 |
| -using System.Globalization; |
| 1 | +using System.Buffers.Text; |
2 | 2 | using System.Text;
|
3 | 3 | using MySqlConnector.Core;
|
4 | 4 | using MySqlConnector.Protocol.Serialization;
|
@@ -85,24 +85,21 @@ public static void Verify(ReadOnlySpan<byte> span, IServerCapabilities serverCap
|
85 | 85 | break;
|
86 | 86 |
|
87 | 87 | case SessionTrackKind.SystemVariables:
|
88 |
| - var systemVariableOffset = reader.Offset + dataLength; |
| 88 | + var systemVariablesEndOffset = reader.Offset + dataLength; |
89 | 89 | do
|
90 | 90 | {
|
91 |
| - var variableSv = Encoding.ASCII.GetString(reader.ReadLengthEncodedByteString()); |
92 |
| - var lenSv = reader.ReadLengthEncodedIntegerOrNull(); |
93 |
| - var valueSv = lenSv == -1 |
94 |
| - ? null |
95 |
| - : Encoding.ASCII.GetString(reader.ReadByteString(lenSv)); |
96 |
| - switch (variableSv) |
| 91 | + var systemVariableName = reader.ReadLengthEncodedByteString(); |
| 92 | + var systemVariableValueLength = reader.ReadLengthEncodedIntegerOrNull(); |
| 93 | + var systemVariableValue = systemVariableValueLength == -1 ? default : reader.ReadByteString(systemVariableValueLength); |
| 94 | + if (systemVariableName.SequenceEqual("character_set_client"u8) && systemVariableValueLength != 0) |
97 | 95 | {
|
98 |
| - case "character_set_client": |
99 |
| - clientCharacterSet = valueSv; |
100 |
| - break; |
101 |
| - case "connection_id": |
102 |
| - connectionId = Convert.ToInt32(valueSv, CultureInfo.InvariantCulture); |
103 |
| - break; |
| 96 | + clientCharacterSet = Encoding.ASCII.GetString(systemVariableValue); |
104 | 97 | }
|
105 |
| - } while (reader.Offset < systemVariableOffset); |
| 98 | + else if (systemVariableName.SequenceEqual("connection_id"u8)) |
| 99 | + { |
| 100 | + connectionId = Utf8Parser.TryParse(systemVariableValue, out int parsedConnectionId, out var bytesConsumed) && bytesConsumed == systemVariableValue.Length ? parsedConnectionId : default(int?); |
| 101 | + } |
| 102 | + } while (reader.Offset < systemVariablesEndOffset); |
106 | 103 | break;
|
107 | 104 |
|
108 | 105 | default:
|
|
0 commit comments