aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TablesList.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-01-06 20:54:03 +0000
committerBibiko <bibiko@eva.mpg.de>2010-01-06 20:54:03 +0000
commitfcb6ce6cbb0bd4179e22a3dd17dd12e4a3529cdd (patch)
tree72b2be91dd765765415705e5105d04780792cc6e /Source/TablesList.m
parent644befb3e7d6c3fcce85da8a54d6b89de4ae2bbf (diff)
downloadsequelpro-fcb6ce6cbb0bd4179e22a3dd17dd12e4a3529cdd.tar.gz
sequelpro-fcb6ce6cbb0bd4179e22a3dd17dd12e4a3529cdd.tar.bz2
sequelpro-fcb6ce6cbb0bd4179e22a3dd17dd12e4a3529cdd.zip
• avoid querying the server for `information_schema` table for MySQL version < 5 - this speeds up SP esp. for slow connections
Diffstat (limited to 'Source/TablesList.m')
-rw-r--r--Source/TablesList.m55
1 files changed, 28 insertions, 27 deletions
diff --git a/Source/TablesList.m b/Source/TablesList.m
index 3a6462a7..0472e0c4 100644
--- a/Source/TablesList.m
+++ b/Source/TablesList.m
@@ -116,39 +116,40 @@
* using information_schema gives us more info (for information window perhaps?) but breaks
* backward compatibility with pre 4 I believe. I left the other methods below, in case.
*/
- NSString *pQuery = [NSString stringWithFormat:@"SELECT * FROM information_schema.routines WHERE routine_schema = '%@' ORDER BY routine_name",[tableDocumentInstance database]];
- theResult = [mySQLConnection queryString:pQuery];
+ if ([mySQLConnection serverMajorVersion] >= 5) {
+ NSString *pQuery = [NSString stringWithFormat:@"SELECT * FROM information_schema.routines WHERE routine_schema = '%@' ORDER BY routine_name",[tableDocumentInstance database]];
+ theResult = [mySQLConnection queryString:pQuery];
- // Check for mysql errors - if information_schema is not accessible for some reasons
- // omit adding procedures and functions
- if([[mySQLConnection getLastErrorMessage] isEqualToString:@""] && theResult != nil && [theResult numOfRows] ) {
- // add the header row
- [tables addObject:NSLocalizedString(@"PROCS & FUNCS",@"header for procs & funcs list")];
- [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_NONE]];
- [theResult dataSeek:0];
+ // Check for mysql errors - if information_schema is not accessible for some reasons
+ // omit adding procedures and functions
+ if([[mySQLConnection getLastErrorMessage] isEqualToString:@""] && theResult != nil && [theResult numOfRows] ) {
+ // add the header row
+ [tables addObject:NSLocalizedString(@"PROCS & FUNCS",@"header for procs & funcs list")];
+ [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_NONE]];
+ [theResult dataSeek:0];
- if( [theResult numOfFields] == 1 ) {
- for( i = 0; i < [theResult numOfRows]; i++ ) {
- [tables addObject:NSArrayObjectAtIndex([theResult fetchRowAsArray],3)];
- if( [NSArrayObjectAtIndex([theResult fetchRowAsArray], 4) isEqualToString:@"PROCEDURE"]) {
- [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_PROC]];
- } else {
- [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_FUNC]];
+ if( [theResult numOfFields] == 1 ) {
+ for( i = 0; i < [theResult numOfRows]; i++ ) {
+ [tables addObject:NSArrayObjectAtIndex([theResult fetchRowAsArray],3)];
+ if( [NSArrayObjectAtIndex([theResult fetchRowAsArray], 4) isEqualToString:@"PROCEDURE"]) {
+ [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_PROC]];
+ } else {
+ [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_FUNC]];
+ }
}
+ } else {
+ for( i = 0; i < [theResult numOfRows]; i++ ) {
+ resultRow = [theResult fetchRowAsArray];
+ [tables addObject:NSArrayObjectAtIndex(resultRow, 3)];
+ if( [NSArrayObjectAtIndex(resultRow, 4) isEqualToString:@"PROCEDURE"] ) {
+ [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_PROC]];
+ } else {
+ [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_FUNC]];
+ }
+ }
}
- } else {
- for( i = 0; i < [theResult numOfRows]; i++ ) {
- resultRow = [theResult fetchRowAsArray];
- [tables addObject:NSArrayObjectAtIndex(resultRow, 3)];
- if( [NSArrayObjectAtIndex(resultRow, 4) isEqualToString:@"PROCEDURE"] ) {
- [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_PROC]];
- } else {
- [tableTypes addObject:[NSNumber numberWithInt:SP_TABLETYPE_FUNC]];
- }
- }
}
}
-
/*
BOOL addedPFHeader = FALSE;
NSString *pQuery = [NSString stringWithFormat:@"SHOW PROCEDURE STATUS WHERE db = '%@'",[tableDocumentInstance database]];