diff options
Diffstat (limited to 'Frameworks/MCPKit')
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h | 2 | ||||
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 22 |
2 files changed, 24 insertions, 0 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h index 5fa3fe86..af38e99c 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h @@ -109,6 +109,7 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, NSInteger e NSString *serverVersionString; NSDictionary *theDbStructure; NSDictionary *uniqueDbIdentifier; + NSArray *allKeysofDbStructure; NSTimer *keepAliveTimer; pthread_t keepAliveThread; @@ -238,6 +239,7 @@ void performThreadedKeepAlive(void *ptr); - (void)queryDbStructure; - (NSDictionary *)getDbStructure; - (NSInteger)getUniqueDbIdentifierFor:(NSString*)term; +- (NSArray *)getAllKeysOfDbStructure; // Server information - (NSString *)clientInfo; diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index 0685d162..82772461 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -114,6 +114,7 @@ static BOOL sTruncateLongFieldInLogs = YES; keepAliveInterval = 60; theDbStructure = nil; + allKeysofDbStructure = nil; uniqueDbIdentifier = nil; isQueryingDbStructure = NO; @@ -428,6 +429,7 @@ static BOOL sTruncateLongFieldInLogs = YES; if (serverVersionString) [serverVersionString release], serverVersionString = nil; if (theDbStructure) [theDbStructure release], theDbStructure = nil; + if (allKeysofDbStructure) [allKeysofDbStructure release], allKeysofDbStructure = nil; if (uniqueDbIdentifier) [uniqueDbIdentifier release], uniqueDbIdentifier = nil; if (pingThread != NULL) pthread_cancel(pingThread), pingThread = NULL; } @@ -1952,6 +1954,7 @@ void performThreadedKeepAlive(void *ptr) if (mysql_real_query(structConnection, queryCString, queryCStringLength) == 0) { theResult = mysql_use_result(structConnection); NSMutableDictionary *structure = [NSMutableDictionary dictionary]; + NSMutableSet *allKeys = [[NSMutableSet alloc] initWithCapacity:20]; NSMutableSet *namesSet = [[NSMutableSet alloc] initWithCapacity:20]; NSMutableArray *allDbNames = [NSMutableArray array]; NSMutableArray *allTableNames = [NSMutableArray array]; @@ -1991,6 +1994,9 @@ void performThreadedKeepAlive(void *ptr) [namesSet addObject:[table lowercaseString]]; [allDbNames addObject:[db lowercaseString]]; [allTableNames addObject:[table lowercaseString]]; + [allKeys addObject:db_id]; + [allKeys addObject:table_id]; + [allKeys addObject:field_id]; if(![[structure valueForKey:connectionID] valueForKey:db_id]) { [[structure valueForKey:connectionID] setObject:[NSMutableDictionary dictionary] forKey:db_id]; @@ -2015,6 +2021,13 @@ void performThreadedKeepAlive(void *ptr) } theDbStructure = [[NSDictionary dictionaryWithDictionary:structure] retain]; + if(allKeysofDbStructure != nil) { + [allKeysofDbStructure release]; + allKeysofDbStructure = nil; + } + allKeysofDbStructure = [[NSArray arrayWithArray:[allKeys allObjects]] retain]; + [allKeys release]; + NSMutableDictionary *uniqueIdentifier = [NSMutableDictionary dictionary]; for(id name in namesSet) { if([allDbNames containsObject:name] && [allTableNames containsObject:name]) { @@ -2071,6 +2084,14 @@ void performThreadedKeepAlive(void *ptr) return theDbStructure; } +/** + * Returns all keys of the db structure. + */ +- (NSArray *)getAllKeysOfDbStructure +{ + return allKeysofDbStructure; +} + #pragma mark - #pragma mark Server information @@ -2492,6 +2513,7 @@ void performThreadedKeepAlive(void *ptr) if (connectionPassword) [connectionPassword release]; if (serverVersionString) [serverVersionString release], serverVersionString = nil; if (theDbStructure) [theDbStructure release], theDbStructure = nil; + if (allKeysofDbStructure) [allKeysofDbStructure release], allKeysofDbStructure = nil; if (uniqueDbIdentifier) [uniqueDbIdentifier release], uniqueDbIdentifier = nil; [super dealloc]; |