diff options
-rw-r--r-- | Resources/English.lproj/Localizable.strings | bin | 182032 -> 182178 bytes | |||
-rw-r--r-- | Source/SPIndexesController.m | 24 | ||||
-rw-r--r-- | Source/SPServerSupport.h | 6 | ||||
-rw-r--r-- | Source/SPServerSupport.m | 5 |
4 files changed, 29 insertions, 6 deletions
diff --git a/Resources/English.lproj/Localizable.strings b/Resources/English.lproj/Localizable.strings Binary files differindex 1a0c85af..b30e0551 100644 --- a/Resources/English.lproj/Localizable.strings +++ b/Resources/English.lproj/Localizable.strings diff --git a/Source/SPIndexesController.m b/Source/SPIndexesController.m index bd7d9253..c0bf2448 100644 --- a/Source/SPIndexesController.m +++ b/Source/SPIndexesController.m @@ -129,12 +129,20 @@ NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; [indexTypePopUpButton selectItemAtIndex:0]; [indexNameTextField setEnabled:NO]; [indexNameTextField setStringValue:@"PRIMARY"]; + + // If the table is of type MyISAM and Spation extension support is available, add the SPATIAL type + NSString *engine = [[tableData statusValues] objectForKey:@"Engine"]; + + if ([engine isEqualToString:@"MyISAM"] && [[dbDocument serverSupport] supportsSpatialExtensions]) { + [indexTypePopUpButton addItemWithTitle:@"SPATIAL"]; + } - // Check to see whether a primary key already exists for the table, and if so select an INDEX instead + // Check to see whether a primary key already exists for the table, and if so select INDEX instead for (NSDictionary *field in fields) { if ([field objectForKey:@"isprimarykey"]) { + // Remove primary key option [indexTypePopUpButton removeItemAtIndex:0]; // Select INDEX type @@ -156,9 +164,6 @@ NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; [addIndexedColumnButton setEnabled:([indexedFields count] < [fields count])]; - // Index storage types (HASH & BTREE) are only available some storage engines - NSString *engine = [[tableData statusValues] objectForKey:@"Engine"]; - // MyISAM and InnoDB tables only support BTREE storage types so disable the storage type popup button // as it's the default anyway. [indexStorageTypePopUpButton setEnabled:(!([engine isEqualToString:@"MyISAM"] || [engine isEqualToString:@"InnoDB"]))]; @@ -235,7 +240,9 @@ NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; */ - (IBAction)chooseIndexType:(id)sender { - if ([[indexTypePopUpButton titleOfSelectedItem] isEqualToString:@"PRIMARY KEY"] ) { + NSString *indexType = [indexTypePopUpButton titleOfSelectedItem]; + + if ([indexType isEqualToString:@"PRIMARY KEY"] ) { [indexNameTextField setEnabled:NO]; [indexNameTextField setStringValue:@"PRIMARY"]; } @@ -245,6 +252,9 @@ NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; if ([[indexNameTextField stringValue] isEqualToString:@"PRIMARY"]) { [indexNameTextField setStringValue:@""]; } + + // Specifiying an index storage type (i.e. HASH or BTREE) is not permitted with SPATIAL indexes + [indexStorageTypePopUpButton setEnabled:(![indexType isEqualToString:@"SPATIAL"])]; } } @@ -490,7 +500,7 @@ NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; [indexDetails setObject:[NSNumber numberWithInteger:[indexKeyBlockSizeTextField integerValue]] forKey:SPNewIndexKeyBlockSize]; } - if ([indexStorageTypePopUpButton indexOfSelectedItem] > 0) { + if (([indexStorageTypePopUpButton indexOfSelectedItem] > 0) && (![[indexTypePopUpButton titleOfSelectedItem] isEqualToString:@"SPATIAL"])) { [indexDetails setObject:[indexStorageTypePopUpButton titleOfSelectedItem] forKey:SPNewIndexStorageType]; } @@ -668,6 +678,8 @@ NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; [tempIndexedColumns addObject:[columnName backtickQuotedString]]; } } + + if (![indexType isEqualToString:@"INDEX"]) indexType = [indexType stringByAppendingFormat:@" INDEX"]; // Build the query NSMutableString *query = [NSMutableString stringWithFormat:@"ALTER TABLE %@ ADD %@", [table backtickQuotedString], indexType]; diff --git a/Source/SPServerSupport.h b/Source/SPServerSupport.h index b1afc5cd..fc16b426 100644 --- a/Source/SPServerSupport.h +++ b/Source/SPServerSupport.h @@ -50,6 +50,7 @@ // General BOOL supportsInformationSchema; + BOOL supportsSpatialExtensions; // Encoding BOOL supportsShowCharacterSet; @@ -123,6 +124,11 @@ @property (readonly) BOOL supportsInformationSchema; /** + * @property supportsSpatialExtensions Indicates if the server supports spatial extensions + */ +@property (readonly) BOOL supportsSpatialExtensions; + +/** * @property supportsShowCharacterSet Indicates if the server supports the SHOW CHARACTER SET statement */ @property (readonly) BOOL supportsShowCharacterSet; diff --git a/Source/SPServerSupport.m b/Source/SPServerSupport.m index 3f8227d9..0b3ba79d 100644 --- a/Source/SPServerSupport.m +++ b/Source/SPServerSupport.m @@ -45,6 +45,7 @@ @synthesize isMySQL5; @synthesize isMySQL6; @synthesize supportsInformationSchema; +@synthesize supportsSpatialExtensions; @synthesize supportsShowCharacterSet; @synthesize supportsCharacterSetDatabaseVar; @synthesize supportsPost41CharacterSetHandling; @@ -120,6 +121,9 @@ // The information schema database wasn't added until MySQL 5 supportsInformationSchema = (serverMajorVersion >= 5); + // Support for spatial extensions wasn't added until MySQL 4.1 + supportsSpatialExtensions = [self isEqualToOrGreaterThanMajorVersion:4 minor:1 release:0]; + // The SHOW CHARACTER SET statement wasn't added until MySQL 4.1.0 supportsShowCharacterSet = [self isEqualToOrGreaterThanMajorVersion:4 minor:1 release:0]; @@ -232,6 +236,7 @@ isMySQL6 = NO; supportsInformationSchema = NO; + supportsSpatialExtensions = NO; supportsShowCharacterSet = NO; supportsCharacterSetDatabaseVar = NO; supportsPost41CharacterSetHandling = NO; |