diff options
author | rowanbeentje <rowan@beent.je> | 2009-03-19 23:44:06 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2009-03-19 23:44:06 +0000 |
commit | ddf7d62d20614111acdd420075ef762d6deaa8d7 (patch) | |
tree | cf5ce70dde9c25d1b21da1cded5cee9f3e562704 /Source/CMMCPConnection.m | |
parent | 4a8d0f731bbb03b9ace041d421800e5c6470326a (diff) | |
download | sequelpro-ddf7d62d20614111acdd420075ef762d6deaa8d7.tar.gz sequelpro-ddf7d62d20614111acdd420075ef762d6deaa8d7.tar.bz2 sequelpro-ddf7d62d20614111acdd420075ef762d6deaa8d7.zip |
SPSQLParser changes:
- Use method caches for oft-called functions, and support caching of chunks of the underlying string for string walking, resulting in an overall 1.3x-1.4x parsing speedup.
- Improve handling of multi-character comment starts (eg / or -) at the very end of strings
- When running splitString... methods return even empty strings for consistency.
- Update TableDump and TableData to match new usage
SPStringAddition changes:
- Add a formatter for time intervals.
CMMCPConnection changes:
- Add support for timing queries
CustomQuery and nib changes:
- Change the "Run Queries" button to "Run All".
- Add a "Run Current" button, which runs the query the text caret is currently positioned inside; if text is actually selected, this changes to "Run Selection". This addresses Issue #43.
- Amend the "rows affected" string to better reflect the actual number of rows altered by several queries, show the query count if > 1, and display the overall execution time of the queries. This addresses Issue #142.
- No longer execute blank strings as part of the custom query, preventing errors.
Diffstat (limited to 'Source/CMMCPConnection.m')
-rw-r--r-- | Source/CMMCPConnection.m | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/Source/CMMCPConnection.m b/Source/CMMCPConnection.m index 109ab280..64315ff6 100644 --- a/Source/CMMCPConnection.m +++ b/Source/CMMCPConnection.m @@ -68,6 +68,7 @@ static void forcePingTimeout(int signalNumber); connectionSocket = nil; keepAliveTimer = nil; lastKeepAliveSuccess = nil; + lastQueryExecutionTime = 0; if (![NSBundle loadNibNamed:@"ConnectionErrorDialog" owner:self]) { NSLog(@"Connection error dialog could not be loaded; connection failure handling will not function correctly."); } @@ -345,6 +346,7 @@ static void forcePingTimeout(int signalNumber); CMMCPResult *theResult; const char *theCQuery = [self cStringFromString:query]; int theQueryCode; + NSDate *queryStartDate; // If no connection is present, return nil. if (!mConnected) return nil; @@ -360,10 +362,16 @@ static void forcePingTimeout(int signalNumber); [delegate willQueryString:query]; } - if (0 == (theQueryCode = mysql_query(mConnection, theCQuery))) { + // Run the query, storing run time (note this will include some network and overhead) + queryStartDate = [NSDate date]; + theQueryCode = mysql_query(mConnection, theCQuery); + lastQueryExecutionTime = [[NSDate date] timeIntervalSinceDate:queryStartDate]; + + // Retrieve the result or error appropriately. + if (0 == theQueryCode) { if (mysql_field_count(mConnection) != 0) { - // Use CMMCPResult instad of MCPResult + // Use CMMCPResult instead of MCPResult theResult = [[CMMCPResult alloc] initWithMySQLPtr:mConnection encoding:mEncoding timeZone:mTimeZone]; } else { return nil; @@ -385,6 +393,16 @@ static void forcePingTimeout(int signalNumber); /* + * Return the time taken to execute the last query. This should be close to the time it took + * the server to run the query, but will include network lag and some client library overhead. + */ +- (float) lastQueryExecutionTime +{ + return lastQueryExecutionTime; +} + + +/* * Modified version of selectDB to be used in Sequel Pro. * Checks the connection exists, and handles keepalive, otherwise calling the parent implementation. */ |