aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPIndexesController.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-09-22 22:08:48 +0000
committerstuconnolly <stuart02@gmail.com>2010-09-22 22:08:48 +0000
commite7f4b5ea710721440be2a341bbea1a940664be7c (patch)
tree059d2438af7d0896c622a647d0915f3ab4be9ccc /Source/SPIndexesController.m
parentf12e8dfc1453248b843efe9066570206c26bbdd6 (diff)
downloadsequelpro-e7f4b5ea710721440be2a341bbea1a940664be7c.tar.gz
sequelpro-e7f4b5ea710721440be2a341bbea1a940664be7c.tar.bz2
sequelpro-e7f4b5ea710721440be2a341bbea1a940664be7c.zip
Add support in the new index sheet for specifying an index's key block size (in the advanced view) which was added in MySQL 5.1.10.
Diffstat (limited to 'Source/SPIndexesController.m')
-rw-r--r--Source/SPIndexesController.m37
1 files changed, 29 insertions, 8 deletions
diff --git a/Source/SPIndexesController.m b/Source/SPIndexesController.m
index 50f2e677..21e1a66c 100644
--- a/Source/SPIndexesController.m
+++ b/Source/SPIndexesController.m
@@ -32,6 +32,7 @@ NSString *SPNewIndexIndexName = @"IndexName";
NSString *SPNewIndexIndexType = @"IndexType";
NSString *SPNewIndexIndexedColumns = @"IndexedColumns";
NSString *SPNewIndexStorageType = @"IndexStorageType";
+NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize";
@interface SPIndexesController (PrivateAPI)
@@ -161,6 +162,10 @@ NSString *SPNewIndexStorageType = @"IndexStorageType";
// as it's the default anyway.
[indexStorageTypePopUpButton setEnabled:(!([engine isEqualToString:@"MyISAM"] || [engine isEqualToString:@"InnoDB"]))];
+ // The ability to specify an index's key block size was added in MySQL 5.1.10 so disable the textfield
+ // if it's not supported.
+ [indexKeyBlockSizeTextField setEnabled:(([connection serverMajorVersion] >= 5) && ([connection serverMinorVersion] >= 1) && ([connection serverReleaseVersion] >= 10))];
+
// Begin the sheet
[NSApp beginSheet:[self window]
modalForWindow:[dbDocument parentWindow]
@@ -258,6 +263,9 @@ NSString *SPNewIndexStorageType = @"IndexStorageType";
[NSApp endSheet:[sender window] returnCode:[sender tag]];
[[sender window] orderOut:self];
+
+ // Clear the index key block size field
+ [indexKeyBlockSizeTextField setStringValue:@""];
}
/**
@@ -337,13 +345,14 @@ NSString *SPNewIndexStorageType = @"IndexStorageType";
- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
{
+ if (tableView == indexesTableView) return;
- if(tableView == indexesTableView) return;
-
- if([[tableColumn identifier] isEqualToString:@"name"]) {
+ if ([[tableColumn identifier] isEqualToString:@"name"]) {
+
// Iterate to given fields to replace the correct desired index field dictionary
- for(NSDictionary *dic in fields) {
- if([[dic objectForKey:@"name"] isEqualToString:object]) {
+ for (NSDictionary *dic in fields)
+ {
+ if ([[dic objectForKey:@"name"] isEqualToString:object]) {
[indexedFields replaceObjectAtIndex:rowIndex withObject:dic];
break;
}
@@ -474,6 +483,11 @@ NSString *SPNewIndexStorageType = @"IndexStorageType";
[indexDetails setObject:indexedFields forKey:SPNewIndexIndexedColumns];
[indexDetails setObject:[indexNameTextField stringValue] forKey:SPNewIndexIndexName];
[indexDetails setObject:[indexTypePopUpButton titleOfSelectedItem] forKey:SPNewIndexIndexType];
+
+ // If there is a key block size set it means the database version supports it
+ if ([[indexKeyBlockSizeTextField stringValue] length]) {
+ [indexDetails setObject:[NSNumber numberWithInteger:[indexKeyBlockSizeTextField integerValue]] forKey:SPNewIndexKeyBlockSize];
+ }
if ([indexStorageTypePopUpButton indexOfSelectedItem] > 0) {
[indexDetails setObject:[indexStorageTypePopUpButton titleOfSelectedItem] forKey:SPNewIndexStorageType];
@@ -614,9 +628,11 @@ NSString *SPNewIndexStorageType = @"IndexStorageType";
if (![[tableStructure onMainThread] saveRowOnDeselect]) return;
// Retrieve index details
- NSString *indexName = [indexDetails objectForKey:SPNewIndexIndexName];
- NSString *indexType = [indexDetails objectForKey:SPNewIndexIndexType];
- NSString *indexStorageType = [indexDetails objectForKey:SPNewIndexStorageType];
+ NSString *indexName = [indexDetails objectForKey:SPNewIndexIndexName];
+ NSString *indexType = [indexDetails objectForKey:SPNewIndexIndexType];
+ NSString *indexStorageType = [indexDetails objectForKey:SPNewIndexStorageType];
+ NSNumber *indexKeyBlockSize = [indexDetails objectForKey:SPNewIndexKeyBlockSize];
+
NSArray *indexedColumns = [indexDetails objectForKey:SPNewIndexIndexedColumns];
// Interface validation should prevent this, but just to be safe
@@ -669,6 +685,11 @@ NSString *SPNewIndexStorageType = @"IndexStorageType";
[query appendString:@" USING "];
[query appendString:indexStorageType];
}
+
+ // If supplied specify the index's key block size
+ if (indexKeyBlockSize) {
+ [query appendFormat:@" KEY_BLOCK_SIZE = %d", [indexKeyBlockSize integerValue]];
+ }
// Execute the query
[connection queryString:query];