diff options
-rw-r--r-- | Source/SPConstants.h | 3 | ||||
-rw-r--r-- | Source/SPServerSupport.h | 8 | ||||
-rw-r--r-- | Source/SPServerSupport.m | 5 | ||||
-rw-r--r-- | Source/SPTablesList.h | 1 | ||||
-rw-r--r-- | Source/SPTablesList.m | 41 |
5 files changed, 32 insertions, 26 deletions
diff --git a/Source/SPConstants.h b/Source/SPConstants.h index 60787559..415fd4da 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -103,7 +103,8 @@ typedef enum SPTableTypeTable = 0, SPTableTypeView = 1, SPTableTypeProc = 2, - SPTableTypeFunc = 3 + SPTableTypeFunc = 3, + SPTableTypeEvent = 4 } SPTableType; // History views diff --git a/Source/SPServerSupport.h b/Source/SPServerSupport.h index 55b8a6ad..e8b8a613 100644 --- a/Source/SPServerSupport.h +++ b/Source/SPServerSupport.h @@ -85,6 +85,9 @@ // Indexes BOOL supportsIndexKeyBlockSize; + + // Events + BOOL supportsEvents; // Data types BOOL supportsFractionalSeconds; @@ -230,6 +233,11 @@ @property (readonly) BOOL supportsTriggers; /** +* @property supportsEvents Indicates if the server supports scheduled events +*/ +@property (readonly) BOOL supportsEvents; + +/** * @property supportsIndexKeyBlockSize Indicates if the server supports specifying an index's key block size */ @property (readonly) BOOL supportsIndexKeyBlockSize; diff --git a/Source/SPServerSupport.m b/Source/SPServerSupport.m index 991a9fd3..bf74a61e 100644 --- a/Source/SPServerSupport.m +++ b/Source/SPServerSupport.m @@ -69,6 +69,7 @@ @synthesize supportsArchiveStorageEngine; @synthesize supportsCSVStorageEngine; @synthesize supportsTriggers; +@synthesize supportsEvents; @synthesize supportsIndexKeyBlockSize; @synthesize supportsQuotingEngineTypeInCreateSyntax; @synthesize supportsFractionalSeconds; @@ -185,6 +186,9 @@ // Support for triggers wasn't added until MySQL 5.0.2 supportsTriggers = [self isEqualToOrGreaterThanMajorVersion:5 minor:0 release:2]; + + // Support for events wasn't added until MySQL 5.1.6 + supportsEvents = [self isEqualToOrGreaterThanMajorVersion:5 minor:1 release:6]; // Support for specifying an index's key block size wasn't added until MySQL 5.1.10 supportsIndexKeyBlockSize = [self isEqualToOrGreaterThanMajorVersion:5 minor:1 release:10]; @@ -280,6 +284,7 @@ supportsArchiveStorageEngine = NO; supportsCSVStorageEngine = NO; supportsTriggers = NO; + supportsEvents = NO; supportsIndexKeyBlockSize = NO; supportsQuotingEngineTypeInCreateSyntax = NO; supportsFractionalSeconds = NO; diff --git a/Source/SPTablesList.h b/Source/SPTablesList.h index a8d9ab91..198f327f 100644 --- a/Source/SPTablesList.h +++ b/Source/SPTablesList.h @@ -180,6 +180,7 @@ - (NSArray *)allViewNames; - (NSArray *)allFunctionNames; - (NSArray *)allProcedureNames; +- (NSArray *)allEventNames; - (NSArray *)allDatabaseNames; - (NSArray *)allSystemDatabaseNames; - (NSString *)selectedDatabase; diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index 952d4868..3efc45ef 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -91,6 +91,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; #endif - (void)_renameTableOfType:(SPTableType)tableType from:(NSString *)oldTableName to:(NSString *)newTableName; - (void)_duplicateConnectionToFrontTab; +- (NSMutableArray *)_allSchemaObjectsOfType:(SPTableType)type; @end @implementation SPTablesList @@ -1286,47 +1287,37 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; - (NSArray *)allTableNames { - NSMutableArray *returnArray = [NSMutableArray array]; - NSInteger i; - NSInteger cnt = [[self tables] count]; - for(i=0; i<cnt; i++) { - if([NSArrayObjectAtIndex([self tableTypes],i) integerValue] == SPTableTypeTable) - [returnArray addObject:NSArrayObjectAtIndex([self tables], i)]; - } - return returnArray; + return [self _allSchemaObjectsOfType:SPTableTypeTable]; } - (NSArray *)allViewNames { - NSMutableArray *returnArray = [NSMutableArray array]; - NSInteger i; - NSInteger cnt = [[self tables] count]; - for(i=0; i<cnt; i++) { - if([NSArrayObjectAtIndex([self tableTypes],i) integerValue] == SPTableTypeView) - [returnArray addObject:NSArrayObjectAtIndex([self tables], i)]; - } + NSMutableArray *returnArray = [self _allSchemaObjectsOfType:SPTableTypeView]; [returnArray sortUsingSelector:@selector(compare:)]; return returnArray; } - (NSArray *)allProcedureNames { - NSMutableArray *returnArray = [NSMutableArray array]; - NSInteger i; - NSInteger cnt = [[self tables] count]; - for(i=0; i<cnt; i++) { - if([NSArrayObjectAtIndex([self tableTypes],i) integerValue] == SPTableTypeProc) - [returnArray addObject:NSArrayObjectAtIndex([self tables], i)]; - } - return returnArray; + return [self _allSchemaObjectsOfType:SPTableTypeProc]; } - (NSArray *)allFunctionNames { + return [self _allSchemaObjectsOfType:SPTableTypeFunc]; +} + +- (NSArray *)allEventNames +{ + return [self _allSchemaObjectsOfType:SPTableTypeEvent]; +} + +- (NSMutableArray *)_allSchemaObjectsOfType:(SPTableType)type +{ NSMutableArray *returnArray = [NSMutableArray array]; - NSInteger i; + NSUInteger i; NSInteger cnt = [[self tables] count]; for(i=0; i<cnt; i++) { - if([NSArrayObjectAtIndex([self tableTypes],i) integerValue] == SPTableTypeFunc) + if([NSArrayObjectAtIndex([self tableTypes],i) integerValue] == type) [returnArray addObject:NSArrayObjectAtIndex([self tables], i)]; } return returnArray; |