aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h1
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m21
-rw-r--r--Source/TablesList.m7
3 files changed, 28 insertions, 1 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
index 4d972c31..dd8a172e 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
@@ -179,6 +179,7 @@
BOOL delegateResponseToWillQueryString;
BOOL delegateSupportsConnectionLostDecisions;
NSInteger isQueryingDbStructure;
+ BOOL cancelQueryingDbStructure;
BOOL lockQuerying;
// Pointers
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
index 6d9ef181..003595c7 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
@@ -1872,9 +1872,15 @@ void performThreadedKeepAlive(void *ptr)
{
NSAutoreleasePool *queryPool = [[NSAutoreleasePool alloc] init];
+ // if 'cancelQuerying' is set try to interrupt any current querying
+ if(userInfo && [userInfo objectForKey:@"cancelQuerying"])
+ cancelQueryingDbStructure = YES;
+
// Requests are queued
while(isQueryingDbStructure > 0) { usleep(1000000); }
+ cancelQueryingDbStructure = NO;
+
[[NSNotificationCenter defaultCenter] postNotificationName:@"SPDBStructureIsUpdating" object:delegate];
NSString *SPUniqueSchemaDelimiter = @"￸";
@@ -2085,6 +2091,11 @@ void performThreadedKeepAlive(void *ptr)
// Query all tables
for(NSString* table in tables) {
+ if(cancelQueryingDbStructure) {
+ [self performSelectorOnMainThread:@selector(decrementQueryingDbStructure) withObject:nil waitUntilDone:YES];
+ [queryPool release];
+ return;
+ }
NSString *query = [NSString stringWithFormat:@"SHOW FULL COLUMNS FROM `%@` FROM `%@`",
[table stringByReplacingOccurrencesOfString:@"`" withString:@"``"],
currentDatabaseEscaped];
@@ -2133,6 +2144,11 @@ void performThreadedKeepAlive(void *ptr)
}
// Query all views
for(NSString* table in tableviews) {
+ if(cancelQueryingDbStructure) {
+ [self performSelectorOnMainThread:@selector(decrementQueryingDbStructure) withObject:nil waitUntilDone:YES];
+ [queryPool release];
+ return;
+ }
NSString *query = [NSString stringWithFormat:@"SHOW FULL COLUMNS FROM `%@` FROM `%@`",
[table stringByReplacingOccurrencesOfString:@"`" withString:@"``"],
currentDatabaseEscaped];
@@ -2197,6 +2213,11 @@ void performThreadedKeepAlive(void *ptr)
theResult = mysql_use_result(structConnection);
NSUInteger numberOfFields = mysql_num_fields(theResult);
while(row = mysql_fetch_row(theResult)) {
+ if(cancelQueryingDbStructure) {
+ [self performSelectorOnMainThread:@selector(decrementQueryingDbStructure) withObject:nil waitUntilDone:YES];
+ [queryPool release];
+ return;
+ }
NSString *field = [self stringWithUTF8CString:row[0]];
NSString *table_id = [NSString stringWithFormat:@"%@%@%@", db_id, SPUniqueSchemaDelimiter, field];
NSString *field_id = [NSString stringWithFormat:@"%@%@%@", table_id, SPUniqueSchemaDelimiter, field];
diff --git a/Source/TablesList.m b/Source/TablesList.m
index 1644c13d..bced6366 100644
--- a/Source/TablesList.m
+++ b/Source/TablesList.m
@@ -252,7 +252,12 @@
if (previousSelectedTable) [previousSelectedTable release];
// Query the structure of all databases in the background
- [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:nil];
+ if(sender == self)
+ // Invoked by SP
+ [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:nil];
+ else
+ // User press refresh button ergo force update
+ [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", [NSNumber numberWithBool:YES], @"cancelQuerying", nil]];
}