aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMMCPConnection.h4
-rw-r--r--Source/CMMCPConnection.m34
-rw-r--r--Source/CustomQuery.m8
-rw-r--r--Source/SPQueryConsole.h2
-rw-r--r--Source/SPQueryConsole.m14
-rw-r--r--Source/SPStringAdditions.h2
-rw-r--r--Source/SPStringAdditions.m7
-rw-r--r--Source/TableDocument.m8
8 files changed, 49 insertions, 30 deletions
diff --git a/Source/CMMCPConnection.h b/Source/CMMCPConnection.h
index f0505956..6d0b0811 100644
--- a/Source/CMMCPConnection.h
+++ b/Source/CMMCPConnection.h
@@ -59,7 +59,7 @@
BOOL useKeepAlive;
float keepAliveInterval;
- float lastQueryExecutionTime;
+ int lastQueryExecutionTime;
NSString *lastQueryErrorMessage;
unsigned int lastQueryErrorId;
my_ulonglong lastQueryAffectedRows;
@@ -75,6 +75,8 @@
BOOL delegateResponseToWillQueryString;
+ IMP willQueryStringPtr;
+
}
- (id) init;
diff --git a/Source/CMMCPConnection.m b/Source/CMMCPConnection.m
index 7dc8804f..68056ba1 100644
--- a/Source/CMMCPConnection.m
+++ b/Source/CMMCPConnection.m
@@ -665,15 +665,6 @@ static void forcePingTimeout(int signalNumber);
/*
- * Override the standard queryString: method to default to the connection encoding, as before,
- * before pssing on to queryString: usingEncoding:.
- */
-- (CMMCPResult *)queryString:(NSString *) query
-{
- return [self queryString:query usingEncoding:mEncoding];
-}
-
-/*
* Via that method the current mySQLConnection will be informed
* which object sent the current query.
*/
@@ -690,6 +681,15 @@ static void forcePingTimeout(int signalNumber);
}
+/*
+ * Override the standard queryString: method to default to the connection encoding, as before,
+ * before pssing on to queryString: usingEncoding:.
+ */
+- (CMMCPResult *)queryString:(NSString *) query
+{
+ return [self queryString:query usingEncoding:mEncoding];
+}
+
/*
* Modified version of queryString to be used in Sequel Pro.
@@ -700,7 +700,7 @@ static void forcePingTimeout(int signalNumber);
- (CMMCPResult *)queryString:(NSString *) query usingEncoding:(NSStringEncoding) encoding
{
CMMCPResult *theResult = nil;
- float queryStartTime;
+ int queryStartTime;
const char *theCQuery;
unsigned long theCQueryLength;
int queryResultCode;
@@ -724,12 +724,11 @@ static void forcePingTimeout(int signalNumber);
[self stopKeepAliveTimer];
- queryStartTime = clock();
+ // queryStartTime = clock();
// Inform the delegate about the query
- if (delegateResponseToWillQueryString) {
- [delegate willQueryString:query];
- }
+ if (delegateResponseToWillQueryString)
+ (void)(NSString*)(*willQueryStringPtr)(delegate, @selector(willQueryString:), query);
// Derive the query string in the correct encoding
theCQuery = [self cStringFromString:query usingEncoding:encoding];
@@ -782,8 +781,9 @@ static void forcePingTimeout(int signalNumber);
// Run (or re-run) the query, timing the execution time of the query - note
// that this time will include network lag.
+ queryStartTime = clock();
queryResultCode = mysql_real_query(mConnection, theCQuery, theCQueryLength);
- lastQueryExecutionTime = (clock() - queryStartTime)/CLOCKS_PER_SEC;
+ lastQueryExecutionTime = (clock() - queryStartTime);
// On success, capture the results
if (0 == queryResultCode) {
@@ -932,6 +932,7 @@ static void forcePingTimeout(int signalNumber);
{
delegate = object;
delegateResponseToWillQueryString = (delegate && [delegate respondsToSelector:@selector(willQueryString:)]);
+ willQueryStringPtr = [delegate methodForSelector:@selector(willQueryString:)];
}
/* Getting the currently used time zone (in communication with the DB server). */
@@ -1134,9 +1135,6 @@ static void forcePingTimeout(int signalNumber)
- (const char *) cStringFromString:(NSString *) theString usingEncoding:(NSStringEncoding) encoding
{
- if(encoding == NSUTF8StringEncoding)
- return [theString UTF8String];
-
NSMutableData *theData;
if (! theString) {
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index 495f6b20..b59fe084 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -585,26 +585,26 @@
if (totalAffectedRows==1) {
[affectedRowsText setStringValue:[NSString stringWithFormat:NSLocalizedString(@"1 row affected in total, by %i queries taking %@", @"text showing one row has been affected by multiple queries"),
totalQueriesRun,
- [NSString stringForTimeInterval:executionTime]
+ [NSString stringForTimeInterval:executionTime intervalInClocks:YES]
]];
} else {
[affectedRowsText setStringValue:[NSString stringWithFormat:NSLocalizedString(@"%i rows affected in total, by %i queries taking %@", @"text showing how many rows have been affected by multiple queries"),
totalAffectedRows,
totalQueriesRun,
- [NSString stringForTimeInterval:executionTime]
+ [NSString stringForTimeInterval:executionTime intervalInClocks:YES]
]];
}
} else {
if (totalAffectedRows==1) {
[affectedRowsText setStringValue:[NSString stringWithFormat:NSLocalizedString(@"1 row affected, taking %@", @"text showing one row has been affected by a single query"),
- [NSString stringForTimeInterval:executionTime]
+ [NSString stringForTimeInterval:executionTime intervalInClocks:YES]
]];
} else {
[affectedRowsText setStringValue:[NSString stringWithFormat:NSLocalizedString(@"%i rows affected, taking %@", @"text showing how many rows have been affected by a single query"),
totalAffectedRows,
- [NSString stringForTimeInterval:executionTime]
+ [NSString stringForTimeInterval:executionTime intervalInClocks:YES]
]];
}
diff --git a/Source/SPQueryConsole.h b/Source/SPQueryConsole.h
index 281f2d2e..85ea7cbe 100644
--- a/Source/SPQueryConsole.h
+++ b/Source/SPQueryConsole.h
@@ -40,6 +40,7 @@
BOOL showSelectStatementsAreDisabled;
BOOL showHelpStatementsAreDisabled;
BOOL filterIsActive;
+
NSMutableString *activeFilterString;
}
@@ -54,6 +55,7 @@
- (IBAction)toggleShowSelectShowStatements:(id)sender;
- (IBAction)toggleShowHelpStatements:(id)sender;
+- (void)updateEntries;
- (void)showMessageInConsole:(NSString *)message;
- (void)showErrorInConsole:(NSString *)error;
diff --git a/Source/SPQueryConsole.m b/Source/SPQueryConsole.m
index a7c7263d..dab9a9a0 100644
--- a/Source/SPQueryConsole.m
+++ b/Source/SPQueryConsole.m
@@ -365,6 +365,12 @@ static SPQueryConsole *sharedQueryConsole = nil;
return [[self window] validateMenuItem:menuItem];
}
+- (void)updateEntries
+{
+ [consoleTableView reloadData];
+ [consoleTableView scrollRowToVisible:([messagesVisibleSet count] - 1)];
+}
+
/**
* Standard dealloc.
*/
@@ -494,9 +500,11 @@ static SPQueryConsole *sharedQueryConsole = nil;
[clearConsoleButton setEnabled:YES];
}
- // Reload the table and scroll to the new message
- [consoleTableView reloadData];
- [consoleTableView scrollRowToVisible:([messagesVisibleSet count] - 1)];
+ // Reload the table and scroll to the new message if it's visible (for speed)
+ if ( [[self window] isVisible] ) {
+ [consoleTableView reloadData];
+ [consoleTableView scrollRowToVisible:([messagesVisibleSet count] - 1)];
+ }
}
/**
diff --git a/Source/SPStringAdditions.h b/Source/SPStringAdditions.h
index 8e50bbd4..318e8d4d 100644
--- a/Source/SPStringAdditions.h
+++ b/Source/SPStringAdditions.h
@@ -28,7 +28,7 @@
@interface NSString (SPStringAdditions)
+ (NSString *)stringForByteSize:(int)byteSize;
-+ (NSString *)stringForTimeInterval:(float)timeInterval;
++ (NSString *)stringForTimeInterval:(float)timeInterval intervalInClocks:(BOOL)inClocks;
- (NSString *)backtickQuotedString;
- (NSArray *)lineRangesForRange:(NSRange)aRange;
diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m
index da4380ff..4b74e905 100644
--- a/Source/SPStringAdditions.m
+++ b/Source/SPStringAdditions.m
@@ -74,10 +74,13 @@
//
// Returns a human readable version string of the supplied time interval.
// -------------------------------------------------------------------------------
-+ (NSString *)stringForTimeInterval:(float)timeInterval
++ (NSString *)stringForTimeInterval:(float)timeInterval intervalInClocks:(BOOL)inClocks
{
NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
-
+
+ if(inClocks)
+ timeInterval = timeInterval/CLOCKS_PER_SEC;
+
[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
if (timeInterval < 0.001) {
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index e638ffd9..270ebe5b 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -985,7 +985,13 @@ NSString *TableDocumentFavoritesControllerSelectionIndexDidChange = @"TableDocum
- (void)toggleConsole:(id)sender
{
BOOL isConsoleVisible = [[[SPQueryConsole sharedQueryConsole] window] isVisible];
-
+
+ // If the Console window is not visible data are not reloaded (for speed).
+ // Due to that update list if user opens the Console window.
+ if(!isConsoleVisible) {
+ [[SPQueryConsole sharedQueryConsole] updateEntries];
+ }
+
// Show or hide the console
[[[SPQueryConsole sharedQueryConsole] window] setIsVisible:(!isConsoleVisible)];