diff options
author | stuconnolly <stuart02@gmail.com> | 2010-03-26 13:14:54 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2010-03-26 13:14:54 +0000 |
commit | 2c558dccc2235bfbd9c8f2114bbffa99c78c4af5 (patch) | |
tree | f22159b831abab0acb06a40c3800bdd32b1cd746 /Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | |
parent | 6fb53eb4a62184f5ed0d8bdf42ff0973dd552ff9 (diff) | |
download | sequelpro-2c558dccc2235bfbd9c8f2114bbffa99c78c4af5.tar.gz sequelpro-2c558dccc2235bfbd9c8f2114bbffa99c78c4af5.tar.bz2 sequelpro-2c558dccc2235bfbd9c8f2114bbffa99c78c4af5.zip |
Minor MCPKit tidy up, including the resolution of potential issues raised during static analysis.
Diffstat (limited to 'Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m')
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index 6f516157..af3bae08 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -28,10 +28,11 @@ #import "MCPConnection.h" #import "MCPResult.h" -#import "MCPStreamingResult.h" #import "MCPNumber.h" #import "MCPNull.h" +#import "MCPStreamingResult.h" #import "MCPConnectionProxy.h" +#import "MCPStringAdditions.h" #include <unistd.h> #include <mach/mach_time.h> @@ -1285,7 +1286,7 @@ void performThreadedKeepAlive(void *ptr) */ - (MCPResult *)queryString:(NSString *)query { - return [self queryString:query usingEncoding:mEncoding streamingResult:MCP_NO_STREAMING]; + return [self queryString:query usingEncoding:mEncoding streamingResult:MCPStreamingNone]; } /** @@ -1295,7 +1296,7 @@ void performThreadedKeepAlive(void *ptr) */ - (MCPStreamingResult *)streamingQueryString:(NSString *)query { - return [self queryString:query usingEncoding:mEncoding streamingResult:MCP_FAST_STREAMING]; + return [self queryString:query usingEncoding:mEncoding streamingResult:MCPStreamingFast]; } /** @@ -1307,7 +1308,7 @@ void performThreadedKeepAlive(void *ptr) */ - (MCPStreamingResult *)streamingQueryString:(NSString *)query useLowMemoryBlockingStreaming:(BOOL)fullStream { - return [self queryString:query usingEncoding:mEncoding streamingResult:(fullStream?MCP_LOWMEM_STREAMING:MCP_FAST_STREAMING)]; + return [self queryString:query usingEncoding:mEncoding streamingResult:(fullStream?MCPStreamingLowMem:MCPStreamingFast)]; } /** @@ -1413,7 +1414,7 @@ void performThreadedKeepAlive(void *ptr) // Lock the connection - on this thread for normal result sets (avoiding blocking issues // when the app is in modal mode), or ensuring a lock on the main thread for streaming queries. - if (streamResultType == MCP_NO_STREAMING) [queryLock lock]; + if (streamResultType == MCPStreamingNone) [queryLock lock]; else [self lockConnection]; // Run (or re-run) the query, timing the execution time of the query - note @@ -1431,14 +1432,14 @@ void performThreadedKeepAlive(void *ptr) if (mysql_field_count(mConnection) != 0) { // For normal result sets, fetch the results and unlock the connection - if (streamResultType == MCP_NO_STREAMING) { + if (streamResultType == MCPStreamingNone) { theResult = [[MCPResult alloc] initWithMySQLPtr:mConnection encoding:mEncoding timeZone:mTimeZone]; if (!queryCancelled || !queryCancelUsedReconnect) [queryLock unlock]; // For streaming result sets, fetch the result pointer and leave the connection locked - } else if (streamResultType == MCP_FAST_STREAMING) { + } else if (streamResultType == MCPStreamingFast) { theResult = [[MCPStreamingResult alloc] initWithMySQLPtr:mConnection encoding:mEncoding timeZone:mTimeZone connection:self withFullStreaming:NO]; - } else if (streamResultType == MCP_LOWMEM_STREAMING) { + } else if (streamResultType == MCPStreamingLowMem) { theResult = [[MCPStreamingResult alloc] initWithMySQLPtr:mConnection encoding:mEncoding timeZone:mTimeZone connection:self withFullStreaming:YES]; } @@ -1449,20 +1450,20 @@ void performThreadedKeepAlive(void *ptr) break; } } else { - if (streamResultType == MCP_NO_STREAMING) [queryLock unlock]; + if (streamResultType == MCPStreamingNone) [queryLock unlock]; else [self unlockConnection]; } queryErrorMessage = [[NSString alloc] initWithString:@""]; queryErrorId = 0; - if (streamResultType == MCP_NO_STREAMING && queryAffectedRows == -1) { + if (streamResultType == MCPStreamingNone && queryAffectedRows == -1) { queryAffectedRows = mysql_affected_rows(mConnection); } // On failure, set the error messages and IDs } else { if (!queryCancelled || !queryCancelUsedReconnect) { - if (streamResultType == MCP_NO_STREAMING) [queryLock unlock]; + if (streamResultType == MCPStreamingNone) [queryLock unlock]; else [self unlockConnection]; } @@ -1486,7 +1487,7 @@ void performThreadedKeepAlive(void *ptr) break; } - if (streamResultType == MCP_NO_STREAMING) { + if (streamResultType == MCPStreamingNone) { // If the mysql thread id has changed as a result of a connection error, // ensure connection details are still correct @@ -1499,8 +1500,13 @@ void performThreadedKeepAlive(void *ptr) // Update error strings and IDs lastQueryErrorId = queryErrorId; - [self setLastErrorMessage:queryErrorMessage?queryErrorMessage:@""]; - if (queryErrorMessage) [queryErrorMessage release]; + + if (queryErrorMessage) { + [self setLastErrorMessage:queryErrorMessage]; + + [queryErrorMessage release]; + } + lastQueryAffectedRows = queryAffectedRows; lastQueryExecutionTime = queryExecutionTime; |