aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-03-26 19:23:18 +0000
committerBibiko <bibiko@eva.mpg.de>2010-03-26 19:23:18 +0000
commitf5edb22564ec1c3e834f20fd080a84ce581acfe4 (patch)
treeaf955d775594cd3713772c2d343111f270f94b91
parent1c3c288b8cc26d8de7119e3fff9b1ad60c9ee63a (diff)
downloadsequelpro-f5edb22564ec1c3e834f20fd080a84ce581acfe4.tar.gz
sequelpro-f5edb22564ec1c3e834f20fd080a84ce581acfe4.tar.bz2
sequelpro-f5edb22564ec1c3e834f20fd080a84ce581acfe4.zip
• navigator
- fixed issue if different connection windows are connected to the same connection - prepared structure querying method to be able to add user info containing which table/db was changed if we know it to reduce the future parsing cost
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h2
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m11
-rw-r--r--Source/SPNavigatorController.m2
-rw-r--r--Source/TableDocument.m9
-rw-r--r--Source/TableSource.m4
-rw-r--r--Source/TablesList.m10
6 files changed, 18 insertions, 20 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
index 352f152b..c105691f 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
@@ -266,7 +266,7 @@ void performThreadedKeepAlive(void *ptr);
- (MCPResult *)listTablesFromDB:(NSString *)dbName like:(NSString *)tablesName;
- (MCPResult *)listFieldsFromTable:(NSString *)tableName;
- (MCPResult *)listFieldsFromTable:(NSString *)tableName like:(NSString *)fieldsName;
-- (void)queryDbStructureAndForceUpdate:(NSNumber*)forceUpdate;
+- (void)queryDbStructureWithUserInfo:(NSDictionary*)userInfo;
- (NSDictionary *)getDbStructure;
- (NSInteger)getUniqueDbIdentifierFor:(NSString*)term;
- (NSArray *)getAllKeysOfDbStructure;
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
index e2a2930f..7b6fa0b8 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
@@ -1834,7 +1834,7 @@ void performThreadedKeepAlive(void *ptr)
* Updates the dict containing the structure of all available databases (mainly for completion/navigator)
* executed on a new connection.
*/
-- (void)queryDbStructureAndForceUpdate:(NSNumber*)forceUpdate
+- (void)queryDbStructureWithUserInfo:(NSDictionary*)userInfo
{
NSAutoreleasePool *queryPool = [[NSAutoreleasePool alloc] init];
@@ -1842,6 +1842,8 @@ void performThreadedKeepAlive(void *ptr)
NSString *SPUniqueSchemaDelimiter = @"￸";
+
+
NSString *connectionID;
if([delegate respondsToSelector:@selector(connectionID)])
connectionID = [NSString stringWithString:[[self delegate] connectionID]];
@@ -1858,9 +1860,8 @@ void performThreadedKeepAlive(void *ptr)
[[[self delegate] allDatabaseNames] componentsJoinedByString:SPUniqueSchemaDelimiter]]
componentsSeparatedByString:SPUniqueSchemaDelimiter];
for(id db in dbs) {
- NSString *db_id = [NSString stringWithFormat:@"%@%@%@", connectionID, SPUniqueSchemaDelimiter, db];
- if(![[structure valueForKey:connectionID] valueForKey:db_id]) {
- [[structure valueForKey:connectionID] setObject:db forKey:db_id];
+ if(![[self delegate] navigatorSchemaPathExistsForDatabase:db]) {
+ [[structure valueForKey:connectionID] setObject:db forKey:[NSString stringWithFormat:@"%@%@%@", connectionID, SPUniqueSchemaDelimiter, db]];
}
}
@@ -1907,7 +1908,7 @@ void performThreadedKeepAlive(void *ptr)
}
}
- if(forceUpdate == nil) {
+ if(userInfo == nil || ![userInfo objectForKey:@"forceUpdate"]) {
if([[self delegate] navigatorSchemaPathExistsForDatabase:currentDatabase]) {
if(removeFlag)
[[NSNotificationCenter defaultCenter] postNotificationName:@"SPDBStructureWasUpdated" object:delegate];
diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m
index d8772b17..c5c6463d 100644
--- a/Source/SPNavigatorController.m
+++ b/Source/SPNavigatorController.m
@@ -492,7 +492,7 @@ static SPNavigatorController *sharedNavigatorController = nil;
if ([[[NSDocumentController sharedDocumentController] documents] count]) {
for(id doc in [[NSDocumentController sharedDocumentController] documents]) {
if(![[doc valueForKeyPath:@"mySQLConnection"] isConnected]) continue;
- [NSThread detachNewThreadSelector:@selector(queryDbStructureAndForceUpdate:) toTarget:[doc valueForKeyPath:@"mySQLConnection"] withObject:[NSNumber numberWithBool:YES]];
+ [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:[doc valueForKeyPath:@"mySQLConnection"] withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
}
}
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index 8663cc21..7725ee1c 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -688,9 +688,6 @@
window:tableWindow
notificationName:@"Connected"];
- // // Query the structure of all databases in the background (mainly for completion)
- // [NSThread detachNewThreadSelector:@selector(queryDbStructureAndForceUpdate:) toTarget:mySQLConnection withObject:nil];
-
// Init Custom Query editor with the stored queries in a spf file if given.
[spfDocData setObject:[NSNumber numberWithBool:NO] forKey:@"save_editor_content"];
if(spfSession != nil && [spfSession objectForKey:@"queries"]) {
@@ -1025,7 +1022,7 @@
[self _addDatabase];
// Query the structure of all databases in the background (mainly for completion)
- [NSThread detachNewThreadSelector:@selector(queryDbStructureAndForceUpdate:) toTarget:mySQLConnection withObject:[NSNumber numberWithBool:YES]];
+ [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
} else {
// reset chooseDatabaseButton
@@ -4104,7 +4101,7 @@
[allDatabases removeObject:[self database]];
// This only deletes the db and refreshes the navigator since nothing is changed
// that's why we can run this on main thread
- [mySQLConnection queryDbStructureAndForceUpdate:nil];
+ [mySQLConnection queryDbStructureWithUserInfo:nil];
// Delete was successful
if (selectedDatabase) [selectedDatabase release], selectedDatabase = nil;
@@ -4196,7 +4193,7 @@
}
// Query the structure of all databases in the background (mainly for completion)
- [NSThread detachNewThreadSelector:@selector(queryDbStructureAndForceUpdate:) toTarget:mySQLConnection withObject:nil];
+ [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:nil];
[self endTask];
[taskPool drain];
diff --git a/Source/TableSource.m b/Source/TableSource.m
index e50f7021..8ccc682e 100644
--- a/Source/TableSource.m
+++ b/Source/TableSource.m
@@ -205,7 +205,7 @@
[tablesListInstance setStatusRequiresReload:YES];
// Query the structure of all databases in the background (mainly for completion)
- [NSThread detachNewThreadSelector:@selector(queryDbStructureAndForceUpdate:) toTarget:mySQLConnection withObject:[NSNumber numberWithBool:YES]];
+ [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
[self loadTable:selectedTable];
}
@@ -864,7 +864,7 @@ closes the keySheet
[tablesListInstance setContentRequiresReload:YES];
// Query the structure of all databases in the background (mainly for completion)
- [NSThread detachNewThreadSelector:@selector(queryDbStructureAndForceUpdate:) toTarget:mySQLConnection withObject:[NSNumber numberWithBool:YES]];
+ [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
return YES;
}
diff --git a/Source/TablesList.m b/Source/TablesList.m
index 72448495..f5d479ee 100644
--- a/Source/TablesList.m
+++ b/Source/TablesList.m
@@ -92,7 +92,7 @@
[[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:tableDocumentInstance];
// Query the structure of all databases in the background (mainly for completion)
- [NSThread detachNewThreadSelector:@selector(queryDbStructureAndForceUpdate:) toTarget:mySQLConnection withObject:nil];
+ [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:nil];
// Select the table list for the current database. On MySQL versions after 5 this will include
// views; on MySQL versions >= 5.0.02 select the "full" list to also select the table type column.
@@ -1348,7 +1348,7 @@
[tableWindow setTitle:[tableDocumentInstance displaySPName]];
// Query the structure of all databases in the background (mainly for completion)
- [NSThread detachNewThreadSelector:@selector(queryDbStructureAndForceUpdate:) toTarget:mySQLConnection withObject:[NSNumber numberWithBool:YES]];
+ [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
}
#pragma mark -
@@ -1928,7 +1928,7 @@
[tablesListView deselectAll:self];
// Query the structure of all databases in the background (mainly for completion)
- [NSThread detachNewThreadSelector:@selector(queryDbStructureAndForceUpdate:) toTarget:mySQLConnection withObject:[NSNumber numberWithBool:YES]];
+ [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
}
@@ -2028,7 +2028,7 @@
[self updateSelectionWithTaskString:[NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), selectedTableName]];
// Query the structure of all databases in the background (mainly for completion)
- [NSThread detachNewThreadSelector:@selector(queryDbStructureAndForceUpdate:) toTarget:mySQLConnection withObject:[NSNumber numberWithBool:YES]];
+ [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
}
else {
@@ -2222,7 +2222,7 @@
[self updateSelectionWithTaskString:[NSString stringWithFormat:NSLocalizedString(@"Loading %@...", @"Loading table task string"), selectedTableName]];
// Query the structure of all databases in the background (mainly for completion)
- [NSThread detachNewThreadSelector:@selector(queryDbStructureAndForceUpdate:) toTarget:mySQLConnection withObject:[NSNumber numberWithBool:YES]];
+ [NSThread detachNewThreadSelector:@selector(queryDbStructureWithUserInfo:) toTarget:mySQLConnection withObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"forceUpdate", nil]];
}
}