From 8d055c6df1d1590f97bd9e7c4834c05c706f27b7 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Thu, 25 Mar 2010 15:24:56 +0000 Subject: =?UTF-8?q?=E2=80=A2=20Navigator=20-=20first=20implementation=20of?= =?UTF-8?q?=20a=20search=20functionality,=20workable=20but=20tiny=20issues?= =?UTF-8?q?=20have=20to=20be=20improved=20-=20up=20to=20now=20the=20only?= =?UTF-8?q?=20search=20implemented=20is=20'contains',=20regexp/fuzzy=20sea?= =?UTF-8?q?rch=20will=20come=20soon=20-=20the=20search=20is=20only=20perfo?= =?UTF-8?q?rmed=20in=20the=20main=20outline=20view,=20the=20upper=20one=20?= =?UTF-8?q?is=20static=20-=20for=20the=20new=20search=20store=20all=20avai?= =?UTF-8?q?lable=20schema=20paths=20uniquely=20in=20an=20array=20which=20w?= =?UTF-8?q?ill=20be=20set=20during=20queryDbStructure=20(this=20avoids=20r?= =?UTF-8?q?e-parsing=20of=20a=20dict=20structure)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h | 2 ++ Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'Frameworks/MCPKit') 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]; -- cgit v1.2.3