Permalink
Browse files

Prevent users from creating tables using the performance_schema stora…

…ge engine.
  • Loading branch information...
stuconnolly committed Oct 11, 2018
1 parent dbc3198 commit 61c3aa11b9d9f2fa47b9a26a0334b9f834e52d93
Showing with 17 additions and 6 deletions.
  1. +7 −4 Source/SPDatabaseData.m
  2. +10 −2 Source/SPExtendedTableInfo.m
View
@@ -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]) {
@@ -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 {
@@ -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];
}
@@ -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")];

0 comments on commit 61c3aa1

Please sign in to comment.