aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-05-01 22:20:29 +0000
committerrowanbeentje <rowan@beent.je>2012-05-01 22:20:29 +0000
commitdea294a90f9bf6017986f9c950991a7fc7c9645e (patch)
treeb317f3b272bcd854e80e8d999853ec84def7155e
parentf7164f1f962fb732ea38383150a3bc28a3ae8caf (diff)
downloadsequelpro-dea294a90f9bf6017986f9c950991a7fc7c9645e.tar.gz
sequelpro-dea294a90f9bf6017986f9c950991a7fc7c9645e.tar.bz2
sequelpro-dea294a90f9bf6017986f9c950991a7fc7c9645e.zip
- Fix a query made during a streaming query during CSV export of a table using low memory streaming, addressing Issue #1274
-rw-r--r--Source/SPCSVExporter.m60
1 files changed, 31 insertions, 29 deletions
diff --git a/Source/SPCSVExporter.m b/Source/SPCSVExporter.m
index aa5268c1..4bf6c651 100644
--- a/Source/SPCSVExporter.m
+++ b/Source/SPCSVExporter.m
@@ -118,7 +118,37 @@
[self setExportProcessIsRunning:YES];
lastProgressValue = 0;
-
+
+ // Before the streaming query is started, build an array of numeric columns if a table
+ // is being exported
+ if ([self csvTableName] && (![self csvDataArray])) {
+ NSDictionary *tableDetails = nil;
+
+ // Determine whether the supplied table is actually a table or a view via the CREATE TABLE command, and get the table details
+ SPMySQLResult *queryResult = [connection queryString:[NSString stringWithFormat:@"SHOW CREATE TABLE %@", [[self csvTableName] backtickQuotedString]]];
+ [queryResult setReturnDataAsStrings:YES];
+
+ if ([queryResult numberOfRows]) {
+ id object = [[queryResult getRowAsDictionary] objectForKey:@"Create View"];
+
+ tableDetails = [[NSDictionary alloc] initWithDictionary:(object) ? [[self csvTableData] informationForView:[self csvTableName]] : [[self csvTableData] informationForTable:[self csvTableName]]];
+ }
+
+ // Retrieve the table details via the data class, and use it to build an array containing column numeric status
+ for (NSDictionary *column in [tableDetails objectForKey:@"columns"])
+ {
+ NSString *tableColumnTypeGrouping = [column objectForKey:@"typegrouping"];
+
+ [tableColumnNumericStatus addObject:[NSNumber numberWithBool:
+ ([tableColumnTypeGrouping isEqualToString:@"bit"]
+ || [tableColumnTypeGrouping isEqualToString:@"integer"]
+ || [tableColumnTypeGrouping isEqualToString:@"float"])
+ ]];
+ }
+
+ [tableDetails release];
+ }
+
// Make a streaming request for the data if the data array isn't set
if ((![self csvDataArray]) && [self csvTableName]) {
totalRows = [[connection getFirstFieldFromQuery:[NSString stringWithFormat:@"SELECT COUNT(1) FROM %@", [[self csvTableName] backtickQuotedString]]] integerValue];
@@ -177,35 +207,7 @@
if ([self csvDataArray]) totalRows = [[self csvDataArray] count];
if (([self csvDataArray]) && (![self csvOutputFieldNames])) currentRowIndex++;
-
- if ([self csvTableName] && (![self csvDataArray])) {
-
- NSDictionary *tableDetails = nil;
-
- // Determine whether the supplied table is actually a table or a view via the CREATE TABLE command, and get the table details
- SPMySQLResult *queryResult = [connection queryString:[NSString stringWithFormat:@"SHOW CREATE TABLE %@", [[self csvTableName] backtickQuotedString]]];
- [queryResult setReturnDataAsStrings:YES];
-
- if ([queryResult numberOfRows]) {
- id object = [[queryResult getRowAsDictionary] objectForKey:@"Create View"];
-
- tableDetails = [[NSDictionary alloc] initWithDictionary:(object) ? [[self csvTableData] informationForView:[self csvTableName]] : [[self csvTableData] informationForTable:[self csvTableName]]];
- }
-
- // Retrieve the table details via the data class, and use it to build an array containing column numeric status
- for (NSDictionary *column in [tableDetails objectForKey:@"columns"])
- {
- NSString *tableColumnTypeGrouping = [column objectForKey:@"typegrouping"];
-
- [tableColumnNumericStatus addObject:[NSNumber numberWithBool:([tableColumnTypeGrouping isEqualToString:@"bit"] ||
- [tableColumnTypeGrouping isEqualToString:@"integer"] ||
- [tableColumnTypeGrouping isEqualToString:@"float"])]];
- }
-
- [tableDetails release];
- }
-
// Drop into the processing loop
NSAutoreleasePool *csvExportPool = [[NSAutoreleasePool alloc] init];