aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDatabaseInfo.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-08-13 16:48:59 +0000
committerstuconnolly <stuart02@gmail.com>2010-08-13 16:48:59 +0000
commitf1e829f98f50d9e75e7ba111361a625f7aab802d (patch)
tree930c14091b0cba5d4c44ec1e4fc70c34f55c56fe /Source/SPDatabaseInfo.m
parentefdcfb17f87863fef42f209f72eb4c4ccd888d35 (diff)
downloadsequelpro-f1e829f98f50d9e75e7ba111361a625f7aab802d.tar.gz
sequelpro-f1e829f98f50d9e75e7ba111361a625f7aab802d.tar.bz2
sequelpro-f1e829f98f50d9e75e7ba111361a625f7aab802d.zip
Tidy up database renaming and copying by removing the use of alert dialogs within loops to prevent locking up the main thread. These operations ideally should also be threaded.
Diffstat (limited to 'Source/SPDatabaseInfo.m')
-rw-r--r--Source/SPDatabaseInfo.m28
1 files changed, 15 insertions, 13 deletions
diff --git a/Source/SPDatabaseInfo.m b/Source/SPDatabaseInfo.m
index 551a1c77..3c70aec9 100644
--- a/Source/SPDatabaseInfo.m
+++ b/Source/SPDatabaseInfo.m
@@ -27,42 +27,44 @@
@implementation SPDatabaseInfo
--(BOOL)databaseExists:(NSString *)databaseName {
+-(BOOL)databaseExists:(NSString *)databaseName
+{
NSArray *names = [self listDBs];
+
return [names containsObject:databaseName];
}
-- (NSArray *)listDBs {
+- (NSArray *)listDBs
+{
return [self listDBsLike:nil];
}
- (NSArray *)listDBsLike:(NSString *)dbsName
{
NSString *listDBStatement = nil;
+
if ((dbsName == nil) || ([dbsName isEqualToString:@""])) {
listDBStatement = [NSString stringWithFormat:@"SHOW DATABASES"];
}
else {
listDBStatement = [NSString stringWithFormat:@"SHOW DATABASES LIKE %@", [dbsName backtickQuotedString]];
}
- DLog(@"running query : %@", listDBStatement);
+
MCPResult *theResult = [connection queryString:listDBStatement];
- if ([connection queryErrored]) {
- SPBeginAlertSheet(NSLocalizedString(@"Failed to retrieve databases list", @"database list error message"),
- NSLocalizedString(@"OK", @"OK button"), nil, nil, messageWindow, self, nil, nil,
- [NSString stringWithFormat:NSLocalizedString(@"An error occured while trying to retrieve a list of databases.\n\nMySQL said: %@",
- @"database list error informative message"),
- [connection getLastErrorMessage]]);
- return NO;
- }
+ if ([connection queryErrored]) return NO;
NSMutableArray *names = [NSMutableArray array];
NSMutableString *name;
+
if ([theResult numOfRows] > 1) {
- int i;
- for ( i = 0 ; i < [theResult numOfRows] ; i++ ) {
+
+ NSUInteger i;
+
+ for (i = 0 ; i < [theResult numOfRows]; i++)
+ {
name = [[theResult fetchRowAsArray] objectAtIndex:0];
+
[names addObject:name];
}
}