diff options
author | Max <post@wickenrode.com> | 2016-03-03 19:54:44 +0100 |
---|---|---|
committer | Max <post@wickenrode.com> | 2016-03-03 19:54:44 +0100 |
commit | ba04386f728a8606c6a0c3f4b121cbe74c1d051f (patch) | |
tree | e3bd6891da701adf8599106f31fb4c52e8179475 /Source/SPTableData.m | |
parent | 5b95189def6eff812eb6abbcd2c56db7325b7002 (diff) | |
download | sequelpro-ba04386f728a8606c6a0c3f4b121cbe74c1d051f.tar.gz sequelpro-ba04386f728a8606c6a0c3f4b121cbe74c1d051f.tar.bz2 sequelpro-ba04386f728a8606c6a0c3f4b121cbe74c1d051f.zip |
* Fix an exception that could occur when trying to view a damaged table
(backport from 2f2aafb4f5675282a37d16dce96027706096df40)
Diffstat (limited to 'Source/SPTableData.m')
-rw-r--r-- | Source/SPTableData.m | 13 |
1 files changed, 12 insertions, 1 deletions
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]] + ); + } } } |