diff options
author | rowanbeentje <rowan@beent.je> | 2012-08-18 14:18:29 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2012-08-18 14:18:29 +0000 |
commit | eda4399be690cb325bb03d3195654e38ed061738 (patch) | |
tree | de1b9e4d6492ab0ab2446c0747b4db0539777e3c /Source/SPCustomQuery.m | |
parent | 70467916504f6052869dfdf618e5a677bd0cf366 (diff) | |
download | sequelpro-eda4399be690cb325bb03d3195654e38ed061738.tar.gz sequelpro-eda4399be690cb325bb03d3195654e38ed061738.tar.bz2 sequelpro-eda4399be690cb325bb03d3195654e38ed061738.zip |
Improve connection handling and recovery in general, and specifically to address Issue #877:
- On servers with very short timeouts set the wait_timeout for the session as well as the interactive_timeout to prevent the connection from dropping frequently
- Improve recovery from connection errors, correctly restoring the connection if appropriate and possible
- Allow reconnections to occur recursively by altering the internal tracking mechanism
- Fix some edge cases where the connection would remain locked incorrectly
- Improve error messaging for the "MySQL Server has gone away" network case
Diffstat (limited to 'Source/SPCustomQuery.m')
-rw-r--r-- | Source/SPCustomQuery.m | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index bc80d971..411527e3 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -685,6 +685,12 @@ errorString = NSLocalizedString(@"Query cancelled.", @"Query cancelled error"); } else { errorString = [mySQLConnection lastErrorMessage]; + + // If dealing with a "MySQL server has gone away" error, explain the situation. + // Error 2006 is CR_SERVER_GONE_ERROR, which means the query write couldn't complete. + if ([mySQLConnection lastErrorID] == 2006) { + errorString = [NSString stringWithFormat:@"%@.\n\n%@", errorString, NSLocalizedString(@"(This usually indicates that the connection has been closed by the server after inactivity, but can also occur due to other conditions. The connection has been restored; please try again if the query is safe to re-run.)", @"Explanation for MySQL server has gone away error")]; + } } // If the query errored, append error to the error log for display at the end |