diff options
author | rowanbeentje <rowan@beent.je> | 2013-01-21 00:51:01 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2013-01-21 00:51:01 +0000 |
commit | fb74197b3affc05405439458d01e2f45eec47816 (patch) | |
tree | c0963a1b3aeed9d01b27e058e396670fd4c97f62 /Source/SPTableContent.m | |
parent | a192312d3060c37c9451ac05e1a939293db5b941 (diff) | |
download | sequelpro-fb74197b3affc05405439458d01e2f45eec47816.tar.gz sequelpro-fb74197b3affc05405439458d01e2f45eec47816.tar.bz2 sequelpro-fb74197b3affc05405439458d01e2f45eec47816.zip |
- Fix a problem where the row count for InnoDB would not be displayed as an accurate value, whatever the Preferences setting, if the Content table was not selected
- Clean up code slightly
- Remove an unneccessary query being used for the table information view, speeding up display slightly
Diffstat (limited to 'Source/SPTableContent.m')
-rw-r--r-- | Source/SPTableContent.m | 61 |
1 files changed, 16 insertions, 45 deletions
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 71657916..94e86694 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -4063,45 +4063,24 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper [[[tableDocumentInstance valueForKey:@"extendedTableInfoInstance"] onMainThread] loadTable:selectedTable]; #endif - // Otherwise, if the table status value is accurate, use it - } else if ([[tableDataInstance statusValueForKey:@"RowsCountAccurate"] boolValue]) { - maxNumRows = [[tableDataInstance statusValueForKey:@"Rows"] integerValue]; - maxNumRowsIsEstimate = NO; - checkStatusCount = YES; + } else { - // Choose whether to display an estimate, or to fetch the correct row count, based on prefs - } else if ( -#ifndef SP_REFACTOR - [[prefs objectForKey:SPTableRowCountQueryLevel] integerValue] == SPRowCountFetchAlways - || ([[prefs objectForKey:SPTableRowCountQueryLevel] integerValue] == SPRowCountFetchIfCheap - && -#endif - [tableDataInstance statusValueForKey:@"Data_length"] - && -#ifndef SP_REFACTOR - [[prefs objectForKey:SPTableRowCountCheapSizeBoundary] integerValue] -#else - 5242880 -#endif - > [[tableDataInstance statusValueForKey:@"Data_length"] integerValue]) -#ifndef SP_REFACTOR - ) -#endif - { - maxNumRows = [self fetchNumberOfRows]; - maxNumRowsIsEstimate = NO; - [tableDataInstance setStatusValue:[NSString stringWithFormat:@"%ld", (long)maxNumRows] forKey:@"Rows"]; - [tableDataInstance setStatusValue:@"y" forKey:@"RowsCountAccurate"]; -#ifndef SP_REFACTOR - [[tableInfoInstance onMainThread] tableChanged:nil]; -#endif - [[[tableDocumentInstance valueForKey:@"extendedTableInfoInstance"] onMainThread] loadTable:selectedTable]; + // Trigger an update via the SPTableData instance if preferences require it, and if + // the state is not already accurate + [tableDataInstance updateAccurateNumberOfRowsForCurrentTableForcingUpdate:NO]; - // Use the estimate count - } else { - maxNumRows = [[tableDataInstance statusValueForKey:@"Rows"] integerValue]; - maxNumRowsIsEstimate = YES; - checkStatusCount = YES; + // If the state is now accurate, use it + if ([[tableDataInstance statusValueForKey:@"RowsCountAccurate"] boolValue]) { + maxNumRows = [[tableDataInstance statusValueForKey:@"Rows"] integerValue]; + maxNumRowsIsEstimate = NO; + checkStatusCount = YES; + + // Otherwise, use the estimate count + } else { + maxNumRows = [[tableDataInstance statusValueForKey:@"Rows"] integerValue]; + maxNumRowsIsEstimate = YES; + checkStatusCount = YES; + } } // Check whether the estimated count requires updating, ie if the retrieved count exceeds it @@ -4136,14 +4115,6 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper } /** - * Fetches the number of rows in the selected table using a "SELECT COUNT(1)" query and return it - */ -- (NSInteger)fetchNumberOfRows -{ - return [[mySQLConnection getFirstFieldFromQuery:[NSString stringWithFormat:@"SELECT COUNT(1) FROM %@", [selectedTable backtickQuotedString]]] integerValue]; -} - -/** * Autosize all columns based on their content. * Should be called on the main thread. */ |