Skip to content

Commit bd75d9a

Browse files
committed
Restrict some variables to their actual usage scope
1 parent a13b067 commit bd75d9a

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

Source/SPSQLExporter.m

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,13 @@ - (void)exportOperation
9090
[sqlTableDataInstance setConnection:connection];
9191

9292
SPMySQLResult *queryResult;
93-
SPMySQLStreamingResult *streamingResult;
9493

95-
NSArray *row;
9694
NSString *tableName;
9795
NSDictionary *tableDetails;
98-
BOOL *useRawDataForColumnAtIndex, *useRawHexDataForColumnAtIndex;
9996
SPTableType tableType = SPTableTypeTable;
10097

10198
id createTableSyntax = nil;
102-
NSUInteger j, t, s, rowCount, queryLength, lastProgressValue, cleanAutoReleasePool = NO;
99+
NSUInteger j, s;
103100

104101
BOOL sqlOutputIncludeStructure;
105102
BOOL sqlOutputIncludeContent;
@@ -232,7 +229,7 @@ - (void)exportOperation
232229
// Inform the delegate that we are about to start fetcihing data for the current table
233230
[delegate performSelectorOnMainThread:@selector(sqlExportProcessWillBeginFetchingData:) withObject:self waitUntilDone:NO];
234231

235-
lastProgressValue = 0;
232+
NSUInteger lastProgressValue = 0;
236233

237234
// Add the name of table
238235
[self writeString:[NSString stringWithFormat:@"# %@ %@\n# ------------------------------------------------------------\n\n", NSLocalizedString(@"Dump of table", @"sql export dump of table label"), tableName]];
@@ -297,8 +294,8 @@ - (void)exportOperation
297294
NSMutableArray *rawColumnNames = [NSMutableArray arrayWithCapacity:colCount];
298295
NSMutableArray *queryColumnDetails = [NSMutableArray arrayWithCapacity:colCount];
299296

300-
useRawDataForColumnAtIndex = calloc(colCount, sizeof(BOOL));
301-
useRawHexDataForColumnAtIndex = calloc(colCount, sizeof(BOOL));
297+
BOOL *useRawDataForColumnAtIndex = calloc(colCount, sizeof(BOOL));
298+
BOOL *useRawHexDataForColumnAtIndex = calloc(colCount, sizeof(BOOL));
302299

303300
// Determine whether raw data can be used for each column during processing - safe numbers and hex-encoded data.
304301
for (j = 0; j < colCount; j++)
@@ -347,17 +344,17 @@ - (void)exportOperation
347344
continue;
348345
}
349346

350-
rowCount = [NSArrayObjectAtIndex(rowArray, 0) integerValue];
347+
NSUInteger rowCount = [NSArrayObjectAtIndex(rowArray, 0) integerValue];
351348

352349
if (rowCount) {
353350

354351
// Set up a result set in streaming mode
355-
streamingResult = [[connection streamingQueryString:[NSString stringWithFormat:@"SELECT %@ FROM %@", [queryColumnDetails componentsJoinedByString:@", "], [tableName backtickQuotedString]] useLowMemoryBlockingStreaming:([self exportUsingLowMemoryBlockingStreaming])] retain];
352+
SPMySQLStreamingResult *streamingResult = [[connection streamingQueryString:[NSString stringWithFormat:@"SELECT %@ FROM %@", [queryColumnDetails componentsJoinedByString:@", "], [tableName backtickQuotedString]] useLowMemoryBlockingStreaming:([self exportUsingLowMemoryBlockingStreaming])] retain];
356353

357354
// Inform the delegate that we are about to start writing data for the current table
358355
[delegate performSelectorOnMainThread:@selector(sqlExportProcessWillBeginWritingData:) withObject:self waitUntilDone:NO];
359356

360-
queryLength = 0;
357+
NSUInteger queryLength = 0;
361358

362359
// Lock the table for writing and disable keys if supported
363360
[metaString setString:@""];
@@ -371,13 +368,15 @@ - (void)exportOperation
371368
// Iterate through the rows to construct a VALUES group for each
372369
NSUInteger rowsWrittenForTable = 0;
373370
NSUInteger rowsWrittenForCurrentStmt = 0;
371+
BOOL cleanAutoReleasePool = NO;
374372

375373
NSAutoreleasePool *sqlExportPool = [[NSAutoreleasePool alloc] init];
376374

377375
// Inform the delegate that we are about to start writing the data to disk
378376
[delegate performSelectorOnMainThread:@selector(sqlExportProcessWillBeginWritingData:) withObject:self waitUntilDone:NO];
379377

380-
while ((row = [streamingResult getRowAsArray]))
378+
NSArray *row;
379+
while ((row = [streamingResult getRowAsArray]))
381380
{
382381
// Check for cancellation flag
383382
if ([self isCancelled]) {
@@ -428,7 +427,7 @@ - (void)exportOperation
428427
[sqlString setString:@",\n\t("];
429428
}
430429

431-
for (t = 0; t < colCount; t++)
430+
for (NSUInteger t = 0; t < colCount; t++)
432431
{
433432
id object = NSArrayObjectAtIndex(row, t);
434433

0 commit comments

Comments
 (0)