diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-06-15 19:37:25 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-06-15 19:37:25 +0000 |
commit | 95f796e8c75aeb13f4e1190d9ec08feecc35aba6 (patch) | |
tree | d93cc99bcc1ed043c313dcc5188adfe252c1e82f /Source/CMMCPConnection.m | |
parent | 6f267c8d8f6c12663e16d30f4cd4a1a6677fccd5 (diff) | |
download | sequelpro-95f796e8c75aeb13f4e1190d9ec08feecc35aba6.tar.gz sequelpro-95f796e8c75aeb13f4e1190d9ec08feecc35aba6.tar.bz2 sequelpro-95f796e8c75aeb13f4e1190d9ec08feecc35aba6.zip |
• different log message for changing max_allowed_packet for increasing it and for resetting it (a bit more transparent info)
- now also check the delegate if queryGaveError: method is implemented
• while adding/updating a row to the db Table Content's pane now indicates that process better via spinning wheel
• after TRUNCATE TABLE reload that table content
Diffstat (limited to 'Source/CMMCPConnection.m')
-rw-r--r-- | Source/CMMCPConnection.m | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/Source/CMMCPConnection.m b/Source/CMMCPConnection.m index ca86fbd7..8b256cc4 100644 --- a/Source/CMMCPConnection.m +++ b/Source/CMMCPConnection.m @@ -655,14 +655,14 @@ static void forcePingTimeout(int signalNumber); */ - (CMMCPResult *)queryString:(NSString *) query usingEncoding:(NSStringEncoding) encoding { - CMMCPResult *theResult = nil; - NSDate *queryStartDate; - const char *theCQuery; - int queryResultCode; - int currentMaxAllowedPacket = -1; - unsigned int queryErrorID = 0; - NSString *queryErrorMessage; - unsigned long threadid = mConnection->thread_id; + CMMCPResult *theResult = nil; + NSDate *queryStartDate; + NSString *queryErrorMessage; + const char *theCQuery; + int queryResultCode; + int currentMaxAllowedPacket = -1; + unsigned int queryErrorID = 0; + unsigned long threadid = mConnection->thread_id; // If no connection is present, return nil. if (!mConnected) return nil; @@ -693,10 +693,11 @@ static void forcePingTimeout(int signalNumber); if (![self checkConnection]) return nil; threadid = mConnection->thread_id; - // Try to increase max_allowed_packet for error 2006 BEFORE check connection + // Try to increase max_allowed_packet for error 2006 if user + // has SUPER privileges if(isMaxAllowedPacketEditable && queryResultCode == 1 && queryErrorID == 2006) { currentMaxAllowedPacket = [self getMaxAllowedPacket]; - [self setMaxAllowedPacketTo:strlen(theCQuery)+1024]; + [self setMaxAllowedPacketTo:strlen(theCQuery)+1024 resetSize:NO]; [self reconnect]; } @@ -721,7 +722,7 @@ static void forcePingTimeout(int signalNumber); // If max_allowed_packet was changed, reset it to default if(currentMaxAllowedPacket > -1) - [self setMaxAllowedPacketTo:currentMaxAllowedPacket]; + [self setMaxAllowedPacketTo:currentMaxAllowedPacket resetSize:YES]; // If an error occurred, inform the delegate if (0 != queryResultCode && delegate && [delegate respondsToSelector:@selector(queryGaveError:)]) { @@ -1070,13 +1071,18 @@ static void forcePingTimeout(int signalNumber) * if the maximal size was reached (e.g. set it to 4GB it'll return 1GB up to now). * If something failed it return -1; */ -- (int) setMaxAllowedPacketTo:(int)newSize +- (int) setMaxAllowedPacketTo:(int)newSize resetSize:(BOOL)reset { if(![self isMaxAllowedPacketEditable] || newSize < 1024) return [self getMaxAllowedPacket]; mysql_query(mConnection, [[NSString stringWithFormat:@"SET GLOBAL max_allowed_packet = %d", newSize] UTF8String]); - // Inform the user via a log entry about that change - [delegate queryGaveError:[NSString stringWithFormat:@"Query too large; max_allowed_packet temporarily set to %d for the current session to allow query to succeed", newSize]]; + // Inform the user via a log entry about that change according to reset value + if(delegate && [delegate respondsToSelector:@selector(queryGaveError:)]) + if(reset) + [delegate queryGaveError:[NSString stringWithFormat:@"max_allowed_packet was reset to %d for new session", newSize]]; + else + [delegate queryGaveError:[NSString stringWithFormat:@"Query too large; max_allowed_packet temporarily set to %d for the current session to allow query to succeed", newSize]]; + return [self getMaxAllowedPacket]; } |