aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStuart Connolly <stuart02@gmail.com>2017-01-13 22:35:30 +0000
committerStuart Connolly <stuart02@gmail.com>2017-01-13 22:35:30 +0000
commit6b669dd486779a3a4f4978c4cf7286939ad94bbf (patch)
treedcf030b0971ae75e1bef185824becfa627fee878
parent5626b75b597281f9ecc0ab1e5d12052604ccb867 (diff)
parent164af9b85c6bf890aa0c7631538827bec1741e08 (diff)
downloadsequelpro-6b669dd486779a3a4f4978c4cf7286939ad94bbf.tar.gz
sequelpro-6b669dd486779a3a4f4978c4cf7286939ad94bbf.tar.bz2
sequelpro-6b669dd486779a3a4f4978c4cf7286939ad94bbf.zip
Merge branch 'master' of github.com:sequelpro/sequelpro
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Max Packet Size.m21
1 files changed, 11 insertions, 10 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Max Packet Size.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Max Packet Size.m
index dc453624..08ed03cf 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Max Packet Size.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Max Packet Size.m
@@ -97,13 +97,15 @@
*/
- (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 @@
[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;
}
/**