Skip to content

Commit

Permalink
Some changes suggested in PR #2606 to improve MySQL 5.8 handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoagx committed Nov 1, 2016
1 parent ee5e4db commit f77f871
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Source/SPDatabaseDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -5608,9 +5608,9 @@ - (void)handleSchemeCommand:(NSDictionary*)commandDict
}
NSError *err = nil;
[tableMetaData writeToFile:metaFileName
atomically:YES
encoding:NSUTF8StringEncoding
error:&err];
atomically:YES
encoding:NSUTF8StringEncoding
error:&err];
if(err != nil) {
NSLog(@"Error while writing “%@”", tableMetaData);
NSBeep();
Expand Down Expand Up @@ -5705,7 +5705,7 @@ - (void)handleSchemeCommand:(NSDictionary*)commandDict
}

if(userTerminated) {
[SPTooltip showWithObject:NSLocalizedString(@"URL scheme command was terminated by user", @"URL scheme command was terminated by user") atLocation:[NSApp mouseLocation]];
[SPTooltip showWithObject:NSLocalizedString(@"URL scheme command was terminated by user", @"URL scheme command was terminated by user") atLocation:[NSEvent mouseLocation]];
status = @"1";
}

Expand Down
2 changes: 1 addition & 1 deletion Source/SPExtendedTableInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ - (NSString *)_formatValueWithKey:(NSString *)key inDictionary:(NSDictionary *)i
{
NSString *value = [infoDict objectForKey:key];

if ([value isNSNull]) {
if (![value unboxNull]) { // (value == nil || value == [NSNull null])
value = @"";
}
else {
Expand Down
4 changes: 3 additions & 1 deletion Source/SPTableData.m
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,9 @@ - (BOOL) updateAccurateNumberOfRowsForCurrentTableForcingUpdate:(BOOL)alwaysUpda
#endif

if (rowCountLevel == SPRowCountFetchNever
|| (rowCountLevel == SPRowCountFetchIfCheap && [[self statusValueForKey:@"Data_length"] integerValue] >= rowCountCheapBoundary))
|| (rowCountLevel == SPRowCountFetchIfCheap
&& (![[self statusValueForKey:@"Data_length"] unboxNull] //this works as a nil check for both NSNull and nil.
|| [[self statusValueForKey:@"Data_length"] integerValue] >= rowCountCheapBoundary)))
{
return YES;
}
Expand Down
7 changes: 5 additions & 2 deletions Source/SPTableInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,11 @@ - (void)tableChanged:(NSNotification *)notification
[info addObject:[NSString stringWithFormat:[[tableStatus objectForKey:@"RowsCountAccurate"] boolValue] ? NSLocalizedString(@"rows: %@", @"Table Info Section : number of rows (exact value)") : NSLocalizedString(@"rows: ~%@", @"Table Info Section : number of rows (estimated value)"),
[numberFormatter stringFromNumber:[NSNumber numberWithLongLong:[[tableStatus objectForKey:@"Rows"] longLongValue]]]]];
}

[info addObject:[NSString stringWithFormat:NSLocalizedString(@"size: %@", @"Table Info Section : table size on disk"), [NSString stringForByteSize:[[tableStatus objectForKey:@"Data_length"] longLongValue]]]];

// Check for 'Data_Length' == NULL (see PR #2606)
if([[tableStatus objectForKey:@"Data_length"] unboxNull]) {
[info addObject:[NSString stringWithFormat:NSLocalizedString(@"size: %@", @"Table Info Section : table size on disk"), [NSString stringForByteSize:[[tableStatus objectForKey:@"Data_length"] longLongValue]]]];
}
NSString *tableEnc = [tableDataInstance tableEncoding];
NSString *tableColl = [tableStatus objectForKey:@"Collation"];
if([tableColl length]) {
Expand Down
1 change: 1 addition & 0 deletions Source/SPTablesList.m
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ - (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 setDefaultRowReturnType:SPMySQLResultRowAsArray];
[theResult setReturnDataAsStrings:YES]; // MySQL 5.8 (beta) seems to return Table_type as data (see PR #2606)
if ([theResult numberOfFields] == 1) {
for (NSArray *eachRow in theResult) {
[tables addObject:[eachRow objectAtIndex:0]];
Expand Down

1 comment on commit f77f871

@miraclebg
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks!

Please sign in to comment.