From 8a7621ee68c7de9a08bbd1552c6006e4fa3aaaa9 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 19 Mar 2010 16:21:10 +0000 Subject: =?UTF-8?q?=E2=80=A2=20further=20work=20on=20Navigator=20(not=20ye?= =?UTF-8?q?t=20active=20but=20workable=20->=20unHide=20menu=20item)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 34 +++++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m') diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index 3223964c..6dac15b3 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -1849,7 +1849,7 @@ void performThreadedKeepAlive(void *ptr) } /** - * Updates the dict containing the structure of all available databases (mainly for completion) + * Updates the dict containing the structure of all available databases (mainly for completion/navigator) * executed on a new connection. */ - (void)queryDbStructure @@ -1888,7 +1888,7 @@ void performThreadedKeepAlive(void *ptr) } else { thePass = [self cStringFromString:connectionPassword]; } - + // Connect connectionSetupStatus = mysql_real_connect(structConnection, theHost, theLogin, thePass, NULL, connectionPort, theSocket, mConnectionFlags); thePass = NULL; @@ -1931,10 +1931,23 @@ void performThreadedKeepAlive(void *ptr) NSMutableArray *allDbNames = [NSMutableArray array]; NSMutableArray *allTableNames = [NSMutableArray array]; + NSString *connectionID; + if([delegate respondsToSelector:@selector(connectionID)]) + connectionID = [NSString stringWithString:[[self delegate] connectionID]]; + else + connectionID = @"_"; + + NSString *SPUniqueSchemaDelimiter = @"￸"; + + [structure setObject:[NSMutableDictionary dictionary] forKey:connectionID]; + while(row = mysql_fetch_row(theResult)) { NSString *db = [self stringWithUTF8CString:row[0]]; + NSString *db_id = [NSString stringWithFormat:@"%@%@%@", connectionID, SPUniqueSchemaDelimiter, db]; NSString *table = [self stringWithUTF8CString:row[1]]; + NSString *table_id = [NSString stringWithFormat:@"%@%@%@", db_id, SPUniqueSchemaDelimiter, table]; NSString *field = [self stringWithUTF8CString:row[2]]; + NSString *field_id = [NSString stringWithFormat:@"%@%@%@", table_id, SPUniqueSchemaDelimiter, field]; NSString *type = [self stringWithUTF8CString:row[3]]; NSString *charset = (row[4]) ? [self stringWithUTF8CString:row[4]] : @""; NSString *structtype = [self stringWithUTF8CString:row[5]]; @@ -1947,19 +1960,20 @@ void performThreadedKeepAlive(void *ptr) [allDbNames addObject:[db lowercaseString]]; [allTableNames addObject:[table lowercaseString]]; - if(![structure valueForKey:db]) { - [structure setObject:[NSMutableDictionary dictionary] forKey:db]; + if(![[structure valueForKey:connectionID] valueForKey:db_id]) { + [[structure valueForKey:connectionID] setObject:[NSMutableDictionary dictionary] forKey:db_id]; } - if(![[structure valueForKey:db] valueForKey:table]) { - [[structure valueForKey:db] setObject:[NSMutableDictionary dictionary] forKey:table]; + if(![[[structure valueForKey:connectionID] valueForKey:db_id] valueForKey:table_id]) { + [[[structure valueForKey:connectionID] valueForKey:db_id] setObject:[NSMutableDictionary dictionary] forKey:table_id]; } - [[[structure valueForKey:db] valueForKey:table] setObject:[NSArray arrayWithObjects:type, charset, key, extra, priv, nil] forKey:field]; - [[[structure valueForKey:db] valueForKey:table] setObject:structtype forKey:@" struct_type "]; + [[[[structure valueForKey:connectionID] valueForKey:db_id] valueForKey:table_id] setObject:[NSArray arrayWithObjects:type, charset, key, extra, priv, nil] forKey:field_id]; + [[[[structure valueForKey:connectionID] valueForKey:db_id] valueForKey:table_id] setObject:structtype forKey:@" struct_type "]; } + mysql_free_result(theResult); mysql_close(structConnection); @@ -1987,6 +2001,10 @@ void performThreadedKeepAlive(void *ptr) } uniqueDbIdentifier = [[NSDictionary dictionaryWithDictionary:uniqueIdentifier] retain]; + + if(delegate && [delegate respondsToSelector:@selector(updateNavigator:)]) + [[self delegate] updateNavigator:self]; + isQueryingDbStructure = NO; [queryPool release]; return; -- cgit v1.2.3