@@ -364,7 +364,7 @@ public async Task<bool> TryResetConnectionAsync(ConnectionSettings cs, IOBehavio
364364
365365 try
366366 {
367- if ( ServerVersion . Version . CompareTo ( ServerVersions . SupportsResetConnection ) >= 0 )
367+ if ( DatabaseOverride == null && ServerVersion . Version . CompareTo ( ServerVersions . SupportsResetConnection ) >= 0 )
368368 {
369369 m_logArguments [ 1 ] = ServerVersion . OriginalString ;
370370 Log . Debug ( "Session{0} ServerVersion={1} supports reset connection; sending reset connection request" , m_logArguments ) ;
@@ -380,8 +380,17 @@ public async Task<bool> TryResetConnectionAsync(ConnectionSettings cs, IOBehavio
380380 else
381381 {
382382 // optimistically hash the password with the challenge from the initial handshake (supported by MariaDB; doesn't appear to be supported by MySQL)
383- m_logArguments [ 1 ] = ServerVersion . OriginalString ;
384- Log . Debug ( "Session{0} ServerVersion={1} doesn't support reset connection; sending change user request" , m_logArguments ) ;
383+ if ( DatabaseOverride == null )
384+ {
385+ m_logArguments [ 1 ] = ServerVersion . OriginalString ;
386+ Log . Debug ( "Session{0} ServerVersion={1} doesn't support reset connection; sending change user request" , m_logArguments ) ;
387+ }
388+ else
389+ {
390+ m_logArguments [ 1 ] = DatabaseOverride ;
391+ Log . Debug ( "Session{0} sending change user request due to changed Database={1}" , m_logArguments ) ;
392+ DatabaseOverride = null ;
393+ }
385394 var hashedPassword = AuthenticationUtility . CreateAuthenticationResponse ( AuthPluginData , 0 , cs . Password ) ;
386395 using ( var changeUserPayload = ChangeUserPayload . Create ( cs . UserID , hashedPassword , cs . Database , m_supportsConnectionAttributes ? s_connectionAttributes : null ) )
387396 await SendAsync ( changeUserPayload , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
0 commit comments