@@ -328,10 +328,10 @@ public async Task ConnectAsync(ConnectionSettings cs, ILoadBalancer loadBalancer
328
328
}
329
329
} while ( shouldRetrySsl ) ;
330
330
331
- if ( m_supportsConnectionAttributes && s_connectionAttributes == null )
332
- s_connectionAttributes = CreateConnectionAttributes ( ) ;
331
+ if ( m_supportsConnectionAttributes && cs . ConnectionAttributes == null )
332
+ cs . ConnectionAttributes = CreateConnectionAttributes ( cs . ApplicationName ) ;
333
333
334
- using ( var handshakeResponsePayload = HandshakeResponse41Payload . Create ( initialHandshake , cs , m_useCompression , m_supportsConnectionAttributes ? s_connectionAttributes : null ) )
334
+ using ( var handshakeResponsePayload = HandshakeResponse41Payload . Create ( initialHandshake , cs , m_useCompression , m_supportsConnectionAttributes ? cs . ConnectionAttributes : null ) )
335
335
await SendReplyAsync ( handshakeResponsePayload , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
336
336
payload = await ReceiveReplyAsync ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
337
337
@@ -395,7 +395,7 @@ public async Task<bool> TryResetConnectionAsync(ConnectionSettings cs, IOBehavio
395
395
DatabaseOverride = null ;
396
396
}
397
397
var hashedPassword = AuthenticationUtility . CreateAuthenticationResponse ( AuthPluginData , 0 , cs . Password ) ;
398
- using ( var changeUserPayload = ChangeUserPayload . Create ( cs . UserID , hashedPassword , cs . Database , m_supportsConnectionAttributes ? s_connectionAttributes : null ) )
398
+ using ( var changeUserPayload = ChangeUserPayload . Create ( cs . UserID , hashedPassword , cs . Database , m_supportsConnectionAttributes ? cs . ConnectionAttributes : null ) )
399
399
await SendAsync ( changeUserPayload , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
400
400
var payload = await ReceiveReplyAsync ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
401
401
if ( payload . HeaderByte == AuthenticationMethodSwitchRequestPayload . Signature )
@@ -1269,7 +1269,7 @@ private void VerifyState(State state1, State state2, State state3)
1269
1269
1270
1270
internal SslProtocols SslProtocol => m_sslStream ? . SslProtocol ?? SslProtocols . None ;
1271
1271
1272
- private byte [ ] CreateConnectionAttributes ( )
1272
+ private byte [ ] CreateConnectionAttributes ( string programName )
1273
1273
{
1274
1274
Log . Debug ( "Session{0} creating connection attributes" , m_logArguments ) ;
1275
1275
var attributesWriter = new ByteBufferWriter ( ) ;
@@ -1298,6 +1298,11 @@ private byte[] CreateConnectionAttributes()
1298
1298
attributesWriter . WriteLengthEncodedString ( "_pid" ) ;
1299
1299
attributesWriter . WriteLengthEncodedString ( process . Id . ToString ( CultureInfo . InvariantCulture ) ) ;
1300
1300
}
1301
+ if ( ! string . IsNullOrEmpty ( programName ) )
1302
+ {
1303
+ attributesWriter . WriteLengthEncodedString ( "program_name" ) ;
1304
+ attributesWriter . WriteLengthEncodedString ( programName ) ;
1305
+ }
1301
1306
using ( var connectionAttributesPayload = attributesWriter . ToPayloadData ( ) )
1302
1307
{
1303
1308
var connectionAttributes = connectionAttributesPayload . ArraySegment ;
@@ -1349,7 +1354,6 @@ private enum State
1349
1354
1350
1355
static readonly byte [ ] s_beginCertificateBytes = new byte [ ] { 45 , 45 , 45 , 45 , 45 , 66 , 69 , 71 , 73 , 78 , 32 , 67 , 69 , 82 , 84 , 73 , 70 , 73 , 67 , 65 , 84 , 69 , 45 , 45 , 45 , 45 , 45 } ; // -----BEGIN CERTIFICATE-----
1351
1356
static int s_lastId ;
1352
- static byte [ ] s_connectionAttributes ;
1353
1357
static readonly IMySqlConnectorLogger Log = MySqlConnectorLogManager . CreateLogger ( nameof ( ServerSession ) ) ;
1354
1358
static readonly PayloadData s_setNamesUtf8mb4Payload = QueryPayload . Create ( "SET NAMES utf8mb4 COLLATE utf8mb4_bin;" ) ;
1355
1359
0 commit comments