aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPServerSupport.h
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-10-07 18:56:33 +0000
committerstuconnolly <stuart02@gmail.com>2010-10-07 18:56:33 +0000
commit44a5f9e552b3d5e1f9ef1c6d11f34e893d67e85b (patch)
treec833ba970d8cae5f756a31bc274e365c0a44b3bf /Source/SPServerSupport.h
parent95d2e4acc393e91aa70ed4c71daa1f776454a936 (diff)
downloadsequelpro-44a5f9e552b3d5e1f9ef1c6d11f34e893d67e85b.tar.gz
sequelpro-44a5f9e552b3d5e1f9ef1c6d11f34e893d67e85b.tar.bz2
sequelpro-44a5f9e552b3d5e1f9ef1c6d11f34e893d67e85b.zip
Various improvements to server capability/version checking, including:
- Add a new ServerSupport class, for which an instance is created upon each new connection and is then subsequently accessible via SPDatabaseDocument. - Replace the majority of manual version checking with calls to properties in the above new class. - Improve the user manager's compatibility with MySQL 3 and 4 servers. Fixes issue #811 Other changes include: - Disable the encoding popup button when adding a new table or database to servers running pre MySQL 4.1 as it only contains one option, 'Default'. - Fix various potential memory leaks discovered during static analysis. - General tidy up and comments.
Diffstat (limited to 'Source/SPServerSupport.h')
-rw-r--r--Source/SPServerSupport.h209
1 files changed, 209 insertions, 0 deletions
diff --git a/Source/SPServerSupport.h b/Source/SPServerSupport.h
new file mode 100644
index 00000000..b1afc5cd
--- /dev/null
+++ b/Source/SPServerSupport.h
@@ -0,0 +1,209 @@
+//
+// $Id$
+//
+// SPServerSupport.h
+// sequel-pro
+//
+// Created by Stuart Connolly (stuconnolly.com) on September 23, 2010
+// Copyright (c) 2010 Stuart Connolly. All rights reserved.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// More info at <http://code.google.com/p/sequel-pro/>
+
+/**
+ * @class SPServerSupport SPServerSupport.h
+ *
+ * @author Stuart Connolly http://stuconnolly.com/
+ *
+ * This class is provided as a convenient method of determining what features/functionality the MySQL server
+ * with the supplied version numbers supports. Note that this class has no direct connection to the server,
+ * all of it's information is simply determined by way of version comparisons using hard coded values of known
+ * versions and the functionality they support.
+ *
+ * Every new MySQL connection that is established should create an instance of this class and make it globally
+ * accessible to the rest of the application to remove the need of manual version comparisons. Calling it's
+ * designated initializer (initWithMajorVersion:major:minor:release:) causes the determination of what
+ * functionality is supported, and so other initializtion is required.
+ *
+ * See the method evaluate for information regarding adding additional functionality checks.
+ */
+@interface SPServerSupport : NSObject
+{
+ // Convenience vars
+ BOOL isMySQL3;
+ BOOL isMySQL4;
+ BOOL isMySQL5;
+ BOOL isMySQL6;
+
+ // General
+ BOOL supportsInformationSchema;
+
+ // Encoding
+ BOOL supportsShowCharacterSet;
+ BOOL supportsCharacterSetDatabaseVar;
+ BOOL supportsPost41CharacterSetHandling;
+
+ // User account related
+ BOOL supportsCreateUser;
+ BOOL supportsDropUser;
+ BOOL supportsFullDropUser;
+ BOOL supportsUserMaxVars;
+ BOOL supportsShowPrivileges;
+
+ // Storage engines
+ BOOL supportsInformationSchemaEngines;
+ BOOL supportsPre41StorageEngines;
+ BOOL supportsBlackholeStorageEngine;
+ BOOL supportsArchiveStorageEngine;
+ BOOL supportsCSVStorageEngine;
+
+ // Triggers
+ BOOL supportsTriggers;
+
+ // Indexes
+ BOOL supportsIndexKeyBlockSize;
+
+ // Server versions
+ NSInteger serverMajorVersion;
+ NSInteger serverMinorVersion;
+ NSInteger serverReleaseVersion;
+}
+
+/**
+ * @property serverMajorVersion
+ */
+@property (readwrite, assign) NSInteger serverMajorVersion;
+
+/**
+ * @property serverMinorVersion
+ */
+@property (readwrite, assign) NSInteger serverMinorVersion;
+
+/**
+ * @property serverReleaseVersion
+ */
+@property (readwrite, assign) NSInteger serverReleaseVersion;
+
+/**
+ * @property isMySQL3 Indicates if the server is MySQL version 3
+ */
+@property (readonly) BOOL isMySQL3;
+
+/**
+ * @property isMySQL4 Indicates if the server is MySQL version 4
+ */
+@property (readonly) BOOL isMySQL4;
+
+/**
+ * @property isMySQL5 Indicates if the server is MySQL version 5
+ */
+@property (readonly) BOOL isMySQL5;
+
+/**
+ * @property isMySQL6 Indicates if the server is MySQL version 6
+ */
+@property (readonly) BOOL isMySQL6;
+
+/**
+ * @property supportsInformationSchema Indicates if the server supports the information_schema database
+ */
+@property (readonly) BOOL supportsInformationSchema;
+
+/**
+ * @property supportsShowCharacterSet Indicates if the server supports the SHOW CHARACTER SET statement
+ */
+@property (readonly) BOOL supportsShowCharacterSet;
+
+/**
+ * @property supportsCharacterSetDatabaseVar Indicates if the server supports the 'character_set_database'
+ * variable.
+ */
+@property (readonly) BOOL supportsCharacterSetDatabaseVar;
+
+/**
+ * @property supportsPost41CharacterSetHandling Indicates whether the server supports post 4.1 character set
+ * handling.
+ */
+@property (readonly) BOOL supportsPost41CharacterSetHandling;
+
+/**
+ * @property supportsCreateUser Indicates if the server supports the CREATE USER statement
+ */
+@property (readonly) BOOL supportsCreateUser;
+
+/**
+ * @property supportsDropUser Indicates if the server supports the DROP USER statement
+ */
+@property (readonly) BOOL supportsDropUser;
+
+/**
+ * @property supportsFullDropUser Indicates if the server supports deleting a user's priveleges when issueing
+ * the DROP USER statement.
+ */
+@property (readonly) BOOL supportsFullDropUser;
+
+/**
+ * @property supportsUserMaxVars Indicates if the server supports setting a user's maximum variables
+ */
+@property (readonly) BOOL supportsUserMaxVars;
+
+/**
+ * @property supportsShowPrivileges Indicates if the server supports the SHOW PRIVILEGES statement
+ */
+@property (readonly) BOOL supportsShowPrivileges;
+
+/**
+ * @property supportsInformationSchemaEngines Indicates if the server supports the information_schema.engines table
+ */
+@property (readonly) BOOL supportsInformationSchemaEngines;
+
+/**
+ * @property supportsPre41StorageEngines Indicates if the server supports storage engines available prior
+ * to MySQL 4.1
+ */
+@property (readonly) BOOL supportsPre41StorageEngines;
+
+/**
+ * @property supportsBlackholeStorageEngine Indicates if the server supports the BLACKHOLE storage engine
+ */
+@property (readonly) BOOL supportsBlackholeStorageEngine;
+
+/**
+ * @property supportsArchiveStorageEngine Indicates if the server supports the ARCHIVE storage engine
+ */
+@property (readonly) BOOL supportsArchiveStorageEngine;
+
+/**
+ * @property supportsCSVStorageEngine Indicates if the server supports the CSV storage engine
+ */
+@property (readonly) BOOL supportsCSVStorageEngine;
+
+/**
+ * @property supportsTriggers Indicates if the server supports table triggers
+ */
+@property (readonly) BOOL supportsTriggers;
+
+/**
+ * @property supportsIndexKeyBlockSize Indicates if the server supports specifying an index's key block size
+ */
+@property (readonly) BOOL supportsIndexKeyBlockSize;
+
+- (id)initWithMajorVersion:(NSInteger)majorVersion minor:(NSInteger)minorVersion release:(NSInteger)releaseVersion;
+
+- (void)evaluate;
+- (BOOL)isEqualToOrGreaterThanMajorVersion:(NSInteger)majorVersion minor:(NSInteger)minorVersion release:(NSInteger)releaseVersion;
+
+@end