Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Prevent users from creating tables using the performance_schema stora…
…ge engine.
  • Loading branch information
stuconnolly committed Oct 11, 2018
1 parent dbc3198 commit 61c3aa1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
11 changes: 7 additions & 4 deletions Source/SPDatabaseData.m
Expand Up @@ -276,8 +276,10 @@ - (NSArray *)getDatabaseStorageEngines
// Check if InnoDB support is enabled
NSString *result = [self _getSingleVariableValue:@"have_innodb"];

if(result && [result isEqualToString:@"YES"])
if (result && [result isEqualToString:@"YES"])
{
[storageEngines addObject:@{@"Engine" : @"InnoDB"}];
}

// Before MySQL 4.1 the MEMORY engine was known as HEAP and the ISAM engine was included
if ([serverSupport supportsPre41StorageEngines]) {
Expand Down Expand Up @@ -314,7 +316,7 @@ - (NSArray *)getDatabaseStorageEngines

// Table is accessible so get available storage engines
// Note, that the case of the column names specified in this query are important.
[storageEngines addObjectsFromArray:[self _getDatabaseDataForQuery:@"SELECT Engine, Support FROM `information_schema`.`engines` WHERE SUPPORT IN ('DEFAULT', 'YES')"]];
[storageEngines addObjectsFromArray:[self _getDatabaseDataForQuery:@"SELECT Engine, Support FROM `information_schema`.`engines` WHERE SUPPORT IN ('DEFAULT', 'YES') AND Engine != 'PERFORMANCE_SCHEMA'"]];
}
}
else {
Expand All @@ -324,8 +326,9 @@ - (NSArray *)getDatabaseStorageEngines
// We only want to include engines that are supported
for (NSDictionary *engine in engines)
{
if (([[engine objectForKey:@"Support"] isEqualToString:@"DEFAULT"]) ||
([[engine objectForKey:@"Support"] isEqualToString:@"YES"]))
if (([[engine objectForKey:@"Support"] isEqualToString:@"DEFAULT"] ||
[[engine objectForKey:@"Support"] isEqualToString:@"YES"]) &&
![[engine objectForKey:@"Engine"] isEqualToString:@"PERFORMANCE_SCHEMA"])
{
[storageEngines addObject:engine];
}
Expand Down
12 changes: 10 additions & 2 deletions Source/SPExtendedTableInfo.m
Expand Up @@ -335,16 +335,24 @@ - (void)loadTable:(NSString *)table
NSArray *encodings = [databaseDataInstance getDatabaseCharacterSetEncodings];
NSArray *collations = [databaseDataInstance getDatabaseCollationsForEncoding:[tableDataInstance tableEncoding]];

if (([engines count] > 0) && ([statusFields objectForKey:SPMySQLEngineField])) {
NSString *storageEngine = [statusFields objectForKey:SPMySQLEngineField];

if ([engines count] > 0 && storageEngine) {

// Populate type popup button
for (NSDictionary *engine in engines)
{
[tableTypePopUpButton addItemWithTitle:[engine objectForKey:SPMySQLEngineField]];
}

[tableTypePopUpButton selectItemWithTitle:[statusFields objectForKey:SPMySQLEngineField]];
[tableTypePopUpButton selectItemWithTitle:storageEngine];
[tableTypePopUpButton setEnabled:enableInteraction];

// Object has a non-user storage engine (i.e. performance_schema) so just add it
if ([tableTypePopUpButton indexOfSelectedItem] == -1) {
[tableTypePopUpButton addItemWithTitle:storageEngine];
[tableTypePopUpButton selectItemWithTitle:storageEngine];
}
}
else {
[tableTypePopUpButton addItemWithTitle:NSLocalizedString(@"Not available", @"not available label")];
Expand Down

0 comments on commit 61c3aa1

Please sign in to comment.