aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableContent.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-01-30 01:13:30 +0000
committerrowanbeentje <rowan@beent.je>2010-01-30 01:13:30 +0000
commit414ac81a88a5d3da0f4b657769bd0ce6bd32fde8 (patch)
tree6b3a26564786151d8816109d1f348e003a85a72f /Source/TableContent.m
parent00401575e1f0f16f13d56402ec45368982692b6c (diff)
downloadsequelpro-414ac81a88a5d3da0f4b657769bd0ce6bd32fde8.tar.gz
sequelpro-414ac81a88a5d3da0f4b657769bd0ce6bd32fde8.tar.bz2
sequelpro-414ac81a88a5d3da0f4b657769bd0ce6bd32fde8.zip
- Bugfix: when the number of table columns for a content result set no longer matched the internal table representation, table storage exceptions would occur. Additional checks are now made against the column count; if a content result set is retrieved with an unexpected number of columns, the result set is discarded and a full table refresh is triggered to restore the state.
Diffstat (limited to 'Source/TableContent.m')
-rw-r--r--Source/TableContent.m21
1 files changed, 18 insertions, 3 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m
index f5e1feb4..c0814670 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -607,13 +607,25 @@
[tableContentView performSelectorOnMainThread:@selector(noteNumberOfRowsChanged) withObject:nil waitUntilDone:YES];
[self setUsedQuery:queryString];
streamingResult = [mySQLConnection streamingQueryString:queryString];
- if (streamingResult) {
+
+ // Ensure the number of columns are unchanged; if the column count has changed, abort the load
+ // and queue a full table reload.
+ BOOL fullTableReloadRequired = NO;
+ if (streamingResult && [dataColumns count] != [streamingResult numOfFields]) {
+ [tableDocumentInstance disableTaskCancellation];
+ [mySQLConnection cancelCurrentQuery];
+ [streamingResult cancelResultLoad];
+ fullTableReloadRequired = YES;
+ }
+
+ // Process the result into the data store
+ if (!fullTableReloadRequired && streamingResult) {
[self processResultIntoDataStorage:streamingResult approximateRowCount:rowsToLoad];
[streamingResult release];
}
// If the result is empty, and a late page is selected, reset the page
- if ([prefs boolForKey:SPLimitResults] && queryStringBeforeLimit && !tableRowsCount && ![mySQLConnection queryCancelled]) {
+ if (!fullTableReloadRequired && [prefs boolForKey:SPLimitResults] && queryStringBeforeLimit && !tableRowsCount && ![mySQLConnection queryCancelled]) {
contentPage = 1;
queryString = [NSMutableString stringWithFormat:@"%@ LIMIT 0,%ld", queryStringBeforeLimit, (long)[prefs integerForKey:SPLimitResultsValue]];
[self setUsedQuery:queryString];
@@ -652,6 +664,9 @@
// Notify listenters that the query has finished
[[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance];
+
+ // Trigger a full reload if required
+ if (fullTableReloadRequired) [self reloadTable:self];
}
/*
@@ -662,7 +677,7 @@
NSArray *tempRow;
NSUInteger i;
NSUInteger dataColumnsCount = [dataColumns count];
- BOOL *columnBlobStatuses = malloc(dataColumnsCount * sizeof(BOOL));;
+ BOOL *columnBlobStatuses = malloc(dataColumnsCount * sizeof(BOOL));
// Set the column count on the data store
[tableValues setColumnCount:dataColumnsCount];