diff options
author | Max <post@wickenrode.com> | 2015-07-30 00:13:22 +0200 |
---|---|---|
committer | Max <post@wickenrode.com> | 2015-07-30 00:13:22 +0200 |
commit | 291078f1c4c28e5a2c69358a8aa9883862717e36 (patch) | |
tree | 154ef565031ed3fa93f6780d1eac4dc8045e372d /Frameworks/SPMySQLFramework | |
parent | 26c821cf128255e89a6ff15f98891dbff1fc3840 (diff) | |
download | sequelpro-291078f1c4c28e5a2c69358a8aa9883862717e36.tar.gz sequelpro-291078f1c4c28e5a2c69358a8aa9883862717e36.tar.bz2 sequelpro-291078f1c4c28e5a2c69358a8aa9883862717e36.zip |
Add code to disable mysql protocol compression (no UI) to connect to Amazon Aurora (see #2122)
Diffstat (limited to 'Frameworks/SPMySQLFramework')
4 files changed, 39 insertions, 5 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Copying.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Copying.m index 32efa375..e6b73cab 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Copying.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Copying.m @@ -61,6 +61,7 @@ [copy setUseKeepAlive:useKeepAlive]; [copy setRetryQueriesOnConnectionFailure:retryQueriesOnConnectionFailure]; [copy setDelegateQueryLogging:delegateQueryLogging]; + [copy setClientFlags:clientFlags]; // Active connection state details, like selected database and encoding, are *not* copied. diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h index 1720fcf6..8fe79573 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h @@ -127,6 +127,8 @@ // Queries BOOL retryQueriesOnConnectionFailure; + + SPMySQLClientFlags clientFlags; } #pragma mark - @@ -164,6 +166,14 @@ @property (readwrite, assign) BOOL lastQueryWasCancelled; +/** + * The mysql client capability flags to set when connecting. + * See CLIENT_* in mysql.h + */ +@property (readwrite, assign, nonatomic) SPMySQLClientFlags clientFlags; +- (void)addClientFlags:(SPMySQLClientFlags)opts; +- (void)removeClientFlags:(SPMySQLClientFlags)opts; + #pragma mark - #pragma mark Connection and disconnection diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m index 6fbf5a86..d212867a 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m @@ -41,10 +41,10 @@ static void *mySQLThreadFlag; #pragma mark Class constants // The default connection options for MySQL connections -const NSUInteger SPMySQLConnectionOptions = - CLIENT_COMPRESS | // Enable protocol compression - almost always a win - CLIENT_INTERACTIVE | // Mark ourselves as an interactive client - CLIENT_MULTI_RESULTS; // Multiple result support (very basic, but present) +const SPMySQLClientFlags SPMySQLConnectionOptions = + SPMySQLClientFlagCompression | // Enable protocol compression - almost always a win + SPMySQLClientFlagInteractive | // Mark ourselves as an interactive client + SPMySQLClientFlagMultiResults; // Multiple result support (very basic, but present) // List of permissible ciphers to use for SSL connections const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RSA-AES128-SHA:AES128-SHA:AES256-RMD:AES128-RMD:DES-CBC3-RMD:DHE-RSA-AES256-RMD:DHE-RSA-AES128-RMD:DHE-RSA-DES-CBC3-RMD:RC4-SHA:RC4-MD5:DES-CBC3-SHA:DES-CBC-SHA:EDH-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC-SHA"; @@ -73,6 +73,20 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS @synthesize retryQueriesOnConnectionFailure; @synthesize delegateQueryLogging; @synthesize lastQueryWasCancelled; +@synthesize clientFlags = clientFlags; + +#pragma mark - +#pragma mark Getters and Setters + +- (void)addClientFlags:(SPMySQLClientFlags)opts +{ + [self setClientFlags:([self clientFlags] | opts)]; +} + +- (void)removeClientFlags:(SPMySQLClientFlags)opts +{ + [self setClientFlags:([self clientFlags] & ~opts)]; +} #pragma mark - #pragma mark Initialisation and teardown @@ -188,6 +202,8 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS // Start the ping keepalive timer keepAliveTimer = [[SPMySQLKeepAliveTimer alloc] initWithInterval:10 target:self selector:@selector(_keepAlive)]; + + [self setClientFlags:SPMySQLConnectionOptions]; } return self; @@ -567,7 +583,7 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS mysql_ssl_set(theConnection, theSSLKeyFilePath, theSSLCertificatePath, theCACertificatePath, NULL, theSSLCiphers); } - MYSQL *connectionStatus = mysql_real_connect(theConnection, theHost, theUsername, thePassword, NULL, (unsigned int)port, theSocket, SPMySQLConnectionOptions); + MYSQL *connectionStatus = mysql_real_connect(theConnection, theHost, theUsername, thePassword, NULL, (unsigned int)port, theSocket, [self clientFlags]); // If the connection failed, return NULL if (theConnection != connectionStatus) { diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConstants.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConstants.h index 2dc0f31a..0a1beb96 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConstants.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConstants.h @@ -74,3 +74,10 @@ typedef enum { SPMySQLResultAsLowMemStreamingResult = 2, SPMySQLResultAsStreamingResultStore = 3 } SPMySQLResultType; + +// Redeclared from mysql_com.h (private header) +typedef NS_OPTIONS(unsigned long, SPMySQLClientFlags) { + SPMySQLClientFlagCompression = 32, // CLIENT_COMPRESS + SPMySQLClientFlagInteractive = 1024, // CLIENT_INTERACTIVE + SPMySQLClientFlagMultiResults = (1UL << 17) // CLIENT_MULTI_RESULTS = 131072 +}; |