From 65778099b6b5084bf9d2e7a6bbefa42b6f303f68 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Wed, 2 Dec 2009 00:27:00 +0000 Subject: - Fix display of the bottom row in the query console by reloading table data *after* the scroll - Quote timestamp and connection when copying rows from the table console - Reduce queries when fetching database collations or encodings by removing an additional check and adapting logic to match --- Source/SPDatabaseData.m | 41 +++++++++++++++-------------------------- Source/SPQueryController.m | 10 +++++++--- 2 files changed, 22 insertions(+), 29 deletions(-) (limited to 'Source') diff --git a/Source/SPDatabaseData.m b/Source/SPDatabaseData.m index 895700e2..98fedd4f 100644 --- a/Source/SPDatabaseData.m +++ b/Source/SPDatabaseData.m @@ -233,15 +233,11 @@ const CHAR_SETS charsets[] = { if ([collations count] == 0) { - // Check the information_schema.collations table is accessible - MCPResult *result = [connection queryString:@"SELECT * FROM `information_schema`.`collations` LIMIT 1"]; - - if ([result numOfRows] == 1) { - // Table is accessible so get available collations - [collations addObjectsFromArray:[self _getDatabaseDataForQuery:@"SELECT * FROM `information_schema.collations` ORDER BY `collation_name` ASC"]]; - } - else { - // Get the list of collations from our hard coded list + // Try to retrieve the available collations from the database + [collations addObjectsFromArray:[self _getDatabaseDataForQuery:@"SELECT * FROM `information_schema.collations` ORDER BY `collation_name` ASC"]]; + + // If that failed, get the list of collations from the hard-coded list + if (![collations count]) { const CHAR_SETS *c = charsets; do { @@ -269,15 +265,11 @@ const CHAR_SETS charsets[] = characterSetEncoding = [[NSString alloc] initWithString:encoding]; - // Check the information_schema.collations table is accessible - MCPResult *result = [connection queryString:@"SELECT * FROM `information_schema`.`collations` LIMIT 1"]; - - if ([result numOfRows] == 1) { - // Table is accessible so get available collations for the supplied encoding - [characterSetCollations addObjectsFromArray:[self _getDatabaseDataForQuery:[NSString stringWithFormat:@"SELECT * FROM `information_schema`.`collations` WHERE character_set_name = '%@' ORDER BY `collation_name` ASC", characterSetEncoding]]]; - } - else { - // Get the list of collations matching the supplied encoding from our hard coded list + // Try to retrieve the available collations for the supplied encoding from the database + [characterSetCollations addObjectsFromArray:[self _getDatabaseDataForQuery:[NSString stringWithFormat:@"SELECT * FROM `information_schema`.`collations` WHERE character_set_name = '%@' ORDER BY `collation_name` ASC", characterSetEncoding]]]; + + // If that failed, get the list of collations matching the supplied encoding from the hard-coded list + if (![characterSetCollations count]) { const CHAR_SETS *c = charsets; do { @@ -383,15 +375,12 @@ const CHAR_SETS charsets[] = { if ([characterSetEncodings count] == 0) { + // Try to retrieve the available character set encodings from the database // Check the information_schema.collations table is accessible - MCPResult *result = [connection queryString:@"SELECT * FROM `information_schema`.`character_sets` LIMIT 1"]; - - if ([result numOfRows] == 1) { - // Table is accessible so get available encodings for the supplied encoding - [characterSetEncodings addObjectsFromArray:[self _getDatabaseDataForQuery:@"SELECT * FROM `information_schema`.`character_sets` ORDER BY `character_set_name` ASC"]]; - } - else { - // Get the list of collations matching the supplied encoding from our hard coded list + [characterSetEncodings addObjectsFromArray:[self _getDatabaseDataForQuery:@"SELECT * FROM `information_schema`.`character_sets` ORDER BY `character_set_name` ASC"]]; + + // If that failed, get the list of character set encodings from the hard-coded list + if (![characterSetEncodings count]) { const CHAR_SETS *c = charsets; do { diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m index 6e9e561e..8a054ce3 100644 --- a/Source/SPQueryController.m +++ b/Source/SPQueryController.m @@ -191,14 +191,17 @@ static SPQueryController *sharedQueryController = nil; // If the timestamp column is not hidden we need to include them in the copy if (!dateColumnIsHidden) { + [string appendString:@"/* "]; [string appendString:[dateFormatter stringFromDate:[message messageDate]]]; - [string appendString:@" "]; + if (connectionColumnIsHidden) [string appendString:@" */ "]; + else [string appendString:@" "]; } // If the connection column is not hidden we need to include them in the copy if (!connectionColumnIsHidden) { + if (dateColumnIsHidden) [string appendString:@"/* "]; [string appendString:[message messageConnection]]; - [string appendString:@" "]; + [string appendString:@" */ "]; } [string appendString:[message message]]; @@ -865,8 +868,9 @@ static SPQueryController *sharedQueryController = nil; // Reload the table and scroll to the new message if it's visible (for speed) if (allowConsoleUpdate && [[self window] isVisible]) { - [consoleTableView reloadData]; + [consoleTableView noteNumberOfRowsChanged]; [consoleTableView scrollRowToVisible:([messagesVisibleSet count] - 1)]; + [consoleTableView reloadData]; } } -- cgit v1.2.3