From 965abac73b603c464dc9d58ce4778f239ff6e2b9 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 7 Apr 2010 20:27:08 +0000 Subject: =?UTF-8?q?=E2=80=A2=20improved=20querying=20db=20structure=20hand?= =?UTF-8?q?ling=20-=20distinguish=20between=20any=20update=20tables=20list?= =?UTF-8?q?=20invoked=20by=20SP=20which=20causes=20a=20weak=20and=20quick?= =?UTF-8?q?=20refresh=20if=20nothing=20was=20changed=20and=20if=20the=20us?= =?UTF-8?q?er=20pressed=20Table=20List=20Refresh=20button=20explicitly=20w?= =?UTF-8?q?hich=20will=20cancel=20any=20current=20db=20querying=20and=20pe?= =?UTF-8?q?nding=20ones?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h | 1 + Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'Frameworks') 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]; -- cgit v1.2.3