diff options
author | stuconnolly <stuart02@gmail.com> | 2012-04-16 20:16:52 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2012-04-16 20:16:52 +0000 |
commit | 4cad6f0e6e4fb497b480256c2abe3de34ebf225c (patch) | |
tree | b66d6a72a1537cf98624acf3c685f1a4d916fd86 /Frameworks/SPMySQLFramework/Source | |
parent | 0d3b69f964a8d9d93ca794d457b461463f1ec95d (diff) | |
download | sequelpro-4cad6f0e6e4fb497b480256c2abe3de34ebf225c.tar.gz sequelpro-4cad6f0e6e4fb497b480256c2abe3de34ebf225c.tar.bz2 sequelpro-4cad6f0e6e4fb497b480256c2abe3de34ebf225c.zip |
Bring outline view branch up to date with trunk.
Diffstat (limited to 'Frameworks/SPMySQLFramework/Source')
11 files changed, 69 insertions, 13 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQL.h b/Frameworks/SPMySQLFramework/Source/SPMySQL.h index 3c4c78f8..bfdacf3e 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQL.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQL.h @@ -37,7 +37,11 @@ #import "SPMySQLConstants.h" // Required category additions +#ifndef SP_REFACTOR #import "SPMySQLStringAdditions.h" +#else +#import <SPMySQL/SPMySQL.h> +#endif // MySQL Connection Delegate and Proxy protocols #import "SPMySQLConnectionDelegate.h" diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Databases & Tables.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Databases & Tables.m index a95e060e..2065c998 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Databases & Tables.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Databases & Tables.m @@ -32,6 +32,7 @@ #import "Databases & Tables.h" #import "SPMySQL Private APIs.h" +#import "SPMySQLStringAdditions.h" @implementation SPMySQLConnection (Databases_and_Tables) diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.h index cf132fcf..9fa930c5 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.h @@ -33,4 +33,12 @@ @interface SPMySQLConnection (Delegate_and_Proxy) +// Connection delegage +- (void)setDelegate:(NSObject <SPMySQLConnectionDelegate> *)aDelegate; +- (NSObject <SPMySQLConnectionDelegate> *)delegate; + +// Connection proxy +- (void)setProxy:(NSObject <SPMySQLConnectionProxy> *)aProxy; +- (NSObject <SPMySQLConnectionProxy> *)proxy; + @end diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.m index 3ac013cc..59e78c35 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.m @@ -39,8 +39,8 @@ #pragma mark Connection delegate /** - * Override the synthesized delegate setter, to allow optimisations to oft-made - * checks by precacheing availability. + * Set the delegate of the connection object, precaching availability of + * oft-called methods to allow optimisation. */ - (void)setDelegate:(NSObject <SPMySQLConnectionDelegate> *)aDelegate { @@ -51,12 +51,22 @@ delegateSupportsConnectionLost = [delegate respondsToSelector:@selector(connectionLost:)]; } +/** + * Return the current instance delegate. + */ +- (NSObject <SPMySQLConnectionDelegate> *)delegate +{ + return delegate; +} + #pragma mark - #pragma mark Connection proxy /** - * Override the synthesized proxy setter, to record the initial state and to - * set the state change selector. + * Set the connection proxy, used by the class to set up a connection pre-requisite, and + * monitored for state changes. This allows the MySQL connection to be routed over + * another helper class providing a port or socket. This method also records the initial + * state and sets the state change selector. */ - (void)setProxy:(NSObject <SPMySQLConnectionProxy> *)aProxy { @@ -64,7 +74,15 @@ previousProxyState = [aProxy state]; [proxy setConnectionStateChangeSelector:@selector(_proxyStateChange:) delegate:self]; -} +} + +/** + * Return the current instance proxy. + */ +- (NSObject <SPMySQLConnectionProxy> *)proxy +{ + return proxy; +} @end diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Encoding.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Encoding.m index 8f684f29..d11c75b2 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Encoding.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Encoding.m @@ -32,6 +32,7 @@ #import "Encoding.h" +#import "SPMySQLStringAdditions.h" @implementation SPMySQLConnection (Encoding) diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m index 9b54029c..5df71e96 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m @@ -330,10 +330,22 @@ NSString *theErrorMessage = [self _stringForCString:mysql_error(mySQLConnection)]; NSUInteger theErrorID = mysql_errno(mySQLConnection); + // Update the connection's stored insert ID if available + if (mySQLConnection->insert_id) { + lastQueryInsertID = mySQLConnection->insert_id; + } + // If the query was cancelled, override the error state if (lastQueryWasCancelled) { theErrorMessage = NSLocalizedString(@"Query cancelled.", @"Query cancelled error"); theErrorID = 1317; + + // If the query was cancelled on a MySQL <5 server, check the connection to allow reconnects + // after query kills. This is also handled within the class for internal cancellations, but + // as other external classes may also cancel the query. + if (![self serverVersionIsGreaterThanOrEqualTo:5 minorVersion:0 releaseVersion:0]) { + [self checkConnection]; + } } // Unlock the connection if appropriate - if not a streaming result type. diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h index 8f3b7f9f..8ed01ec6 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h @@ -131,9 +131,6 @@ #pragma mark - #pragma mark Synthesized properties -@property (readwrite, assign, nonatomic) NSObject <SPMySQLConnectionDelegate> *delegate; -@property (readwrite, assign, nonatomic) NSObject <SPMySQLConnectionProxy> *proxy; - @property (readwrite, retain) NSString *host; @property (readwrite, retain) NSString *username; @property (readwrite, retain) NSString *password; diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m index 6308a3f5..800157ca 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m @@ -54,8 +54,6 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS #pragma mark - #pragma mark Synthesized properties -@synthesize delegate; -@synthesize proxy; @synthesize host; @synthesize username; @synthesize password; @@ -124,6 +122,7 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS previousEncodingUsesLatin1Transport = NO; // Initialise default delegate settings + delegate = nil; delegateSupportsWillQueryString = NO; delegateSupportsConnectionLost = NO; delegateQueryLogging = YES; @@ -435,10 +434,15 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS isReconnecting = NO; [reconnectionPool release]; return NO; + + // By default attempt a reconnect, returning if it fails. If it succeeds, continue + // on to the end of the function to restore details if appropriate. default: isReconnecting = NO; - [reconnectionPool release]; - return [self reconnect]; + if (![self reconnect]) { + [reconnectionPool release]; + return NO; + } } } diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m b/Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m index 8ba55134..1fa4b829 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m @@ -398,6 +398,11 @@ typedef struct st_spmysqlstreamingrowdata { [parentConnection _unlockConnection]; connectionUnlocked = YES; + // If the connection query may have been cancelled with a query kill, double-check connection + if ([parentConnection lastQueryWasCancelled] && [parentConnection serverMajorVersion] < 5) { + [parentConnection checkConnection]; + } + dataDownloaded = YES; [downloadPool drain]; } diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Convenience Methods.m b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Convenience Methods.m index 2b049264..4d18db18 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Convenience Methods.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Convenience Methods.m @@ -65,7 +65,7 @@ // Instead of empty arrays, return nil if there are no rows. if (![rowsToReturn count]) return nil; - return rowsToReturn; + return [rowsToReturn autorelease]; } @end diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResult.m b/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResult.m index b19e5356..51a17611 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResult.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResult.m @@ -170,6 +170,12 @@ dataDownloaded = YES; [parentConnection _unlockConnection]; connectionUnlocked = YES; + + // If the connection query may have been cancelled with a query kill, double-check connection + if ([parentConnection lastQueryWasCancelled] && [parentConnection serverMajorVersion] < 5) { + [parentConnection checkConnection]; + } + return nil; } |