aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-04-07 20:27:08 +0000
committerBibiko <bibiko@eva.mpg.de>2010-04-07 20:27:08 +0000
commit965abac73b603c464dc9d58ce4778f239ff6e2b9 (patch)
tree4a2370b1895f0784e895ddc7a5ab5e90482637dd /Frameworks/MCPKit
parentc58984f7fb82a089bdc508f0bdf7dc6df89cb979 (diff)
downloadsequelpro-965abac73b603c464dc9d58ce4778f239ff6e2b9.tar.gz
sequelpro-965abac73b603c464dc9d58ce4778f239ff6e2b9.tar.bz2
sequelpro-965abac73b603c464dc9d58ce4778f239ff6e2b9.zip
• improved querying db structure handling
- distinguish between any update tables list invoked by SP which causes a weak and quick refresh if nothing was changed and if the user pressed Table List Refresh button explicitly which will cancel any current db querying and pending ones
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];