aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2009-07-23 17:54:50 +0000
committerstuconnolly <stuart02@gmail.com>2009-07-23 17:54:50 +0000
commitcdb3bc05f56e2a7a89581f3ed42e5147323c014f (patch)
treead124aadf415b2a78ebce87bc72435e4fb9bab5e /Frameworks/MCPKit
parentaaf452b0385bf4cd37b939a0dfc1375e191380f5 (diff)
downloadsequelpro-cdb3bc05f56e2a7a89581f3ed42e5147323c014f.tar.gz
sequelpro-cdb3bc05f56e2a7a89581f3ed42e5147323c014f.tar.bz2
sequelpro-cdb3bc05f56e2a7a89581f3ed42e5147323c014f.zip
To fix query logging not working, initialize delegateQueryLogging to YES upon connection initialization as well as setting the value based on the user's preferences during initiateMySQLConnection in SPConnectionController. Also, initialize delegateResponseToWillQueryString when the connection's delegate is set and revert back to simply calling the delegate method willQueryString:connection: as opposed to using the selector cache as its currently not working. Might need to look into restoring this if we incur a big performance hit after this revision.
Diffstat (limited to 'Frameworks/MCPKit')
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h5
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m35
2 files changed, 35 insertions, 5 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
index 4a0f7485..87b9ca57 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
@@ -119,7 +119,6 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encodin
SEL timeConnectedSEL;
}
-@property (readwrite, assign) id delegate;
@property (readwrite, assign) BOOL useKeepAlive;
@property (readwrite, assign) BOOL delegateQueryLogging;
@property (readwrite, assign) int connectionTimeout;
@@ -129,6 +128,10 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encodin
- (id)initToHost:(NSString *)host withLogin:(NSString *)login usingPort:(int)port;
- (id)initToSocket:(NSString *)socket withLogin:(NSString *)login;
+// Delegate
+- (id)delegate;
+- (void)setDelegate:(id)connectionDelegate;
+
// Connection details
- (BOOL)setPort:(int)thePort;
- (BOOL)setPassword:(NSString *)thePassword;
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
index e3d26aeb..7429e23a 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
@@ -58,7 +58,6 @@ static BOOL sTruncateLongFieldInLogs = YES;
@implementation MCPConnection
// Synthesize ivars
-@synthesize delegate;
@synthesize useKeepAlive;
@synthesize delegateQueryLogging;
@synthesize connectionTimeout;
@@ -104,7 +103,7 @@ static BOOL sTruncateLongFieldInLogs = YES;
// Initialize ivar defaults
connectionTimeout = 10;
useKeepAlive = YES;
- keepAliveInterval = 60;
+ keepAliveInterval = 60;
connectionThreadId = 0;
maxAllowedPacketSize = -1;
@@ -112,6 +111,9 @@ static BOOL sTruncateLongFieldInLogs = YES;
lastQueryErrorId = 0;
lastQueryErrorMessage = nil;
lastQueryAffectedRows = 0;
+
+ // Enable delegate query logging by default
+ delegateQueryLogging = YES;
// Default to allowing queries to be reattempted if they fail due to connection issues
retryAllowed = YES;
@@ -172,6 +174,29 @@ static BOOL sTruncateLongFieldInLogs = YES;
}
#pragma mark -
+#pragma mark Delegate
+
+/**
+ * Get the connection's current delegate.
+ */
+- (id)delegate
+{
+ return delegate;
+}
+
+/**
+ * Set the connection's delegate to the supplied object.
+ */
+- (void)setDelegate:(id)connectionDelegate
+{
+ delegate = connectionDelegate;
+
+ // Check that the delegate implements willQueryString:connection: and cache the result as its used
+ // vert frequently.
+ delegateResponseToWillQueryString = [delegate respondsToSelector:@selector(willQueryString:connection:)];
+}
+
+#pragma mark -
#pragma mark Connection details
/**
@@ -1244,8 +1269,10 @@ static void forcePingTimeout(int signalNumber)
(void)(*stopKeepAliveTimerPtr)(self, stopKeepAliveTimerSEL);
// Inform the delegate about the query if logging is enabled and delegate responds to willQueryString:connection:
- if (delegateQueryLogging && delegateResponseToWillQueryString)
- (void)(NSString*)(*willQueryStringPtr)(delegate, willQueryStringSEL, query);
+ if (delegateQueryLogging && delegateResponseToWillQueryString) {
+ [delegate willQueryString:query connection:self];
+ }
+
// If thirty seconds have elapsed since the last query, check the connection. This provides
// a balance between keeping high read/write timeouts for long queries, network issues, and