aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/SPTableContent.m22
-rw-r--r--Source/SPTableData.m13
2 files changed, 24 insertions, 11 deletions
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index 967cbaf0..2ea0b7c6 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -437,7 +437,8 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper
[tableContentView scrollColumnToVisible:0];
// Set the maximum table rows to an estimated count pre-load
- maxNumRows = [[tableDataInstance statusValueForKey:@"Rows"] integerValue];
+ NSString *rows = [tableDataInstance statusValueForKey:@"Rows"];
+ maxNumRows = (rows && ![rows isNSNull])? [rows integerValue] : 0;
maxNumRowsIsEstimate = YES;
}
@@ -3978,17 +3979,18 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper
[tableDataInstance updateAccurateNumberOfRowsForCurrentTableForcingUpdate:NO];
// If the state is now accurate, use it
+ NSString *rows = [tableDataInstance statusValueForKey:@"Rows"];
if ([[tableDataInstance statusValueForKey:@"RowsCountAccurate"] boolValue]) {
- maxNumRows = [[tableDataInstance statusValueForKey:@"Rows"] integerValue];
- maxNumRowsIsEstimate = NO;
- checkStatusCount = YES;
-
+ maxNumRows = [rows integerValue];
+ maxNumRowsIsEstimate = NO;
+ checkStatusCount = YES;
+ }
// Otherwise, use the estimate count
- } else {
- maxNumRows = [[tableDataInstance statusValueForKey:@"Rows"] integerValue];
- maxNumRowsIsEstimate = YES;
- checkStatusCount = YES;
- }
+ else {
+ maxNumRows = (rows && ![rows isNSNull])? [rows integerValue] : 0;
+ maxNumRowsIsEstimate = YES;
+ checkStatusCount = YES;
+ }
}
// Check whether the estimated count requires updating, ie if the retrieved count exceeds it
diff --git a/Source/SPTableData.m b/Source/SPTableData.m
index cb98183e..00504c2f 100644
--- a/Source/SPTableData.m
+++ b/Source/SPTableData.m
@@ -1045,9 +1045,20 @@
// this happens e.g. for db "information_schema"
if([[status objectForKey:@"Rows"] isNSNull]) {
tableStatusResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SELECT COUNT(1) FROM %@", [escapedTableName backtickQuotedString] ]];
- if (![mySQLConnection queryErrored])
+ // this query can fail e.g. if a table is damaged
+ if (tableStatusResult && ![mySQLConnection queryErrored]) {
[status setObject:[[tableStatusResult getRowAsArray] objectAtIndex:0] forKey:@"Rows"];
[status setObject:@"y" forKey:@"RowsCountAccurate"];
+ }
+ else {
+ //FIXME that error should really show only when trying to view the table content, but we don't even try to load that if Rows==NULL
+ SPOnewayAlertSheet(
+ NSLocalizedString(@"Querying row count failed", @"table status : row count query failed : error title"),
+ nil,
+ [NSApp mainWindow],
+ [NSString stringWithFormat:NSLocalizedString(@"An error occured while trying to determine the number of rows for “%@”.\nMySQL said: %@ (%lu)", @"table status : row count query failed : error message"),[tableListInstance tableName],[mySQLConnection lastErrorMessage],[mySQLConnection lastErrorID]]
+ );
+ }
}
}