aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit
diff options
context:
space:
mode:
Diffstat (limited to 'Frameworks/MCPKit')
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h1
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m21
2 files changed, 22 insertions, 0 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];