@@ -61,6 +61,7 @@ public ServerSession(ConnectionPool? pool, int poolGeneration, int id)
61
61
public WeakReference < MySqlConnection > ? OwningConnection { get ; set ; }
62
62
public bool SupportsComMulti => m_supportsComMulti ;
63
63
public bool SupportsDeprecateEof => m_supportsDeprecateEof ;
64
+ public bool SupportsQueryAttributes { get ; private set ; }
64
65
public bool SupportsSessionTrack => m_supportsSessionTrack ;
65
66
public bool ProcAccessDenied { get ; set ; }
66
67
public ICollection < KeyValuePair < string , object ? > > ActivityTags => m_activityTags ;
@@ -315,7 +316,7 @@ public void FinishQuerying()
315
316
// In order to handle this case, we issue a dummy query that will consume the pending cancellation.
316
317
// See https://bugs.mysql.com/bug.php?id=45679
317
318
Log . Debug ( "Session{0} sending 'DO SLEEP(0)' command to clear pending cancellation" , m_logArguments ) ;
318
- var payload = QueryPayload . Create ( "DO SLEEP(0);" ) ;
319
+ var payload = QueryPayload . Create ( SupportsQueryAttributes , "DO SLEEP(0);" ) ;
319
320
#pragma warning disable CA2012 // Safe because method completes synchronously
320
321
SendAsync ( payload , IOBehavior . Synchronous , CancellationToken . None ) . GetAwaiter ( ) . GetResult ( ) ;
321
322
payload = ReceiveReplyAsync ( IOBehavior . Synchronous , CancellationToken . None ) . GetAwaiter ( ) . GetResult ( ) ;
@@ -463,10 +464,13 @@ public async Task DisposeAsync(IOBehavior ioBehavior, CancellationToken cancella
463
464
m_supportsComMulti = ( initialHandshake . ProtocolCapabilities & ProtocolCapabilities . MariaDbComMulti ) != 0 ;
464
465
m_supportsConnectionAttributes = ( initialHandshake . ProtocolCapabilities & ProtocolCapabilities . ConnectionAttributes ) != 0 ;
465
466
m_supportsDeprecateEof = ( initialHandshake . ProtocolCapabilities & ProtocolCapabilities . DeprecateEof ) != 0 ;
467
+ SupportsQueryAttributes = ( initialHandshake . ProtocolCapabilities & ProtocolCapabilities . QueryAttributes ) != 0 ;
466
468
m_supportsSessionTrack = ( initialHandshake . ProtocolCapabilities & ProtocolCapabilities . SessionTrack ) != 0 ;
467
469
var serverSupportsSsl = ( initialHandshake . ProtocolCapabilities & ProtocolCapabilities . Ssl ) != 0 ;
468
470
m_characterSet = ServerVersion . Version >= ServerVersions . SupportsUtf8Mb4 ? CharacterSet . Utf8Mb4GeneralCaseInsensitive : CharacterSet . Utf8GeneralCaseInsensitive ;
469
- m_setNamesPayload = ServerVersion . Version >= ServerVersions . SupportsUtf8Mb4 ? s_setNamesUtf8mb4Payload : s_setNamesUtf8Payload ;
471
+ m_setNamesPayload = ServerVersion . Version >= ServerVersions . SupportsUtf8Mb4 ?
472
+ ( SupportsQueryAttributes ? s_setNamesUtf8mb4WithAttributesPayload : s_setNamesUtf8mb4NoAttributesPayload ) :
473
+ ( SupportsQueryAttributes ? s_setNamesUtf8WithAttributesPayload : s_setNamesUtf8NoAttributesPayload ) ;
470
474
471
475
// disable pipelining for RDS MySQL 5.7 (assuming Aurora); otherwise take it from the connection string or default to true
472
476
if ( ! cs . Pipelining . HasValue && ServerVersion . Version . Major == 5 && ServerVersion . Version . Minor == 7 && HostName . EndsWith ( ".rds.amazonaws.com" , StringComparison . OrdinalIgnoreCase ) )
@@ -495,9 +499,9 @@ public async Task DisposeAsync(IOBehavior ioBehavior, CancellationToken cancella
495
499
}
496
500
}
497
501
498
- Log . Debug ( "Session{0} made connection; ServerVersion={1}; ConnectionId={2}; Compression={3}; Attributes={4}; DeprecateEof={5}; Ssl={6}; SessionTrack={7}; Pipelining={8}" ,
502
+ Log . Debug ( "Session{0} made connection; ServerVersion={1}; ConnectionId={2}; Compression={3}; Attributes={4}; DeprecateEof={5}; Ssl={6}; SessionTrack={7}; Pipelining={8}; QueryAttributes={9} " ,
499
503
m_logArguments [ 0 ] , ServerVersion . OriginalString , ConnectionId ,
500
- m_useCompression , m_supportsConnectionAttributes , m_supportsDeprecateEof , serverSupportsSsl , m_supportsSessionTrack , m_supportsPipelining ) ;
504
+ m_useCompression , m_supportsConnectionAttributes , m_supportsDeprecateEof , serverSupportsSsl , m_supportsSessionTrack , m_supportsPipelining , SupportsQueryAttributes ) ;
501
505
502
506
if ( cs . SslMode != MySqlSslMode . None && ( cs . SslMode != MySqlSslMode . Preferred || serverSupportsSsl ) )
503
507
{
@@ -1633,7 +1637,7 @@ private async Task GetRealServerDetailsAsync(IOBehavior ioBehavior, Cancellation
1633
1637
Log . Debug ( "Session{0} detected proxy; getting CONNECTION_ID(), VERSION() from server" , m_logArguments ) ;
1634
1638
try
1635
1639
{
1636
- await SendAsync ( QueryPayload . Create ( "SELECT CONNECTION_ID(), VERSION();" ) , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
1640
+ await SendAsync ( QueryPayload . Create ( SupportsQueryAttributes , "SELECT CONNECTION_ID(), VERSION();" ) , ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
1637
1641
1638
1642
// column count: 2
1639
1643
await ReceiveReplyAsync ( ioBehavior , cancellationToken ) . ConfigureAwait ( false ) ;
@@ -1908,8 +1912,10 @@ protected override void OnStatementBegin(int index)
1908
1912
1909
1913
static ReadOnlySpan < byte > 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-----
1910
1914
static readonly IMySqlConnectorLogger Log = MySqlConnectorLogManager . CreateLogger ( nameof ( ServerSession ) ) ;
1911
- static readonly PayloadData s_setNamesUtf8Payload = QueryPayload . Create ( "SET NAMES utf8;" ) ;
1912
- static readonly PayloadData s_setNamesUtf8mb4Payload = QueryPayload . Create ( "SET NAMES utf8mb4;" ) ;
1915
+ static readonly PayloadData s_setNamesUtf8NoAttributesPayload = QueryPayload . Create ( false , "SET NAMES utf8;" ) ;
1916
+ static readonly PayloadData s_setNamesUtf8mb4NoAttributesPayload = QueryPayload . Create ( false , "SET NAMES utf8mb4;" ) ;
1917
+ static readonly PayloadData s_setNamesUtf8WithAttributesPayload = QueryPayload . Create ( true , "SET NAMES utf8;" ) ;
1918
+ static readonly PayloadData s_setNamesUtf8mb4WithAttributesPayload = QueryPayload . Create ( true , "SET NAMES utf8mb4;" ) ;
1913
1919
static int s_lastId ;
1914
1920
1915
1921
readonly object m_lock ;
0 commit comments