From 8ad3b1a34828fd624ceaa4a238fdf84fdf8536cb Mon Sep 17 00:00:00 2001 From: dmoagx Date: Sat, 18 Dec 2010 16:44:46 +0000 Subject: * Recognize "performance_schema" as system DB (added in 5.5) --- Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 3 ++- Source/SPDatabaseDocument.m | 3 ++- Source/SPExtendedTableInfo.m | 11 ++++++----- Source/SPTextView.m | 8 +++++++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index 03cade24..af5e6123 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -2395,7 +2395,8 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) // The cache is available. If the `mysql` or `information_schema` databases are being queried, // never requery as their structure will never change. - if ([currentDatabase isEqualToString:@"mysql"] || [currentDatabase isEqualToString:@"information_schema"]) { + // 5.5.3+ also has performance_schema meta database + if ([currentDatabase isEqualToString:@"mysql"] || [currentDatabase isEqualToString:@"information_schema"] || [currentDatabase isEqualToString:@"performance_schema"]) { shouldQueryStructure = NO; // Otherwise, if the forceUpdate flag wasn't supplied or evaluates to false, also don't update. diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 8557eeba..1e568fec 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -493,7 +493,8 @@ YY_BUFFER_STATE yy_scan_string (const char *); NSString *database = NSArrayObjectAtIndex([queryResult fetchRowAsArray], 0); // If the database is either information_schema or mysql then it is classed as a system table - if ([database isEqualToString:@"information_schema"] || [database isEqualToString:@"mysql"]) { + // 5.5.3+ performance_schema + if ([database isEqualToString:@"information_schema"] || [database isEqualToString:@"mysql"] || [database isEqualToString:@"performance_schema"]) { [allSystemDatabases addObject:database]; } else { diff --git a/Source/SPExtendedTableInfo.m b/Source/SPExtendedTableInfo.m index 1f67b95d..a765f6df 100644 --- a/Source/SPExtendedTableInfo.m +++ b/Source/SPExtendedTableInfo.m @@ -513,23 +513,24 @@ // If we are viewing tables in the information_schema database, then disable all controls that cause table // changes as these tables are not modifiable by anyone. - BOOL isInformationSchemaDb = [[tableDocumentInstance database] isEqualToString:@"information_schema"]; + //also affects mysql and performance_schema + BOOL isSystemSchemaDb = ([[tableDocumentInstance database] isEqualToString:@"information_schema"] || [[tableDocumentInstance database] isEqualToString:@"performance_schema"] || [[tableDocumentInstance database] isEqualToString:@"mysql"]); if ([[databaseDataInstance getDatabaseStorageEngines] count] && [statusFields objectForKey:@"Engine"]) { - [tableTypePopUpButton setEnabled:(!isInformationSchemaDb)]; + [tableTypePopUpButton setEnabled:(!isSystemSchemaDb)]; } if ([[databaseDataInstance getDatabaseCharacterSetEncodings] count] && [tableDataInstance tableEncoding]) { - [tableEncodingPopUpButton setEnabled:(!isInformationSchemaDb)]; + [tableEncodingPopUpButton setEnabled:(!isSystemSchemaDb)]; } if ([[databaseDataInstance getDatabaseCollationsForEncoding:[tableDataInstance tableEncoding]] count] && [statusFields objectForKey:@"Collation"]) { - [tableCollationPopUpButton setEnabled:(!isInformationSchemaDb)]; + [tableCollationPopUpButton setEnabled:(!isSystemSchemaDb)]; } - [tableCommentsTextView setEditable:(!isInformationSchemaDb)]; + [tableCommentsTextView setEditable:(!isSystemSchemaDb)]; } #pragma mark - diff --git a/Source/SPTextView.m b/Source/SPTextView.m index ab37f464..af4356a2 100644 --- a/Source/SPTextView.m +++ b/Source/SPTextView.m @@ -351,8 +351,10 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) // Put information_schema and/or mysql db at the end if not selected + // 5.5.3+ also has performance_schema NSString* mysql_id = [NSString stringWithFormat:@"%@%@%@", connectionID, SPUniqueSchemaDelimiter, @"mysql"]; - NSString* inf_id = [NSString stringWithFormat:@"%@%@%@", connectionID, SPUniqueSchemaDelimiter, @"information_schema"]; + NSString* inf_id = [NSString stringWithFormat:@"%@%@%@", connectionID, SPUniqueSchemaDelimiter, @"information_schema"]; + NSString* perf_id = [NSString stringWithFormat:@"%@%@%@", connectionID, SPUniqueSchemaDelimiter, @"performance_schema"]; if(currentDb && ![currentDb isEqualToString:mysql_id] && [sortedDbs containsObject:mysql_id]) { [sortedDbs removeObject:mysql_id]; [sortedDbs addObject:mysql_id]; @@ -361,6 +363,10 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [sortedDbs removeObject:inf_id]; [sortedDbs addObject:inf_id]; } + if(currentDb && ![currentDb isEqualToString:perf_id] && [sortedDbs containsObject:perf_id]) { + [sortedDbs removeObject:perf_id]; + [sortedDbs addObject:perf_id]; + } BOOL aTableNameExists = NO; if(!aDbName) { -- cgit v1.2.3