aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMMCPConnection.m12
1 files changed, 6 insertions, 6 deletions
diff --git a/Source/CMMCPConnection.m b/Source/CMMCPConnection.m
index 624ad6c3..db45a3d8 100644
--- a/Source/CMMCPConnection.m
+++ b/Source/CMMCPConnection.m
@@ -664,16 +664,16 @@ static void forcePingTimeout(int signalNumber);
// If there was an error, check whether it was a connection-related error
if (0 != queryResultCode && [CMMCPConnection isErrorNumberConnectionError:[self getLastErrorID]]) {
- // Check the connection and see if it can be restored. This triggers reconnects as necessary, and
- // should only return false if a disconnection has been requested - in which case return nil.
- if (![self checkConnection]) return nil;
-
- // Try to increase max_allowed_packet for error 2006
+ // Try to increase max_allowed_packet for error 2006 BEFORE check connection
if(isMaxAllowedPacketEditable && queryResultCode == 1 && [self getLastErrorID] == 2006) {
currentMaxAllowedPacket = [self getMaxAllowedPacket];
- [self setMaxAllowedPacketTo:strlen([self cStringFromString:query])+1024];
+ [self setMaxAllowedPacketTo:strlen(theCQuery)+1024];
}
+ // Check the connection and see if it can be restored. This triggers reconnects as necessary, and
+ // should only return false if a disconnection has been requested - in which case return nil.
+ if (![self checkConnection]) return nil;
+
// The connection has been restored - re-run the query
queryStartDate = [NSDate date];
queryResultCode = mysql_query(mConnection, theCQuery);