diff options
author | Max <post@wickenrode.com> | 2015-08-07 23:45:15 +0200 |
---|---|---|
committer | Max <post@wickenrode.com> | 2015-08-07 23:45:15 +0200 |
commit | c7b5e880003153e599a452151ee1f3a3e40aff4c (patch) | |
tree | 14fa6a7c648e08c5a08ab4225a61148709aff17d /Frameworks/SPMySQLFramework | |
parent | 5befad85ccd6d22900942ea73f4018d71038f516 (diff) | |
download | sequelpro-c7b5e880003153e599a452151ee1f3a3e40aff4c.tar.gz sequelpro-c7b5e880003153e599a452151ee1f3a3e40aff4c.tar.bz2 sequelpro-c7b5e880003153e599a452151ee1f3a3e40aff4c.zip |
Added fallback code for server version identification.
Good news: Sequel Pro can now connect to sphinxql server.
Bad news: It will treat it like a MySQL 2 server (or whatever version of Sphinx is running)
Diffstat (limited to 'Frameworks/SPMySQLFramework')
4 files changed, 29 insertions, 17 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..dc453624 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 + 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 Categories/Server Info.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m index c9bf0bfd..dd684c78 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m @@ -42,10 +42,15 @@ */ - (NSString *)serverVersionString { - if (serverVersionString) { - return [NSString stringWithString:serverVersionString]; + if (serverVariableVersion) { + return [NSString stringWithString:serverVariableVersion]; } +#warning FIXME: There is probably a race condition here with -[self _disconnect] + if(mySQLConnection) { + return [self _stringForCString:mysql_get_server_info(mySQLConnection)]; + } + return nil; } @@ -54,9 +59,9 @@ */ - (NSUInteger)serverMajorVersion { - - if (serverVersionString != nil) { - NSString *s = [[serverVersionString componentsSeparatedByString:@"."] objectAtIndex:0]; + NSString *ver; + if ((ver = [self serverVersionString]) != nil) { + NSString *s = [[ver componentsSeparatedByString:@"."] objectAtIndex:0]; return (NSUInteger)[s integerValue]; } @@ -68,8 +73,9 @@ */ - (NSUInteger)serverMinorVersion { - if (serverVersionString != nil) { - NSString *s = [[serverVersionString componentsSeparatedByString:@"."] objectAtIndex:1]; + NSString *ver; + if ((ver = [self serverVersionString]) != nil) { + NSString *s = [[ver componentsSeparatedByString:@"."] objectAtIndex:1]; return (NSUInteger)[s integerValue]; } @@ -81,8 +87,9 @@ */ - (NSUInteger)serverReleaseVersion { - if (serverVersionString != nil) { - NSString *s = [[serverVersionString componentsSeparatedByString:@"."] objectAtIndex:2]; + NSString *ver; + if ((ver = [self serverVersionString]) != nil) { + NSString *s = [[ver componentsSeparatedByString:@"."] objectAtIndex:2]; return (NSUInteger)[[[s componentsSeparatedByString:@"-"] objectAtIndex:0] integerValue]; } @@ -98,9 +105,10 @@ */ - (BOOL)serverVersionIsGreaterThanOrEqualTo:(NSUInteger)aMajorVersion minorVersion:(NSUInteger)aMinorVersion releaseVersion:(NSUInteger)aReleaseVersion { - if (!serverVersionString) return NO; + NSString *ver; + if (!(ver = [self serverVersionString])) return NO; - NSArray *serverVersionParts = [serverVersionString componentsSeparatedByString:@"."]; + NSArray *serverVersionParts = [ver componentsSeparatedByString:@"."]; NSUInteger serverMajorVersion = (NSUInteger)[[serverVersionParts objectAtIndex:0] integerValue]; if (serverMajorVersion < aMajorVersion) return NO; diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h index 8fe79573..c65ec2fb 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h @@ -100,7 +100,7 @@ BOOL previousEncodingUsesLatin1Transport; // Server details - NSString *serverVersionString; + NSString *serverVariableVersion; // Error state for the last query or connection state NSUInteger queryErrorID; diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m index dfe4802f..40c95321 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m @@ -175,7 +175,7 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS [connectionLock setName:@"SPMySQLConnection query lock"]; // Ensure the server detail records are initialised - serverVersionString = nil; + serverVariableVersion = nil; // Start with a blank error state queryErrorID = 0; @@ -249,7 +249,7 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS if (database) [database release], database = nil; if (databaseToRestore) [databaseToRestore release], databaseToRestore = nil; - if (serverVersionString) [serverVersionString release], serverVersionString = nil; + if (serverVariableVersion) [serverVariableVersion release], serverVariableVersion = nil; if (queryErrorMessage) [queryErrorMessage release], queryErrorMessage = nil; if (querySqlstate) [querySqlstate release], querySqlstate = nil; [delegateDecisionLock release]; @@ -911,7 +911,7 @@ asm(".desc ___crashreporter_info__, 0x10"); } // Clear host-specific information - if (serverVersionString) [serverVersionString release], serverVersionString = nil; + if (serverVariableVersion) [serverVariableVersion release], serverVariableVersion = nil; if (database) [database release], database = nil; state = SPMySQLDisconnected; @@ -940,8 +940,8 @@ asm(".desc ___crashreporter_info__, 0x10"); } // Copy the server version string to the instance variable - if (serverVersionString) [serverVersionString release], serverVersionString = nil; - serverVersionString = [[variables objectForKey:@"version"] retain]; + if (serverVariableVersion) [serverVariableVersion release], serverVariableVersion = nil; + serverVariableVersion = [[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. |