From a395fa908f4ce95355e7e6aaf1d31a75ee3e31f5 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 18 Jun 2012 23:39:43 +0000 Subject: Improvements to the New Table sheet: - Make the default sheet width wider - Change "Default" encoding to "Inherit from database" to clarify the action of the menu item - Fix retrieval of default table type on recent MySQL versions - Fix retain of default server table type This should address Issue #1377. --- Source/SPDatabaseData.m | 21 ++++++++++++++++----- Source/SPTablesList.m | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'Source') diff --git a/Source/SPDatabaseData.m b/Source/SPDatabaseData.m index 4c99b97e..88f07e52 100644 --- a/Source/SPDatabaseData.m +++ b/Source/SPDatabaseData.m @@ -315,13 +315,24 @@ NSInteger _sortStorageEngineEntry(NSDictionary *itemOne, NSDictionary *itemTwo, if (!defaultStorageEngine) { [defaultStorageEngine release]; - - // Use 'table_type' variable rather than 'storage_engine' as it's been available since MySQL 3.23.0 - SPMySQLResult *result = [connection queryString:@"SHOW VARIABLES LIKE 'table_type'"]; - + + // Determine which variable to use based on server version. 'table_type' has been available since MySQL 3.23.0. + NSString *storageEngineKey = @"table_type"; + + // Post 5.5, storage_engine was deprecated; use default_storage_engine + if ([serverSupport isEqualToOrGreaterThanMajorVersion:5 minor:5 release:0]) { + storageEngineKey = @"default_storage_engine"; + + // For the rest of 5.x, use storage_engine + } else if ([serverSupport isEqualToOrGreaterThanMajorVersion:5 minor:0 release:0]) { + storageEngineKey = @"storage_engine"; + } + + // Retrieve the corresponding value for the determined key, ensuring return as a string + SPMySQLResult *result = [connection queryString:[NSString stringWithFormat:@"SHOW VARIABLES LIKE %@", [storageEngineKey tickQuotedString]]];; [result setReturnDataAsStrings:YES]; - defaultStorageEngine = [[result getRowAsDictionary] objectForKey:@"Value"]; + defaultStorageEngine = [[[result getRowAsDictionary] objectForKey:@"Value"] retain]; } return defaultStorageEngine; diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index cfb367e9..441fdeab 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -398,7 +398,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; // Populate the table encoding popup button with a default menu item [tableEncodingButton removeAllItems]; - [tableEncodingButton addItemWithTitle:[NSString stringWithFormat:NSLocalizedString(@"Default (%@)", @"New Table Sheet : Table Encoding Dropdown : Default"), [tableDocumentInstance databaseEncoding]]]; + [tableEncodingButton addItemWithTitle:[NSString stringWithFormat:NSLocalizedString(@"Inherit from database (%@)", @"New Table Sheet : Table Encoding Dropdown : Default inherited from database"), [tableDocumentInstance databaseEncoding]]]; // Retrieve the server-supported encodings and add them to the menu NSArray *encodings = [databaseDataInstance getDatabaseCharacterSetEncodings]; -- cgit v1.2.3