aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-03-25 18:55:32 +0000
committerBibiko <bibiko@eva.mpg.de>2010-03-25 18:55:32 +0000
commit9a4fe782c03bc0c42030b9344fd4f54e494d88b4 (patch)
tree0d8106bb547bc9f97e9f258817115c9190dae65e /Frameworks/MCPKit
parent0e4ca36991a319d001c26df3fc92f327d6fe091b (diff)
downloadsequelpro-9a4fe782c03bc0c42030b9344fd4f54e494d88b4.tar.gz
sequelpro-9a4fe782c03bc0c42030b9344fd4f54e494d88b4.tar.bz2
sequelpro-9a4fe782c03bc0c42030b9344fd4f54e494d88b4.zip
Suppress the connection structure query if there're more than 10000 items are listed in `information_schema`.`COLUMNS` for now which is a 'quick-fix' for i608. In the near future the gathering routine will do it db/table by db/table to minimize the traffic starting from the current selected db.
Diffstat (limited to 'Frameworks/MCPKit')
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m26
1 files changed, 24 insertions, 2 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
index 82772461..84fb6a5d 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
@@ -1926,8 +1926,8 @@ void performThreadedKeepAlive(void *ptr)
NSStringEncoding theConnectionEncoding = [MCPConnection encodingForMySQLEncoding:mysql_character_set_name(structConnection)];
// Set connection to UTF-8 since the information_schema is encoded in UTF-8
- NSString *setNameString = @"SET NAMES 'utf8'";
- NSData *encodedSetNameData = NSStringDataUsingLossyEncoding(setNameString, theConnectionEncoding, 1);
+ NSString *query = @"SET NAMES 'utf8'";
+ NSData *encodedSetNameData = NSStringDataUsingLossyEncoding(query, theConnectionEncoding, 1);
const char *setNameCString = [encodedSetNameData bytes];
unsigned long setNameCStringLength = [encodedSetNameData length];
if (mysql_real_query(structConnection, setNameCString, setNameCStringLength) != 0) {
@@ -1935,7 +1935,29 @@ void performThreadedKeepAlive(void *ptr)
[queryPool release];
return;
}
+
+ NSUInteger numberOfItems = 20000;
+ query = @"SELECT COUNT(*) FROM `information_schema`.`COLUMNS`";
+ encodedSetNameData = NSStringDataUsingLossyEncoding(query, theConnectionEncoding, 1);
+ setNameCString = [encodedSetNameData bytes];
+ setNameCStringLength = [encodedSetNameData length];
+ if (mysql_real_query(structConnection, setNameCString, setNameCStringLength) != 0) {
+ isQueryingDbStructure = NO;
+ [queryPool release];
+ return;
+ }
+ theResult = mysql_use_result(structConnection);
+ row = mysql_fetch_row(theResult);
+ if(row)
+ numberOfItems = [[self stringWithUTF8CString:row[0]] longLongValue];
+ mysql_free_result(theResult);
+ if(numberOfItems > 10000) {
+ isQueryingDbStructure = NO;
+ [queryPool release];
+ return;
+ }
+
// Query the desired data
NSString *queryDbString = @""
@"SELECT TABLE_SCHEMA AS `databases`, TABLE_NAME AS `tables`, COLUMN_NAME AS `fields`, COLUMN_TYPE AS `type`, CHARACTER_SET_NAME AS `charset`, '0' AS `structtype`, `COLUMN_KEY` AS `KEY`, `EXTRA` AS EXTRA, `PRIVILEGES` AS `PRIVILEGES`, `COLLATION_NAME` AS `collation`, `COLUMN_DEFAULT` AS `default`, `IS_NULLABLE` AS `is_nullable`, `COLUMN_COMMENT` AS `comment` FROM `information_schema`.`COLUMNS` "