aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Frameworks/SPMySQLFramework/MySQL Client Libraries/Patches/001-cpp-dependency.diff8
-rw-r--r--Frameworks/SPMySQLFramework/MySQL Client Libraries/Patches/002-new-types.diff9
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m23
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLUtilities.h2
-rwxr-xr-xFrameworks/SPMySQLFramework/build-mysql-client.sh2
-rw-r--r--Source/SPConnectionController.h4
-rw-r--r--Source/SPConnectionController.m37
-rw-r--r--Source/SPDatabaseDocument.h4
-rw-r--r--Source/SPDatabaseDocument.m70
-rw-r--r--Source/SPDatabaseStructure.m2
10 files changed, 79 insertions, 82 deletions
diff --git a/Frameworks/SPMySQLFramework/MySQL Client Libraries/Patches/001-cpp-dependency.diff b/Frameworks/SPMySQLFramework/MySQL Client Libraries/Patches/001-cpp-dependency.diff
index 06c20001..e3ce848a 100644
--- a/Frameworks/SPMySQLFramework/MySQL Client Libraries/Patches/001-cpp-dependency.diff
+++ b/Frameworks/SPMySQLFramework/MySQL Client Libraries/Patches/001-cpp-dependency.diff
@@ -1,3 +1,11 @@
+This patch is neccesary to remove a linker error when trying to link SPMySQL with libmysqlclient.a.
+
+To apply:
+ cd mysql-source-root
+ patch -p1 < this-file
+
+(patch created with `diff -Naur`)
+
--- mysql-5.5.56-dist/extra/yassl/taocrypt/include/runtime.hpp 2017-04-27 09:12:30.000000000 +0200
+++ mysql-5.5.56/extra/yassl/taocrypt/include/runtime.hpp 2017-05-20 23:27:14.000000000 +0200
@@ -53,8 +53,8 @@
diff --git a/Frameworks/SPMySQLFramework/MySQL Client Libraries/Patches/002-new-types.diff b/Frameworks/SPMySQLFramework/MySQL Client Libraries/Patches/002-new-types.diff
index bb42f9d9..47aa9c6d 100644
--- a/Frameworks/SPMySQLFramework/MySQL Client Libraries/Patches/002-new-types.diff
+++ b/Frameworks/SPMySQLFramework/MySQL Client Libraries/Patches/002-new-types.diff
@@ -1,3 +1,12 @@
+This patch backports field types that were added after MySQL 5.5,
+but are technically still compatible to the old client libs.
+
+To apply:
+ cd mysql-source-root
+ patch -p1 < this-file
+
+(patch created with `diff -Naur`)
+
--- mysql-5.5.56-dist/include/mysql_com.h 2017-04-27 09:12:30.000000000 +0200
+++ mysql-5.5.56/include/mysql_com.h 2017-05-21 01:46:44.000000000 +0200
@@ -349,7 +349,11 @@
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
index d50375e2..897df32f 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
@@ -33,6 +33,7 @@
#include <mach/mach_time.h>
#include <pthread.h>
#include <SystemConfiguration/SCNetworkReachability.h>
+#import "SPMySQLUtilities.h"
// Thread flag constant
static pthread_key_t mySQLThreadInitFlagKey;
@@ -321,12 +322,11 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS
}
/**
- * Returns YES if the MCPConnection is connected to a server via SSL, NO otherwise.
+ * Returns YES if the SPMySQLConnection is connected to a server via SSL, NO otherwise.
*/
- (BOOL)isConnectedViaSSL
{
- if (![self isConnected]) return NO;
- return connectedWithSSL;
+ return ([self isConnected] && connectedWithSSL);
}
/**
@@ -470,14 +470,6 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS
const char *__crashreporter_info__ = NULL;
asm(".desc ___crashreporter_info__, 0x10");
-static uint64_t _elapsedMicroSecondsSinceAbsoluteTime(uint64_t comparisonTime)
-{
- uint64_t elapsedTime_t = mach_absolute_time() - comparisonTime;
- Nanoseconds elapsedTime = AbsoluteToNanoseconds(*(AbsoluteTime *)&(elapsedTime_t));
-
- return (UnsignedWideToUInt64(elapsedTime) / 1000ULL);
-}
-
@implementation SPMySQLConnection (PrivateAPI)
/**
@@ -489,8 +481,8 @@ static uint64_t _elapsedMicroSecondsSinceAbsoluteTime(uint64_t comparisonTime)
// If a connection is already active in some form, throw an exception
if (state != SPMySQLDisconnected && state != SPMySQLConnectionLostInBackground) {
@synchronized (self) {
- uint64_t diff = _elapsedMicroSecondsSinceAbsoluteTime(initialConnectTime);
- asprintf(&__crashreporter_info__, "Attempted to connect a connection that is not disconnected (SPMySQLConnectionState=%d).\nIf state==2: Previous connection made %lluµs ago from: %s", state, diff, [_debugLastConnectedEvent cStringUsingEncoding:NSUTF8StringEncoding]);
+ double diff = _elapsedSecondsSinceAbsoluteTime(initialConnectTime);
+ asprintf(&__crashreporter_info__, "Attempted to connect a connection that is not disconnected (SPMySQLConnectionState=%d).\nIf state==2: Previous connection made %lfs ago from: %s", state, diff, [_debugLastConnectedEvent cStringUsingEncoding:NSUTF8StringEncoding]);
__builtin_trap();
}
[NSException raise:NSInternalInconsistencyException format:@"Attempted to connect a connection that is not disconnected (SPMySQLConnectionState=%d).", state];
@@ -1147,7 +1139,10 @@ static uint64_t _elapsedMicroSecondsSinceAbsoluteTime(uint64_t comparisonTime)
pthread_setspecific(mySQLThreadInitFlagKey, &mySQLThreadFlag);
// Set up the notification handler to deregister it
- [[NSNotificationCenter defaultCenter] addObserver:[self class] selector:@selector(_removeThreadVariables:) name:NSThreadWillExitNotification object:[NSThread currentThread]];
+ [[NSNotificationCenter defaultCenter] addObserver:[self class]
+ selector:@selector(_removeThreadVariables:)
+ name:NSThreadWillExitNotification
+ object:[NSThread currentThread]];
}
/**
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLUtilities.h b/Frameworks/SPMySQLFramework/Source/SPMySQLUtilities.h
index 50f9d504..3aa63ae7 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLUtilities.h
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLUtilities.h
@@ -1,5 +1,5 @@
//
-// Locking.h
+// SPMySQLUtilities.h
// SPMySQLFramework
//
// Created by Rowan Beentje (rowan.beent.je) on February 6, 2012
diff --git a/Frameworks/SPMySQLFramework/build-mysql-client.sh b/Frameworks/SPMySQLFramework/build-mysql-client.sh
index 5475b0a0..ca43eab2 100755
--- a/Frameworks/SPMySQLFramework/build-mysql-client.sh
+++ b/Frameworks/SPMySQLFramework/build-mysql-client.sh
@@ -47,7 +47,7 @@ CLEAN='NO'
MIN_OS_X_VERSION='10.6'
ARCHITECTURES='-arch i386 -arch x86_64'
-CONFIGURE_OPTIONS='-DBUILD_CONFIG=mysql_release -DENABLED_LOCAL_INFILE=1 -DWITH_SSL=bundled -DWITH_MYSQLD_LDFLAGS="-all-static --disable-shared" -DWITHOUT_SERVER=1 -DWITH_ZLIB=system'
+CONFIGURE_OPTIONS='-DBUILD_CONFIG=mysql_release -DENABLED_LOCAL_INFILE=1 -DWITH_SSL=bundled -DWITH_MYSQLD_LDFLAGS="-all-static --disable-shared" -DWITHOUT_SERVER=1 -DWITH_ZLIB=system -DWITH_UNIT_TESTS=0'
OUTPUT_DIR='SPMySQLFiles.build'
ESC=`printf '\033'`
diff --git a/Source/SPConnectionController.h b/Source/SPConnectionController.h
index 2da8f58a..9da0d996 100644
--- a/Source/SPConnectionController.h
+++ b/Source/SPConnectionController.h
@@ -208,6 +208,7 @@
@property (readwrite, assign) NSInteger sshKeyLocationEnabled;
@property (readwrite, retain) NSString *sshKeyLocation;
@property (readwrite, retain) NSString *sshPort;
+@property (readwrite, copy, nonatomic) NSString *connectionKeychainID;
@property (readwrite, retain) NSString *connectionKeychainItemName;
@property (readwrite, retain) NSString *connectionKeychainItemAccount;
@property (readwrite, retain) NSString *connectionSSHKeychainItemName;
@@ -221,6 +222,9 @@
@property (readonly, assign) BOOL isConnecting;
@property (readonly, assign) BOOL isEditingConnection;
+- (NSString *)keychainPassword;
+- (NSString *)keychainPasswordForSSH;
+
// Connection processes
- (IBAction)initiateConnection:(id)sender;
- (IBAction)cancelConnection:(id)sender;
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index 018ecf93..921d4312 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -168,6 +168,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
@synthesize dbDocument;
#endif
+@synthesize connectionKeychainID = connectionKeychainID;
@synthesize connectionKeychainItemName;
@synthesize connectionKeychainItemAccount;
@synthesize connectionSSHKeychainItemName;
@@ -176,6 +177,28 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
@synthesize isConnecting;
@synthesize isEditingConnection;
+- (NSString *)keychainPassword
+{
+ NSString *kcItemName = [self connectionKeychainItemName];
+ // If no keychain item is available, return an empty password
+ if (!kcItemName) return nil;
+
+ // Otherwise, pull the password from the keychain using the details from this connection
+ NSString *kcPassword = [keychain getPasswordForName:kcItemName account:[self connectionKeychainItemAccount]];
+
+ return kcPassword;
+}
+
+- (NSString *)keychainPasswordForSSH
+{
+ if (![self connectionKeychainItemName]) return nil;
+
+ // Otherwise, pull the password from the keychain using the details from this connection
+ NSString *kcSSHPassword = [keychain getPasswordForName:connectionSSHKeychainItemName account:connectionSSHKeychainItemAccount];
+
+ return kcSSHPassword;
+}
+
#pragma mark -
#pragma mark Connection processes
@@ -737,7 +760,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
#ifndef SP_CODA
// Clear the keychain referral items as appropriate
- if (connectionKeychainID) SPClear(connectionKeychainID);
+ [self setConnectionKeychainID:nil];
if (connectionKeychainItemName) SPClear(connectionKeychainItemName);
if (connectionKeychainItemAccount) SPClear(connectionKeychainItemAccount);
if (connectionSSHKeychainItemName) SPClear(connectionSSHKeychainItemName);
@@ -804,7 +827,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
}
// Store the selected favorite ID for use with the document on connection
- if ([fav objectForKey:SPFavoriteIDKey]) connectionKeychainID = [[[fav objectForKey:SPFavoriteIDKey] stringValue] retain];
+ if ([fav objectForKey:SPFavoriteIDKey]) [self setConnectionKeychainID:[[fav objectForKey:SPFavoriteIDKey] stringValue]];
// And the same for the SSH password
connectionSSHKeychainItemName = [[keychain nameForSSHForFavoriteName:[fav objectForKey:SPFavoriteNameKey] id:[fav objectForKey:SPFavoriteIDKey]] retain];
@@ -2022,7 +2045,10 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
[connectButton display];
#endif
- [NSThread detachNewThreadWithName:SPCtxt(@"SPConnectionController MySQL connection task", dbDocument) target:self selector:@selector(initiateMySQLConnectionInBackground) object:nil];
+ [NSThread detachNewThreadWithName:SPCtxt(@"SPConnectionController MySQL connection task", dbDocument)
+ target:self
+ selector:@selector(initiateMySQLConnectionInBackground)
+ object:nil];
}
/**
@@ -2372,8 +2398,6 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
for (NSUInteger i = 0; i < [toolbarItems count]; i++) [[toolbarItems objectAtIndex:i] setEnabled:YES];
#endif
- if (connectionKeychainID) [dbDocument setKeychainID:connectionKeychainID];
-
// Pass the connection to the table document, allowing it to set
// up the other classes and the rest of the interface.
[dbDocument setConnection:mySQLConnection];
@@ -3167,7 +3191,6 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
#endif
// Keychain references
- connectionKeychainID = nil;
connectionKeychainItemName = nil;
connectionKeychainItemAccount = nil;
connectionSSHKeychainItemName = nil;
@@ -3621,7 +3644,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
SPClear(nibObjectsToRelease);
- if (connectionKeychainID) SPClear(connectionKeychainID);
+ [self setConnectionKeychainID:nil];
if (connectionKeychainItemName) SPClear(connectionKeychainItemName);
if (connectionKeychainItemAccount) SPClear(connectionKeychainItemAccount);
if (connectionSSHKeychainItemName) SPClear(connectionSSHKeychainItemName);
diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h
index de7dd55e..c89f7847 100644
--- a/Source/SPDatabaseDocument.h
+++ b/Source/SPDatabaseDocument.h
@@ -262,8 +262,6 @@
NSMutableArray *runningActivitiesArray;
#endif
- NSString *keyChainID;
-
#ifndef SP_CODA /* ivars */
NSThread *printThread;
@@ -342,7 +340,6 @@
#endif
- (void)setConnection:(SPMySQLConnection *)theConnection;
- (SPMySQLConnection *)getConnection;
-- (void)setKeychainID:(NSString *)theID;
// Database methods
- (IBAction)setDatabases:(id)sender;
@@ -451,7 +448,6 @@
- (NSString *)port;
- (NSString *)mySQLVersion;
- (NSString *)user;
-- (NSString *)keyChainID;
- (NSString *)connectionID;
#ifndef SP_CODA /* method decls */
- (NSString *)tabTitleForTooltip;
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index 2340b97e..41f4e078 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -218,8 +218,6 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
alterDatabaseCharsetHelper = nil; //init in awakeFromNib
addDatabaseCharsetHelper = nil;
- keyChainID = nil;
-
#ifndef SP_CODA /* init ivars */
statusValues = nil;
printThread = nil;
@@ -613,14 +611,6 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
return mySQLConnection;
}
-/**
- * Sets this connection's Keychain ID.
- */
-- (void)setKeychainID:(NSString *)theId
-{
- keyChainID = [[NSString stringWithString:theId] retain];
-}
-
#pragma mark -
#pragma mark Database methods
@@ -2863,11 +2853,6 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
return thePort;
}
-- (NSString *)keyChainID
-{
- return keyChainID;
-}
-
- (BOOL)isSaveInBundle
{
return _isSavedInBundle;
@@ -4674,7 +4659,8 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
}
[connection setObject:connectionType forKey:@"type"];
- if ([[self keyChainID] length]) [connection setObject:[self keyChainID] forKey:@"kcid"];
+ NSString *kcid = [connectionController connectionKeychainID];
+ if ([kcid length]) [connection setObject:kcid forKey:@"kcid"];
[connection setObject:[self name] forKey:@"name"];
[connection setObject:[self host] forKey:@"host"];
[connection setObject:[self user] forKey:@"user"];
@@ -4686,7 +4672,7 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
[connection setObject:[self database] forKey:@"database"];
if (includePasswords) {
- NSString *pw = [self keychainPasswordForConnection:nil];
+ NSString *pw = [connectionController keychainPassword];
if (!pw) pw = [connectionController password];
if (pw) [connection setObject:pw forKey:@"password"];
@@ -4875,9 +4861,10 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
[connectionController setSslCACertFileLocation:[connection objectForKey:@"sslCACertFileLocation"]];
// Set the keychain details if available
- if ([connection objectForKey:@"kcid"] && [(NSString *)[connection objectForKey:@"kcid"] length]) {
- [self setKeychainID:[connection objectForKey:@"kcid"]];
- [connectionController setConnectionKeychainItemName:[keychain nameForFavoriteName:[connectionController name] id:[self keyChainID]]];
+ NSString *kcid = (NSString *)[connection objectForKey:@"kcid"];
+ if ([kcid length]) {
+ [connectionController setConnectionKeychainID:kcid];
+ [connectionController setConnectionKeychainItemName:[keychain nameForFavoriteName:[connectionController name] id:kcid]];
[connectionController setConnectionKeychainItemAccount:[keychain accountForUser:[connectionController user] host:[connectionController host] database:[connection objectForKey:@"database"]]];
}
@@ -4885,9 +4872,8 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
if ([connection objectForKey:@"password"])
[connectionController setPassword:[connection objectForKey:@"password"]];
else {
- NSString *pw = [self keychainPasswordForConnection:nil];
- if (pw)
- [connectionController setPassword:pw];
+ NSString *pw = [connectionController keychainPassword];
+ if (pw) [connectionController setPassword:pw];
}
// Set the socket details, whether or not the type is a socket
@@ -4910,8 +4896,8 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
if ([connection objectForKey:@"ssh_password"])
[connectionController setSshPassword:[connection objectForKey:@"ssh_password"]];
else {
- if ([connection objectForKey:@"kcid"] && [(NSString *)[connection objectForKey:@"kcid"] length]) {
- [connectionController setConnectionSSHKeychainItemName:[keychain nameForSSHForFavoriteName:[connectionController name] id:[self keyChainID]]];
+ if ([kcid length]) {
+ [connectionController setConnectionSSHKeychainItemName:[keychain nameForSSHForFavoriteName:[connectionController name] id:kcid]];
[connectionController setConnectionSSHKeychainItemAccount:[keychain accountForSSHUser:[connectionController sshUser] sshHost:[connectionController sshHost]]];
}
NSString *sshpw = [self keychainPasswordForSSHConnection:nil];
@@ -7152,17 +7138,7 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
*/
- (NSString *)keychainPasswordForConnection:(SPMySQLConnection *)connection
{
- // If no keychain item is available, return an empty password
- if (![connectionController connectionKeychainItemName]) return nil;
-
- // Otherwise, pull the password from the keychain using the details from this connection
- SPKeychain *keychain = [[SPKeychain alloc] init];
-
- NSString *password = [keychain getPasswordForName:[connectionController connectionKeychainItemName] account:[connectionController connectionKeychainItemAccount]];
-
- [keychain release];
-
- return password;
+ return [connectionController keychainPassword];
}
/**
@@ -7173,25 +7149,10 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
- (NSString *)keychainPasswordForSSHConnection:(SPMySQLConnection *)connection
{
// If no keychain item is available, return an empty password
- if (![connectionController connectionKeychainItemName]) return @"";
-
- // Otherwise, pull the password from the keychain using the details from this connection
- SPKeychain *keychain = [[SPKeychain alloc] init];
-
- NSString *connectionSSHKeychainItemName = [[keychain nameForSSHForFavoriteName:[connectionController name] id:[self keyChainID]] retain];
- NSString *connectionSSHKeychainItemAccount = [[keychain accountForSSHUser:[connectionController sshUser] sshHost:[connectionController sshHost]] retain];
- NSString *sshPassword = [keychain getPasswordForName:connectionSSHKeychainItemName account:connectionSSHKeychainItemAccount];
+ NSString *password = [connectionController keychainPasswordForSSH];
+ if (!password) return @"";
- if (!sshPassword || ![sshPassword length]) {
- sshPassword = @"";
- }
-
- if (connectionSSHKeychainItemName) [connectionSSHKeychainItemName release];
- if (connectionSSHKeychainItemAccount) [connectionSSHKeychainItemAccount release];
-
- [keychain release];
-
- return sshPassword;
+ return password;
}
/**
@@ -7754,7 +7715,6 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
if (spfPreferences) SPClear(spfPreferences);
if (spfSession) SPClear(spfSession);
if (spfDocData) SPClear(spfDocData);
- if (keyChainID) SPClear(keyChainID);
if (mainToolbar) SPClear(mainToolbar);
if (titleAccessoryView) SPClear(titleAccessoryView);
if (taskProgressWindow) SPClear(taskProgressWindow);
diff --git a/Source/SPDatabaseStructure.m b/Source/SPDatabaseStructure.m
index 9289b13b..c2b0bb59 100644
--- a/Source/SPDatabaseStructure.m
+++ b/Source/SPDatabaseStructure.m
@@ -258,6 +258,7 @@
goto cleanup_thread_and_pool;
}
+#if 0
// For future usage - currently unused
// If the affected item name and type - for example, table type and table name - were supplied, extract it.
NSString *affectedItem = nil;
@@ -269,6 +270,7 @@
else
affectedItem = nil;
}
+#endif
// Delete all stored data for the database to be updated, leaving the structure key
[queriedStructure removeObjectForKey:db_id];