From 0ad4a219afda9e2c00db4dd80598d17ce6bf0c1f Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Tue, 19 May 2009 14:06:32 +0000 Subject: When adding a new table allow the user to specify the storage engine used. --- Source/TablesList.h | 1 + Source/TablesList.m | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'Source') diff --git a/Source/TablesList.h b/Source/TablesList.h index 6bc0d76b..a745f9ba 100644 --- a/Source/TablesList.h +++ b/Source/TablesList.h @@ -58,6 +58,7 @@ enum sp_table_types IBOutlet id tableSheet; IBOutlet id tableNameField; IBOutlet id tableEncodingButton; + IBOutlet id tableTypeButton; IBOutlet id addTableButton; IBOutlet id tableRenameSheet; IBOutlet id tableRenameField; diff --git a/Source/TablesList.m b/Source/TablesList.m index f0e7abd3..6173a5d2 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -204,6 +204,22 @@ [tableWindow endEditingFor:nil]; + // Populate the table type (engine) popup button + [tableTypeButton removeAllItems]; + + CMMCPResult *engines = [mySQLConnection queryString:@"SELECT engine FROM information_schema.engines"]; + + [engines dataSeek:0]; + + // Add default menu item + [tableTypeButton addItemWithTitle:@"Default"]; + [[tableTypeButton menu] addItem:[NSMenuItem separatorItem]]; + + for (int i = 0; i < [engines numOfRows]; i++) + { + [tableTypeButton addItemWithTitle:[[engines fetchRowAsArray] objectAtIndex:0]]; + } + [NSApp beginSheet:tableSheet modalForWindow:tableWindow modalDelegate:self @@ -230,6 +246,11 @@ createStatement = [NSString stringWithFormat:@"%@ DEFAULT CHARACTER SET %@", createStatement, [[tableDocumentInstance mysqlEncodingFromDisplayEncoding:[tableEncodingButton title]] backtickQuotedString]]; } + // If there is a type selected other than the default we must specify it in CREATE TABLE statement + if ([tableTypeButton indexOfSelectedItem] > 0) { + createStatement = [NSString stringWithFormat:@"%@ ENGINE = %@", createStatement, [[tableTypeButton title] backtickQuotedString]]; + } + // Create the table [mySQLConnection queryString:createStatement]; -- cgit v1.2.3