aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2016-02-21 17:05:31 +0100
committerMax <post@wickenrode.com>2016-02-21 17:05:31 +0100
commit63ef786ffa86a3b095d55178f34c6b90dcfaf1bc (patch)
tree39e8fc0b508c86b9b2fd842c9d8637dc26a8330b /Source
parentf2575a3a755e625330263c06403d167f7e7901d4 (diff)
downloadsequelpro-63ef786ffa86a3b095d55178f34c6b90dcfaf1bc.tar.gz
sequelpro-63ef786ffa86a3b095d55178f34c6b90dcfaf1bc.tar.bz2
sequelpro-63ef786ffa86a3b095d55178f34c6b90dcfaf1bc.zip
Fix a rare issue where duplicating a database could cause an exception if a SHOW CREATE TABLE statement failed (#2413)
Diffstat (limited to 'Source')
-rw-r--r--Source/SPTableCopy.m11
1 files changed, 6 insertions, 5 deletions
diff --git a/Source/SPTableCopy.m b/Source/SPTableCopy.m
index cd3fc42e..07f03846 100644
--- a/Source/SPTableCopy.m
+++ b/Source/SPTableCopy.m
@@ -44,9 +44,9 @@
- (BOOL)copyTable:(NSString *)tableName from:(NSString *)sourceDB to:(NSString *)targetDB
{
NSString *createTableResult = [self _createTableStatementFor:tableName inDatabase:sourceDB];
- NSMutableString *createTableStatement = [[NSMutableString alloc] initWithString:createTableResult];
- if ([[createTableStatement substringToIndex:12] isEqualToString:@"CREATE TABLE"]) {
+ if ([createTableResult hasPrefix:@"CREATE TABLE"]) {
+ NSMutableString *createTableStatement = [[NSMutableString alloc] initWithString:createTableResult];
// Add the target DB name and the separator dot after "CREATE TABLE ".
[createTableStatement insertString:@"." atIndex:13];
@@ -59,8 +59,6 @@
return ![connection queryErrored];
}
- [createTableStatement release];
-
return NO;
}
@@ -151,7 +149,10 @@
SPMySQLResult *theResult = [connection queryString:showCreateTableStatment];
- return [theResult numberOfRows] > 0 ? [[theResult getRowAsArray] objectAtIndex:1] : @"";
+ if([theResult numberOfRows] > 0) return [[theResult getRowAsArray] objectAtIndex:1];
+
+ NSLog(@"query <%@> failed to return the expected result.\n Error state: %@ (%lu)",showCreateTableStatment,[connection lastErrorMessage],[connection lastErrorID]);
+ return nil;
}
@end