Skip to content

Commit

Permalink
Merge pull request #84 from gboudreau/issue-79-mariadb-crash-db-with-…
Browse files Browse the repository at this point in the history
…views

Bugfix: don't crash when Comment column is not last in the SHOW TABLE STATUS result
  • Loading branch information
gboudreau committed Jun 23, 2020
2 parents ebd3b53 + fd3d983 commit 6fe9bd1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Source/SPTablesList.m
Expand Up @@ -206,32 +206,32 @@ - (IBAction)updateTables:(nullable id)sender
// views; on MySQL versions >= 5.0.02 select the "full" list to also select the table type column.
// theResult = [mySQLConnection queryString:@"SHOW /*!50002 FULL*/ TABLES"];
theResult = [mySQLConnection queryString:@"SHOW TABLE STATUS"];
[theResult setDefaultRowReturnType:SPMySQLResultRowAsArray];
[theResult setDefaultRowReturnType:SPMySQLResultRowAsDictionary];
[theResult setReturnDataAsStrings:YES]; // TODO: workaround for bug #2700 (#2699)
if ([theResult numberOfFields] == 1) {
for (NSArray *eachRow in theResult) {
[tables addObject:[eachRow objectAtIndex:0]];
[tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeTable]];
}
} else {
for (NSArray *eachRow in theResult) {
for (NSDictionary *eachRow in theResult) {

// Due to encoding problems it can be the case that [resultRow objectAtIndex:0]
// return NSNull, thus catch that case for safety reasons
id tableName = [eachRow objectAtIndex:0];
id tableName = [eachRow objectForKey:@"Name"];
if ([tableName isNSNull]) {
tableName = @"...";
}
[tables addObject:tableName];

// comments is usefull
id tableComment = [eachRow lastObject];
id tableComment = [eachRow objectForKey:@"Comment"];
if ([tableComment isNSNull]) {
tableComment = @"";
}
[tableComments setValue:tableComment forKey:tableName];

if ([[eachRow lastObject] isEqualToString:@"VIEW"] || [[eachRow objectAtIndex:1] isEqualToString:@"VIEW"]) {
if ([@"VIEW" isEqualToString:tableComment]) {
[tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeView]];
tableListContainsViews = YES;
} else {
Expand Down

0 comments on commit 6fe9bd1

Please sign in to comment.