@@ -328,10 +328,10 @@ public async Task ConnectAsync(ConnectionSettings cs, ILoadBalancer loadBalancer
328328 }
329329 } while ( shouldRetrySsl ) ;
330330
331- if ( m_supportsConnectionAttributes && s_connectionAttributes == null )
332- s_connectionAttributes = CreateConnectionAttributes ( ) ;
331+ if ( m_supportsConnectionAttributes && cs . ConnectionAttributes == null )
332+ cs . ConnectionAttributes = CreateConnectionAttributes ( cs . ApplicationName ) ;
333333
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 ) )
335335 await SendReplyAsync ( handshakeResponsePayload , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
336336 payload = await ReceiveReplyAsync ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
337337
@@ -395,7 +395,7 @@ public async Task<bool> TryResetConnectionAsync(ConnectionSettings cs, IOBehavio
395395 DatabaseOverride = null ;
396396 }
397397 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 ) )
399399 await SendAsync ( changeUserPayload , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
400400 var payload = await ReceiveReplyAsync ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
401401 if ( payload . HeaderByte == AuthenticationMethodSwitchRequestPayload . Signature )
@@ -1269,7 +1269,7 @@ private void VerifyState(State state1, State state2, State state3)
12691269
12701270 internal SslProtocols SslProtocol => m_sslStream ? . SslProtocol ?? SslProtocols . None ;
12711271
1272- private byte [ ] CreateConnectionAttributes ( )
1272+ private byte [ ] CreateConnectionAttributes ( string programName )
12731273 {
12741274 Log . Debug ( "Session{0} creating connection attributes" , m_logArguments ) ;
12751275 var attributesWriter = new ByteBufferWriter ( ) ;
@@ -1298,6 +1298,11 @@ private byte[] CreateConnectionAttributes()
12981298 attributesWriter . WriteLengthEncodedString ( "_pid" ) ;
12991299 attributesWriter . WriteLengthEncodedString ( process . Id . ToString ( CultureInfo . InvariantCulture ) ) ;
13001300 }
1301+ if ( ! string . IsNullOrEmpty ( programName ) )
1302+ {
1303+ attributesWriter . WriteLengthEncodedString ( "program_name" ) ;
1304+ attributesWriter . WriteLengthEncodedString ( programName ) ;
1305+ }
13011306 using ( var connectionAttributesPayload = attributesWriter . ToPayloadData ( ) )
13021307 {
13031308 var connectionAttributes = connectionAttributesPayload . ArraySegment ;
@@ -1349,7 +1354,6 @@ private enum State
13491354
13501355 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-----
13511356 static int s_lastId ;
1352- static byte [ ] s_connectionAttributes ;
13531357 static readonly IMySqlConnectorLogger Log = MySqlConnectorLogManager . CreateLogger ( nameof ( ServerSession ) ) ;
13541358 static readonly PayloadData s_setNamesUtf8mb4Payload = QueryPayload . Create ( "SET NAMES utf8mb4 COLLATE utf8mb4_bin;" ) ;
13551359
0 commit comments