From fcb6ce6cbb0bd4179e22a3dd17dd12e4a3529cdd Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 6 Jan 2010 20:54:03 +0000 Subject: =?UTF-8?q?=E2=80=A2=20avoid=20querying=20the=20server=20for=20`in?= =?UTF-8?q?formation=5Fschema`=20table=20for=20MySQL=20version=20<=205=20-?= =?UTF-8?q?=20this=20speeds=20up=20SP=20esp.=20for=20slow=20connections?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPDatabaseData.m | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Source/SPDatabaseData.m') 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]) { -- cgit v1.2.3