diff options
author | Max <post@wickenrode.com> | 2015-10-30 01:59:39 +0100 |
---|---|---|
committer | Max <post@wickenrode.com> | 2015-10-30 01:59:39 +0100 |
commit | d82dc7bbd87c29895910ae7ff7382d98687eba00 (patch) | |
tree | 7f537489f64778e198823ae1a6a1c8e8bd57f8f2 /Frameworks/SPMySQLFramework | |
parent | 07b2773ec7c74334922577cb7259fcb44da7a888 (diff) | |
download | sequelpro-d82dc7bbd87c29895910ae7ff7382d98687eba00.tar.gz sequelpro-d82dc7bbd87c29895910ae7ff7382d98687eba00.tar.bz2 sequelpro-d82dc7bbd87c29895910ae7ff7382d98687eba00.zip |
Use more reliable way of detecting server version
backport from c7b5e880003153e599a452151ee1f3a3e40aff4c and b2d798ba9282d3acf1a2d65de30849e529d4d255
Diffstat (limited to 'Frameworks/SPMySQLFramework')
-rw-r--r-- | Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Max Packet Size.m | 4 | ||||
-rw-r--r-- | Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m | 15 |
2 files changed, 15 insertions, 4 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Max Packet Size.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Max Packet Size.m index 4f1f1b7b..db1b2ba9 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Max Packet Size.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Max Packet Size.m @@ -108,6 +108,10 @@ // Make a standard query to the server to retrieve the information SPMySQLResult *result = [self queryString:packetQueryString]; + if(!result) { // query fails on sphinxql, mysqld after upgrade without running mysql_upgrade + NSLog(@"Query for max_allowed_packet failed: %@ (%lu) (on %@)", [self lastErrorMessage], [self lastErrorID], [self serverVersionString]); + return; + } [result setReturnDataAsStrings:YES]; // Get the maximum size string diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m index c12312a2..0bfef1a0 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m @@ -454,6 +454,17 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS mysqlConnectionThreadId = mySQLConnection->thread_id; lastConnectionUsedTime = 0; + // Copy the server version string to the instance variable + if (serverVersionString) [serverVersionString release], serverVersionString = nil; + // the mysql_get_server_info() function + // * returns the version name that is part of the initial connection handshake. + // * Unless the connection failed, it will always return a non-null buffer containing at least a '\0'. + // * It will never affect the error variables (since it only returns a struct member) + // + // At that point (handshake) there is no charset and it's highly unlikely this will ever contain something other than ASCII, + // but to be safe, we'll use the Latin1 encoding which won't bail on invalid chars. + serverVersionString = [[NSString alloc] initWithCString:mysql_get_server_info(mySQLConnection) encoding:NSISOLatin1StringEncoding]; + // Update SSL state connectedWithSSL = NO; if (useSSL) connectedWithSSL = (mysql_get_ssl_cipher(mySQLConnection))?YES:NO; @@ -916,10 +927,6 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS [variables setObject:[variableRow objectAtIndex:1] forKey:[variableRow objectAtIndex:0]]; } - // Copy the server version string to the instance variable - if (serverVersionString) [serverVersionString release], serverVersionString = nil; - serverVersionString = [[variables objectForKey:@"version"] retain]; - // Get the connection encoding. Although a specific encoding may have been requested on // connection, it may be overridden by init_connect commands or connection state changes. // Default to latin1 for older server versions. |