aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-01-03 13:37:54 +0000
committerrowanbeentje <rowan@beent.je>2010-01-03 13:37:54 +0000
commit44cdc2f18931a6d5a7571b2dc485120a73b33b57 (patch)
tree6b7b49f0c7efb80f1fe42b6ab37656660f5c2884 /Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
parente42f000e98e9ff33a91a86a3e2a0cf04c6778102 (diff)
downloadsequelpro-44cdc2f18931a6d5a7571b2dc485120a73b33b57.tar.gz
sequelpro-44cdc2f18931a6d5a7571b2dc485120a73b33b57.tar.bz2
sequelpro-44cdc2f18931a6d5a7571b2dc485120a73b33b57.zip
- Ensure all results for server variable requests are returned as strings, to avoid binary-mode result issues with certain versions of MySQL (including 4.1.14). This should address Issue #509.
- TableDocument now requests the server version string from MCPConnection, aiding caching
Diffstat (limited to 'Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m')
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m33
1 files changed, 26 insertions, 7 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
index aa5dc842..9f87c0d1 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
@@ -734,6 +734,24 @@ void performThreadedKeepAlive(void *ptr)
#pragma mark Server versions
/**
+ * Return the server version string, or nil on failure.
+ */
+- (NSString *)serverVersionString
+{
+ if (mConnected) {
+ if (serverVersionString == nil) {
+ [self _getServerVersionString];
+ }
+
+ if (serverVersionString) {
+ return [NSString stringWithString:serverVersionString];
+ }
+ }
+
+ return nil;
+}
+
+/**
* rReturn the server major version or -1 on fail
*/
- (NSInteger)serverMajorVersion
@@ -1744,6 +1762,7 @@ void performThreadedKeepAlive(void *ptr)
NSString *theQuery = [NSString stringWithFormat:@"SHOW TABLES FROM %@ LIKE '%@'", dbName, tablesName];
theResult = [self queryString:theQuery];
}
+ [theResult setReturnDataAsStrings:YES];
return theResult;
}
@@ -1773,7 +1792,8 @@ void performThreadedKeepAlive(void *ptr)
NSString *theQuery = [NSString stringWithFormat:@"SHOW COLUMNS FROM %@ LIKE '%@'", tableName, fieldsName];
theResult = [self queryString:theQuery];
}
-
+ [theResult setReturnDataAsStrings:YES];
+
return theResult;
}
@@ -1936,16 +1956,12 @@ void performThreadedKeepAlive(void *ptr)
NSArray *theRow;
id theTZName;
NSTimeZone *theTZ;
-
+
+ [theSessionTZ setReturnDataAsStrings:YES];
[theSessionTZ dataSeek:1ULL];
theRow = [theSessionTZ fetchRowAsArray];
theTZName = [theRow objectAtIndex:1];
- if ( [theTZName isKindOfClass:[NSData class]] ) {
- // MySQL 4.1.14 returns the mysql variables as NSData
- theTZName = [self stringWithText:theTZName];
- }
-
if ([theTZName isEqualToString:@"SYSTEM"]) {
[theSessionTZ dataSeek:0ULL];
theRow = [theSessionTZ fetchRowAsArray];
@@ -1963,6 +1979,7 @@ void performThreadedKeepAlive(void *ptr)
// By default set the time zone to the local one..
// Try to get the name using the previously available variable:
theSessionTZ = [self queryString:@"SHOW VARIABLES LIKE 'timezone'"];
+ [theSessionTZ setReturnDataAsStrings:YES];
[theSessionTZ dataSeek:0ULL];
theRow = [theSessionTZ fetchRowAsArray];
theTZName = [theRow objectAtIndex:1];
@@ -2003,6 +2020,7 @@ void performThreadedKeepAlive(void *ptr)
if (0 == mysql_query(mConnection, queryString)) {
if (mysql_field_count(mConnection) != 0) {
MCPResult *r = [[MCPResult alloc] initWithMySQLPtr:mConnection encoding:mEncoding timeZone:mTimeZone];
+ [r setReturnDataAsStrings:YES];
NSArray *a = [r fetchRowAsArray];
[r autorelease];
if([a count]) {
@@ -2183,6 +2201,7 @@ void performThreadedKeepAlive(void *ptr)
{
if (mConnected) {
MCPResult *theResult = [self queryString:@"SHOW VARIABLES LIKE 'version'"];
+ [theResult setReturnDataAsStrings:YES];
if ([theResult numOfRows]) {
[theResult dataSeek:0];