aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2009-07-20 18:22:36 +0000
committerstuconnolly <stuart02@gmail.com>2009-07-20 18:22:36 +0000
commit82490a9e850ff0eb94a7a159106ca50cb34cdfa7 (patch)
tree6392542269e2cb4a8dc94a444eb07ed9085a2e1a /Source
parenta3c74feedbdd46f3c5c0bd5c7091931e930ff6b9 (diff)
downloadsequelpro-82490a9e850ff0eb94a7a159106ca50cb34cdfa7.tar.gz
sequelpro-82490a9e850ff0eb94a7a159106ca50cb34cdfa7.tar.bz2
sequelpro-82490a9e850ff0eb94a7a159106ca50cb34cdfa7.zip
Remove the dependency on information_schema for table encodings.
Diffstat (limited to 'Source')
-rw-r--r--Source/SPDatabaseData.m20
-rw-r--r--Source/SPExtendedTableInfo.m8
2 files changed, 23 insertions, 5 deletions
diff --git a/Source/SPDatabaseData.m b/Source/SPDatabaseData.m
index b8d8b394..a9c86ccc 100644
--- a/Source/SPDatabaseData.m
+++ b/Source/SPDatabaseData.m
@@ -386,7 +386,25 @@ const CHAR_SETS charsets[] =
- (NSArray *)getDatabaseCharacterSetEncodings
{
if ([characterSetEncodings count] == 0) {
- [characterSetEncodings addObjectsFromArray:[self _getDatabaseDataForQuery:@"SELECT * FROM information_schema.character_sets ORDER BY character_set_name ASC"]];
+
+ // Check the information_schema.collations table is accessible
+ CMMCPResult *result = [connection queryString:@"SHOW TABLES IN information_schema LIKE 'character_sets'"];
+
+ if ([result numOfRows] == 1) {
+ // Table is accessible so get available encodings for the supplied encoding
+ [characterSetEncodings addObjectsFromArray:[self _getDatabaseDataForQuery:@"SELECT * FROM information_schema.character_sets ORDER BY character_set_name ASC"]];
+ }
+ else {
+ // Get the list of collations matching the supplied encoding from our hard coded list
+ const CHAR_SETS *c = charsets;
+
+ do {
+ [characterSetEncodings addObject:[NSDictionary dictionaryWithObject:[NSString stringWithCString:c->name encoding:NSUTF8StringEncoding] forKey:@"CHARACTER_SET_NAME"]];
+
+ ++c;
+ }
+ while (c[0].nr != 0);
+ }
}
return characterSetEncodings;
diff --git a/Source/SPExtendedTableInfo.m b/Source/SPExtendedTableInfo.m
index 04070e93..0485281a 100644
--- a/Source/SPExtendedTableInfo.m
+++ b/Source/SPExtendedTableInfo.m
@@ -237,14 +237,14 @@
[tableTypePopUpButton addItemWithTitle:@"Not available"];
}
- if ([encodings count] > 0) {
+ if (([encodings count] > 0) && ([tableDataInstance tableEncoding])) {
NSString *selectedTitle = @"";
// Populate encoding popup button
for (NSDictionary *encoding in encodings)
- {
- NSString *menuItemTitle = [NSString stringWithFormat:@"%@ (%@)", [encoding objectForKey:@"DESCRIPTION"], [encoding objectForKey:@"CHARACTER_SET_NAME"]];
-
+ {
+ NSString *menuItemTitle = (![encoding objectForKey:@"DESCRIPTION"]) ? [encoding objectForKey:@"CHARACTER_SET_NAME"] : [NSString stringWithFormat:@"%@ (%@)", [encoding objectForKey:@"DESCRIPTION"], [encoding objectForKey:@"CHARACTER_SET_NAME"]];
+
[tableEncodingPopUpButton addItemWithTitle:menuItemTitle];
if ([[tableDataInstance tableEncoding] isEqualToString:[encoding objectForKey:@"CHARACTER_SET_NAME"]]) {