Permalink
Browse files

Some changes suggested in PR #2606 to improve MySQL 5.8 handling

  • Loading branch information...
dmoagx committed Nov 1, 2016
1 parent ee5e4db commit f77f8715cf1bcc8811804008fc5d3ac964988ce1
Showing with 14 additions and 8 deletions.
  1. +4 −4 Source/SPDatabaseDocument.m
  2. +1 −1 Source/SPExtendedTableInfo.m
  3. +3 −1 Source/SPTableData.m
  4. +5 −2 Source/SPTableInfo.m
  5. +1 −0 Source/SPTablesList.m
@@ -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();
@@ -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";
}
@@ -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 {
View
@@ -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;
}
View
@@ -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]) {
View
@@ -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]];

1 comment on commit f77f871

@miraclebg

This comment has been minimized.

Show comment
Hide comment
@miraclebg

miraclebg Nov 1, 2016

Cool, thanks!

Cool, thanks!

Please sign in to comment.