aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/SPMySQLFramework
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-10-30 02:50:18 +0100
committerMax <post@wickenrode.com>2015-10-30 02:50:18 +0100
commitb5be6b8b785ecd25a7366afd541844ee78f4420d (patch)
treeddc7a1b2b5acc46d749199e99c2b3dc1f859c42c /Frameworks/SPMySQLFramework
parentb2d798ba9282d3acf1a2d65de30849e529d4d255 (diff)
downloadsequelpro-b5be6b8b785ecd25a7366afd541844ee78f4420d.tar.gz
sequelpro-b5be6b8b785ecd25a7366afd541844ee78f4420d.tar.bz2
sequelpro-b5be6b8b785ecd25a7366afd541844ee78f4420d.zip
* Add a wrapper method for 3 repeatetly used calls
Diffstat (limited to 'Frameworks/SPMySQLFramework')
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQL Private APIs.h1
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m13
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m7
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m4
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.m4
5 files changed, 17 insertions, 12 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQL Private APIs.h b/Frameworks/SPMySQLFramework/Source/SPMySQL Private APIs.h
index ec85f92b..1e2a8c14 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQL Private APIs.h
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQL Private APIs.h
@@ -82,6 +82,7 @@
@interface SPMySQLConnection (Querying_and_Preparation_Private_API)
- (void)_flushMultipleResultSets;
+- (void)_updateLastErrorInfos;
- (void)_updateLastErrorMessage:(NSString *)theErrorMessage;
- (void)_updateLastErrorID:(NSUInteger)theErrorID;
- (void)_updateLastSqlstate:(NSString *)theSqlstate;
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
index 2abb8a35..f001d332 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
@@ -72,11 +72,12 @@
}
return nil;
}
- if (![self _checkConnectionIfNecessary]) return nil;
// Ensure per-thread variables are set up
[self _validateThreadSetup];
+ if (![self _checkConnectionIfNecessary]) return nil;
+
// Perform a lossy conversion to bytes, using NSData to do the hard work. Preserves
// nul characters correctly.
NSData *cData = [theString dataUsingEncoding:stringEncoding allowLossyConversion:YES];
@@ -666,6 +667,16 @@
}
/**
+ * Update lastErrorID, lastErrorMessage and lastSqlstate from connection
+ */
+- (void)_updateLastErrorInfos
+{
+ [self _updateLastErrorID:NSNotFound];
+ [self _updateLastErrorMessage:nil];
+ [self _updateLastSqlstate:nil];
+}
+
+/**
* Update the MySQL error message for this connection. If an error is supplied
* it will be stored and returned to anything asking the instance for the last
* error; if no error is supplied, the connection will be used to derive (or clear)
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
index 1ca2f182..452844ab 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
@@ -503,9 +503,7 @@ asm(".desc ___crashreporter_info__, 0x10");
keepAlivePingFailures = 0;
// Clear the connection error record
- [self _updateLastErrorID:NSNotFound];
- [self _updateLastErrorMessage:nil];
- [self _updateLastSqlstate:nil];
+ [self _updateLastErrorInfos];
// Unlock the connection
[self _unlockConnection];
@@ -1028,7 +1026,6 @@ asm(".desc ___crashreporter_info__, 0x10");
*/
- (void)_validateThreadSetup
{
-
// Check to see whether the handler has already been installed
if (pthread_getspecific(mySQLThreadInitFlagKey)) return;
@@ -1039,7 +1036,7 @@ asm(".desc ___crashreporter_info__, 0x10");
pthread_setspecific(mySQLThreadInitFlagKey, &mySQLThreadFlag);
// Set up the notification handler to deregister it
- [(NSNotificationCenter *)[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/SPMySQLFastStreamingResult.m b/Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m
index 930180da..53ab116f 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m
@@ -392,9 +392,7 @@ typedef struct st_spmysqlstreamingrowdata {
}
// Update the connection's error statuses to reflect any errors during the content download
- [parentConnection _updateLastErrorID:NSNotFound];
- [parentConnection _updateLastErrorMessage:nil];
- [parentConnection _updateLastSqlstate:nil];
+ [parentConnection _updateLastErrorInfos];
// Unlock the parent connection now all data has been retrieved
[parentConnection _unlockConnection];
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.m b/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.m
index 86a6b2b5..29f83e0e 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.m
@@ -809,9 +809,7 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult
}
// Update the connection's error statuses to reflect any errors during the content download
- [parentConnection _updateLastErrorID:NSNotFound];
- [parentConnection _updateLastErrorMessage:nil];
- [parentConnection _updateLastSqlstate:nil];
+ [parentConnection _updateLastErrorInfos];
// Unlock the parent connection now all data has been retrieved
[parentConnection _unlockConnection];