diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-09-09 15:21:33 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-09-09 15:21:33 +0000 |
commit | da8879c2d94f6f849cec202972e0bb595ff5865f (patch) | |
tree | 15aa0e0d29a5f3a0ead60b0217cf584b36d67627 /Source/SPDatabaseData.m | |
parent | 09f05de9dacce173965aaff204a0254786580ab9 (diff) | |
download | sequelpro-da8879c2d94f6f849cec202972e0bb595ff5865f.tar.gz sequelpro-da8879c2d94f6f849cec202972e0bb595ff5865f.tar.bz2 sequelpro-da8879c2d94f6f849cec202972e0bb595ff5865f.zip |
• [SPDatabase getDatabaseCollationsForEncoding:] now uses a cache to reduce the querying of info_schema
- this fixes the querying of each reloadData in [SPTableStructure objectValueFor:]
• autoreleased mutableCopy in [SPTableStructure loadTable]
• fixed drag&drop query in SPTableStructure to copy charset and collation as well
Diffstat (limited to 'Source/SPDatabaseData.m')
-rw-r--r-- | Source/SPDatabaseData.m | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/Source/SPDatabaseData.m b/Source/SPDatabaseData.m index 27b542c4..bec1264c 100644 --- a/Source/SPDatabaseData.m +++ b/Source/SPDatabaseData.m @@ -207,6 +207,7 @@ const SPDatabaseCharSets charsets[] = characterSetCollations = [[NSMutableArray alloc] init]; storageEngines = [[NSMutableArray alloc] init]; characterSetEncodings = [[NSMutableArray alloc] init]; + cachedCollationsByEncoding = [[NSMutableDictionary alloc] init]; } return self; @@ -278,10 +279,13 @@ const SPDatabaseCharSets charsets[] = [characterSetCollations removeAllObjects]; characterSetEncoding = [[NSString alloc] initWithString:encoding]; - + + if([cachedCollationsByEncoding objectForKey:characterSetEncoding] && [[cachedCollationsByEncoding objectForKey:characterSetEncoding] count]) + return [cachedCollationsByEncoding objectForKey:characterSetEncoding]; + // Try to retrieve the available collations for the supplied encoding from the database if (serverMajorVersion >= 5) - [characterSetCollations addObjectsFromArray:[self _getDatabaseDataForQuery:[NSString stringWithFormat:@"SELECT * FROM `information_schema`.`collations` WHERE character_set_name = '%@' ORDER BY `collation_name` ASC", characterSetEncoding]]]; + [characterSetCollations addObjectsFromArray:[self _getDatabaseDataForQuery:[NSString stringWithFormat:@"SELECT * FROM `information_schema`.`collations` WHERE character_set_name = '%@' ORDER BY `collation_name` ASC", characterSetEncoding]]]; // If that failed, get the list of collations matching the supplied encoding from the hard-coded list if (![characterSetCollations count]) { @@ -289,15 +293,19 @@ const SPDatabaseCharSets charsets[] = do { NSString *charSet = [NSString stringWithCString:c->name encoding:NSUTF8StringEncoding]; - + if ([charSet isEqualToString:characterSetEncoding]) { [characterSetCollations addObject:[NSDictionary dictionaryWithObject:[NSString stringWithCString:c->collation encoding:NSUTF8StringEncoding] forKey:@"COLLATION_NAME"]]; } - + ++c; } while (c[0].nr != 0); - } + } + + if(characterSetCollations && [characterSetCollations count]) + [cachedCollationsByEncoding setObject:[NSArray arrayWithArray:characterSetCollations] forKey:characterSetEncoding]; + } return characterSetCollations; @@ -441,6 +449,7 @@ const SPDatabaseCharSets charsets[] = [characterSetCollations release], characterSetCollations = nil; [storageEngines release], storageEngines = nil; [characterSetEncodings release], characterSetEncodings = nil; + [cachedCollationsByEncoding release], cachedCollationsByEncoding = nil; [super dealloc]; } |