Skip to content
Permalink
Browse files

Merge branch 'master' of github.com:sequelpro/sequelpro

  • Loading branch information
stuconnolly committed Jan 13, 2017
2 parents 5626b75 + 164af9b commit 6b669dd486779a3a4f4978c4cf7286939ad94bbf
Showing with 11 additions and 10 deletions.
  1. +11 −10 Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Max Packet Size.m
@@ -97,13 +97,15 @@ @implementation SPMySQLConnection (Max_Packet_Size_Private_API)
*/
- (void)_updateMaxQuerySize
{

// Determine which query to run based on server version
NSString *packetQueryString;
NSUInteger resultCol;
if ([self serverMajorVersion] == 3) {
packetQueryString = @"SHOW VARIABLES LIKE 'max_allowed_packet'";
resultCol = 1;
} else {
packetQueryString = @"SELECT @@global.max_allowed_packet";
resultCol = 0;
}

// Make a standard query to the server to retrieve the information
@@ -115,17 +117,16 @@ - (void)_updateMaxQuerySize
[result setReturnDataAsStrings:YES];

// Get the maximum size string
NSString *maxQuerySizeString = nil;
if ([self serverMajorVersion] == 3) {
maxQuerySizeString = [[result getRowAsArray] objectAtIndex:1];
} else {
maxQuerySizeString = [[result getRowAsArray] objectAtIndex:0];
}
NSString *maxQuerySizeString = [[result getRowAsArray] objectAtIndex:resultCol];

// If a valid size was returned, update the instance variable
if (maxQuerySizeString) {
maxQuerySize = (NSUInteger)[maxQuerySizeString integerValue];
NSInteger _maxQuerySize = maxQuerySizeString ? [maxQuerySizeString integerValue] : 0;
//see #2653
if(_maxQuerySize < 34) { // the max_allowed_packet query above has at least 34 bytes and succeeded, so any value less than that would be nonsense
NSLog(@"Query for max_allowed_packet returned invalid or implausible value: %ld (raw value: %@) (on %@)", _maxQuerySize, maxQuerySizeString, [self serverVersionString]);
return;
}
// If a valid size was returned, update the instance variable
maxQuerySize = (NSUInteger)_maxQuerySize;
}

/**

0 comments on commit 6b669dd

Please sign in to comment.
You can’t perform that action at this time.