From 6a50c5b04187d6546aa11c50a38f77b8ba132565 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Wed, 2 Jun 2010 00:21:46 +0000 Subject: - Fix exceptions and crashes caused by corrupt tables, disabled storage engines, or similar hard MySQL errors --- Source/SPExtendedTableInfo.m | 4 +++- Source/SPTableData.m | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/SPExtendedTableInfo.m b/Source/SPExtendedTableInfo.m index 605cec35..d9d720fa 100644 --- a/Source/SPExtendedTableInfo.m +++ b/Source/SPExtendedTableInfo.m @@ -360,7 +360,9 @@ [tableCreateSyntaxTextView setString:@""]; [tableCreateSyntaxTextView didChangeText]; [tableCreateSyntaxTextView shouldChangeTextInRange:NSMakeRange(0, 0) replacementString:[tableDataInstance tableCreateSyntax]]; - [tableCreateSyntaxTextView insertText:[[tableDataInstance tableCreateSyntax] stringByAppendingString:@";"]]; + if ([tableDataInstance tableCreateSyntax]) { + [tableCreateSyntaxTextView insertText:[[tableDataInstance tableCreateSyntax] stringByAppendingString:@";"]]; + } [tableCreateSyntaxTextView didChangeText]; [tableCreateSyntaxTextView setEditable:NO]; diff --git a/Source/SPTableData.m b/Source/SPTableData.m index ea9229cb..35d7060b 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -850,6 +850,12 @@ [status setObject:[status objectForKey:@"Type"] forKey:@"Engine"]; } + // If the "Engine" key is NULL, a problem occurred when retrieving the table information. + if ([[status objectForKey:@"Engine"] isNSNull]) { + [status setDictionary:[NSDictionary dictionaryWithObjectsAndKeys:@"Error", @"Engine", [NSString stringWithFormat:@"An error occurred retrieving table information. MySQL said: %@", [status objectForKey:@"Comment"]], @"Comment", [tableListInstance tableName], @"Name", nil]]; + return FALSE; + } + // Add a note for whether the row count is accurate or not - only for MyISAM if ([[status objectForKey:@"Engine"] isEqualToString:@"MyISAM"]) { [status setObject:@"y" forKey:@"RowsCountAccurate"]; -- cgit v1.2.3