aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPDatabaseData.m11
-rw-r--r--Source/TablesList.m55
2 files changed, 35 insertions, 31 deletions
diff --git a/Source/SPDatabaseData.m b/Source/SPDatabaseData.m
index 07220f59..e8782fad 100644
--- a/Source/SPDatabaseData.m
+++ b/Source/SPDatabaseData.m
@@ -234,7 +234,8 @@ const CHAR_SETS charsets[] =
if ([collations count] == 0) {
// Try to retrieve the available collations from the database
- [collations addObjectsFromArray:[self _getDatabaseDataForQuery:@"SELECT * FROM `information_schema.collations` ORDER BY `collation_name` ASC"]];
+ if ([connection serverMajorVersion] >= 5)
+ [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]) {
@@ -266,7 +267,8 @@ const CHAR_SETS charsets[] =
characterSetEncoding = [[NSString alloc] initWithString:encoding];
// 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 ([connection serverMajorVersion] >= 5)
+ [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]) {
@@ -377,8 +379,9 @@ 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
- [characterSetEncodings addObjectsFromArray:[self _getDatabaseDataForQuery:@"SELECT * FROM `information_schema`.`character_sets` ORDER BY `character_set_name` ASC"]];
+ // Check the information_schema.character_sets table is accessible
+ if ([connection serverMajorVersion] >= 5)
+ [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]) {
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]];