aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks
diff options
context:
space:
mode:
Diffstat (limited to 'Frameworks')
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Conversion.h2
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Conversion.m4
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Databases & Tables.m8
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Encoding.m6
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Locking.m55
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Max Packet Size.m8
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.h7
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m18
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m8
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m1
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m48
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLDataTypes.h90
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLDataTypes.m90
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLEmptyResult.m7
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m11
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLGeometryData.m29
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Data Conversion.m7
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m128
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLResult.m3
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResult.m7
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.h11
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.m25
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLStringAdditions.m14
23 files changed, 260 insertions, 327 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Conversion.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Conversion.h
index 77b70bf9..d2653087 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Conversion.h
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Conversion.h
@@ -1,5 +1,5 @@
//
-// Encoding.m
+// Conversion.h
// SPMySQLFramework
//
// Created by Rowan Beentje (rowan.beent.je) on January 22, 2012
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Conversion.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Conversion.m
index a7d293ea..e1764b90 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Conversion.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Conversion.m
@@ -1,5 +1,5 @@
//
-// Encoding.m
+// Conversion.m
// SPMySQLFramework
//
// Created by Rowan Beentje (rowan.beent.je) on January 22, 2012
@@ -47,7 +47,6 @@
But the "string" can already contain NUL bytes, so it's not a valid c string anyway.
+ (const char *)_cStringForString:(NSString *)aString usingEncoding:(NSStringEncoding)anEncoding returningLengthAs:(NSUInteger *)cStringLengthPointer
{
-
// Don't try and convert nil strings
if (!aString) return NULL;
@@ -73,7 +72,6 @@
*/
- (const char *)_cStringForString:(NSString *)aString
{
-
// Use a cached reference to avoid dynamic method overhead
return _cStringForStringWithEncoding(aString, stringEncoding, NULL);
}
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Databases & Tables.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Databases & Tables.m
index 7b215db4..fb586274 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Databases & Tables.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Databases & Tables.m
@@ -45,7 +45,6 @@
*/
- (BOOL)selectDatabase:(NSString *)aDatabase
{
-
// If no database was supplied, can't deselected - return NO.
if (!aDatabase) return NO;
@@ -96,7 +95,6 @@
*/
- (NSArray *)databases
{
-
// Wrap the related databasesLike: function to avoid code duplication
return [self databasesLike:nil];
}
@@ -151,7 +149,6 @@
*/
- (NSArray *)tables
{
-
// Wrap the related tablesLike:fromDatabase: function to avoid code duplication
return [self tablesLike:nil fromDatabase:nil];
}
@@ -166,10 +163,8 @@
*/
- (NSArray *)tablesLike:(NSString *)nameLikeString
{
-
// Wrap the related tablesLike:fromDatabase: function to avoid code duplication
return [self tablesLike:nameLikeString fromDatabase:nil];
-
}
/**
@@ -180,10 +175,8 @@
*/
- (NSArray *)tablesFromDatabase:(NSString *)aDatabase
{
-
// Wrap the related tablesLike:fromDatabase: function to avoid code duplication
return [self tablesLike:nil fromDatabase:aDatabase];
-
}
/**
@@ -246,7 +239,6 @@
*/
- (BOOL)_storeAndAlterEncodingToUTF8IfRequired
{
-
// If the encoding is already UTF8, no change is required.
if ([encoding isEqualToString:@"utf8"] && !encodingUsesLatin1Transport) return NO;
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Encoding.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Encoding.m
index 76f323bc..c0f14594 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Encoding.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Encoding.m
@@ -82,7 +82,6 @@
*/
- (BOOL)setEncoding:(NSString *)theEncoding
{
-
// MySQL versions prior to 4.1 don't support encoding changes; return NO on those
// versions.
if (![self serverVersionIsGreaterThanOrEqualTo:4 minorVersion:1 releaseVersion:0]) {
@@ -116,14 +115,13 @@
* Latin1 transport is a compatibility mode in place for compatibility with older
* incorrect setups, where databases and clients might both be set to use UTF8 (or
* other encodings) for storing and retrieving data, but the MySQL link was never
- * set to UTF8 mode; as a result, multibyte characters where split by the connection
+ * set to UTF8 mode; as a result, multibyte characters were split by the connection
* into pairs of characters, resulting in malformed storage. The data works
* correctly if written and read in the same way, so this mode allows correct display
* of that data.
*/
- (BOOL)setEncodingUsesLatin1Transport:(BOOL)useLatin1
{
-
// MySQL versions prior to 4.1 don't support encoding changes; return NO on those
// versions.
if (![self serverVersionIsGreaterThanOrEqualTo:4 minorVersion:1 releaseVersion:0]) {
@@ -208,7 +206,6 @@
*/
+ (NSStringEncoding)stringEncodingForMySQLCharset:(const char *)mysqlCharset
{
-
// Handle the most common cases first
if (!strcmp(mysqlCharset, "utf8")) {
return NSUTF8StringEncoding;
@@ -337,7 +334,6 @@
*/
+ (NSString *)mySQLCharsetForStringEncoding:(NSStringEncoding)aStringEncoding
{
-
// Switch through the list of NSStringEncodings from NSString, returning the most
// appropriate encoding for each
switch (aStringEncoding) {
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Locking.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Locking.m
index 095ba7bf..fd33b3e4 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Locking.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Locking.m
@@ -42,12 +42,11 @@
*/
- (void)_lockConnection
{
-
- // We can only start a query when the condition is SPMySQLConnectionIdle
+ // We can only start a query when the condition is SPMySQLConnectionIdle
[connectionLock lockWhenCondition:SPMySQLConnectionIdle];
-
- // Set the condition to SPMySQLConnectionBusy
- [connectionLock unlockWithCondition:SPMySQLConnectionBusy];
+
+ // Set the condition to SPMySQLConnectionBusy
+ [connectionLock unlockWithCondition:SPMySQLConnectionBusy];
}
/**
@@ -58,7 +57,6 @@
*/
- (BOOL)_tryLockConnection
{
-
// If the connection is already is use, return failure
if (![connectionLock tryLockWhenCondition:SPMySQLConnectionIdle]) {
return NO;
@@ -75,28 +73,31 @@
*/
- (void)_unlockConnection
{
+ // Always lock the conditional lock before proceeding
+ [connectionLock lock];
+
+ // Check if the connection actually was busy. If it wasn't busy,
+ // it means the connection may have been unlocked twice. This is
+ // potentially dangerous, so we log this to the console
+ if ([connectionLock condition] != SPMySQLConnectionBusy) {
+ NSLog(@"SPMySQLConnection: Tried to unlock the connection, but it wasn't locked.");
+ }
+
+ // Since we connected with CLIENT_MULTI_RESULT, we must make sure there are not more results!
+ // This is still a bit of a dirty hack
+ if (
+ state == SPMySQLConnected &&
+ mySQLConnection &&
+ mySQLConnection->net.vio &&
+ mySQLConnection->net.buff &&
+ mysql_more_results(mySQLConnection)
+ ) {
+ NSLog(@"SPMySQLConnection: Discarding unretrieved results. This is currently normal when using CALL.");
+ [self _flushMultipleResultSets];
+ }
- // Always lock the conditional lock before proceeding
- [connectionLock lock];
-
- // Check if the connection actually was busy. If it wasn't busy,
- // it means the connection may have been unlocked twice. This is
- // potentially dangerous, so we log this to the console
- if ([connectionLock condition] != SPMySQLConnectionBusy) {
- NSLog(@"SPMySQLConnection: Tried to unlock the connection, but it wasn't locked.");
- }
-
- // Since we connected with CLIENT_MULTI_RESULT, we must make sure there are not more results!
- // This is still a bit of a dirty hack
- if (state == SPMySQLConnected
- && mySQLConnection && mySQLConnection->net.vio && mySQLConnection->net.buff && mysql_more_results(mySQLConnection))
- {
- NSLog(@"SPMySQLConnection: Discarding unretrieved results. This is currently normal when using CALL.");
- [self _flushMultipleResultSets];
- }
-
- // Tell everyone that the connection is available again
- [connectionLock unlockWithCondition:SPMySQLConnectionIdle];
+ // Tell everyone that the connection is available again
+ [connectionLock unlockWithCondition:SPMySQLConnectionIdle];
}
@end
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Max Packet Size.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Max Packet Size.m
index 76d1dfe7..b3403de1 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Max Packet Size.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Max Packet Size.m
@@ -67,7 +67,6 @@
*/
- (NSUInteger)setGlobalMaxQuerySize:(NSUInteger)newMaxSize
{
-
// Perform basic validation. First, ensure the max query size is editable
if (![self isMaxQuerySizeEditable]) return NSNotFound;
@@ -114,8 +113,7 @@
NSInteger _maxQuerySize = maxQuerySizeString ? [maxQuerySizeString integerValue] : 0;
- if(_maxQuerySize == 0)
- NSLog(@"Query (%@) for max_allowed_packet returned invalid value: %ld (raw value: %@) (on %@)", query, _maxQuerySize, maxQuerySizeString, [self serverVersionString]);
+ if(_maxQuerySize == 0) NSLog(@"Query (%@) for max_allowed_packet returned invalid value: %ld (raw value: %@) (on %@)", query, _maxQuerySize, maxQuerySizeString, [self serverVersionString]);
return _maxQuerySize;
}
@@ -164,12 +162,10 @@
*/
- (BOOL)_attemptMaxQuerySizeIncreaseTo:(NSUInteger)targetSize
{
-
// If the query size is editable, attempt to increase the size
if ([self isMaxQuerySizeEditable]) {
NSUInteger newSize = [self setGlobalMaxQuerySize:targetSize];
if (newSize != NSNotFound) {
-
// Successfully increased the global size - reconnect to use it, and return success
[self _reconnectAllowingRetries:YES];
return YES;
@@ -185,6 +181,7 @@
[delegate queryGaveError:errorMessage connection:self];
}
+ //TODO Setting the last error above should be enough at the framework level. Also this is the only case where -showErrorWithTitle:message: is even used, so we should get rid of it.
// Display an alert as this is a special failure
if ([delegate respondsToSelector:@selector(showErrorWithTitle:message:)]) {
[delegate showErrorWithTitle:NSLocalizedString(@"Error", @"error") message:errorMessage];
@@ -202,7 +199,6 @@
*/
- (void)_restoreMaximumQuerySizeAfterQuery
{
-
// Return if no action needs to be performed
if (queryActionShouldRestoreMaxQuerySize == NSNotFound) return;
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.h
index 1bd9f85b..712d7b95 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.h
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.h
@@ -30,13 +30,6 @@
// This class is private to the framework.
-typedef struct {
- MYSQL *mySQLConnection;
- volatile BOOL *keepAlivePingThreadActivePointer;
- volatile BOOL *keepAliveLastPingSuccessPointer;
- void *parentId;
-} SPMySQLConnectionPingDetails;
-
@interface SPMySQLConnection (Ping_and_KeepAlive)
// Keepalive ping initialisation
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m
index 65a7ae02..d1de87a1 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m
@@ -35,6 +35,13 @@
#import <pthread.h>
#include <stdio.h>
+typedef struct {
+ MYSQL *mySQLConnection;
+ volatile BOOL *keepAlivePingThreadActivePointer;
+ volatile BOOL *keepAliveLastPingSuccessPointer;
+ void *parentId;
+} SPMySQLConnectionPingDetails;
+
@implementation SPMySQLConnection (Ping_and_KeepAlive)
#pragma mark -
@@ -47,7 +54,6 @@
*/
- (void)_keepAlive
{
-
// Do nothing if not connected, if keepalive is disabled, or a keepalive is in
// progress.
if (state != SPMySQLConnected || !useKeepAlive) return;
@@ -185,10 +191,11 @@ end_cleanup:
// If the ping timeout has been exceeded, or the ping thread has been
// cancelled, force a timeout; double-check that the thread is still active.
- if (([[NSThread currentThread] isCancelled] || pingElapsedTime > pingTimeout)
+ if (
+ ([[NSThread currentThread] isCancelled] || pingElapsedTime > pingTimeout)
&& keepAlivePingThreadActive
- && !threadCancelled)
- {
+ && !threadCancelled
+ ) {
pthread_cancel(keepAlivePingThread_t);
threadCancelled = YES;
@@ -209,7 +216,7 @@ end_cleanup:
keepAlivePingThread_t = NULL;
pthread_attr_destroy(&attr);
- // Unlock the connection
+ // Unlock the connection
[self _unlockConnection];
return keepAliveLastPingSuccess;
@@ -278,7 +285,6 @@ void _pingThreadCleanup(void *pingDetails)
*/
- (BOOL)_cancelKeepAlives
{
-
// If no keepalive thread is active, return
if (keepAliveThread) {
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
index ef98a21c..ce52f397 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
@@ -64,7 +64,6 @@
*/
- (NSString *)escapeString:(NSString *)theString includingQuotes:(BOOL)includeQuotes
{
-
// Return nil strings untouched
if (!theString) return theString;
@@ -137,7 +136,6 @@
*/
- (NSString *)escapeData:(NSData *)theData includingQuotes:(BOOL)includeQuotes
{
-
// Return nil datas as nil strings
if (!theData) return nil;
@@ -345,7 +343,7 @@
} while (--queryAttemptsAllowed > 0);
- id theResult = nil;
+ SPMySQLResult *theResult = nil;
// On success, if there is a query result, retrieve the result data type
if (!queryStatus) {
@@ -549,7 +547,6 @@
*/
- (void)cancelCurrentQuery
{
-
// If not connected, no action is required
if (state != SPMySQLConnected && state != SPMySQLDisconnecting) return;
@@ -656,7 +653,6 @@
*/
- (void)_flushMultipleResultSets
{
-
// Repeat as long as there are results
while (!mysql_next_result(mySQLConnection)) {
MYSQL_RES *eachResult = mysql_use_result(mySQLConnection);
@@ -691,7 +687,6 @@
*/
- (void)_updateLastErrorMessage:(NSString *)theErrorMessage
{
-
// If an error message wasn't supplied, select one from the connection
if (!theErrorMessage) {
theErrorMessage = [self _stringForCString:mysql_error(mySQLConnection)];
@@ -714,7 +709,6 @@
*/
- (void)_updateLastErrorID:(NSUInteger)theErrorID
{
-
// If NSNotFound was supplied as the ID, ask the connection for the last error
if (theErrorID == NSNotFound) {
queryErrorID = mysql_errno(mySQLConnection);
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m
index d8d87931..56675d5d 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m
@@ -136,7 +136,6 @@
*/
- (BOOL)killQueryOnThreadID:(unsigned long)theThreadID
{
-
// Note that mysql_kill has been deprecated, so use a query to perform this task.
NSMutableString *killQuery = [NSMutableString stringWithString:@"KILL"];
if ([self serverVersionIsGreaterThanOrEqualTo:5 minorVersion:0 releaseVersion:0]) {
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
index 57a40252..73cadd6e 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
@@ -97,7 +97,6 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS
*/
+ (void)initialize
{
-
// Set up a pthread thread-specific data key to be used across all classes and threads
pthread_key_create(&mySQLThreadInitFlagKey, NULL);
mySQLThreadFlag = malloc(1);
@@ -312,7 +311,6 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS
*/
- (BOOL)isConnected
{
-
// If the connection has been allowed to drop in the background, restore it if posslbe
if (state == SPMySQLConnectionLostInBackground) {
[self _reconnectAllowingRetries:YES];
@@ -389,7 +387,6 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS
*/
- (BOOL)checkConnectionIfNecessary
{
-
// If the connection has been dropped in the background, trigger a
// reconnect and return the success state here
if (state == SPMySQLConnectionLostInBackground) {
@@ -436,25 +433,24 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *possibleSocketLocations = @[
- @"/tmp/mysql.sock", // Default
- @"/Applications/MAMP/tmp/mysql/mysql.sock", // MAMP default location
- @"/Applications/xampp/xamppfiles/var/mysql/mysql.sock", // XAMPP default location
- @"/var/mysql/mysql.sock", // Mac OS X Server default
- @"/opt/local/var/run/mysqld/mysqld.sock", // MacPorts MySQL
- @"/opt/local/var/run/mysql4/mysqld.sock", // MacPorts MySQL 4
- @"/opt/local/var/run/mysql5/mysqld.sock", // MacPorts MySQL 5
- @"/opt/local/var/run/mariadb-10.0/mysqld.sock", // MacPorts MariaDB 10.0
- @"/opt/local/var/run/mariadb-10.1/mysqld.sock", // MacPorts MariaDB 11.0
- @"/usr/local/zend/mysql/tmp/mysql.sock", // Zend Server CE (see Issue #1251)
- @"/var/run/mysqld/mysqld.sock", // As used on Debian/Gentoo
- @"/var/tmp/mysql.sock", // As used on FreeBSD
- @"/var/lib/mysql/mysql.sock", // As used by Fedora
- @"/opt/local/lib/mysql/mysql.sock"
+ @"/tmp/mysql.sock", // Default
+ @"/Applications/MAMP/tmp/mysql/mysql.sock", // MAMP default location
+ @"/Applications/xampp/xamppfiles/var/mysql/mysql.sock", // XAMPP default location
+ @"/var/mysql/mysql.sock", // Mac OS X Server default
+ @"/opt/local/var/run/mysqld/mysqld.sock", // MacPorts MySQL
+ @"/opt/local/var/run/mysql4/mysqld.sock", // MacPorts MySQL 4
+ @"/opt/local/var/run/mysql5/mysqld.sock", // MacPorts MySQL 5
+ @"/opt/local/var/run/mariadb-10.0/mysqld.sock", // MacPorts MariaDB 10.0
+ @"/opt/local/var/run/mariadb-10.1/mysqld.sock", // MacPorts MariaDB 11.0
+ @"/usr/local/zend/mysql/tmp/mysql.sock", // Zend Server CE (see Issue #1251)
+ @"/var/run/mysqld/mysqld.sock", // As used on Debian/Gentoo
+ @"/var/tmp/mysql.sock", // As used on FreeBSD
+ @"/var/lib/mysql/mysql.sock", // As used by Fedora
+ @"/opt/local/lib/mysql/mysql.sock"
];
- for (NSUInteger i = 0; i < [possibleSocketLocations count]; i++) {
- if ([fileManager fileExistsAtPath:[possibleSocketLocations objectAtIndex:i]])
- return [possibleSocketLocations objectAtIndex:i];
+ for(NSString *path in possibleSocketLocations) {
+ if([fileManager fileExistsAtPath:path]) return path;
}
return nil;
@@ -477,7 +473,6 @@ asm(".desc ___crashreporter_info__, 0x10");
*/
- (BOOL)_connect
{
-
// If a connection is already active in some form, throw an exception
if (state != SPMySQLDisconnected && state != SPMySQLConnectionLostInBackground) {
@synchronized (self) {
@@ -686,7 +681,6 @@ asm(".desc ___crashreporter_info__, 0x10");
// If the connection failed, return NULL
if (theConnection != connectionStatus) {
-
// If the connection is the master connection, record the error state
if (isMaster) {
// <TODO>
@@ -883,10 +877,10 @@ asm(".desc ___crashreporter_info__, 0x10");
[self setEncodingUsesLatin1Transport:encodingUsesLatin1TransportToRestore];
[encodingToRestore release], encodingToRestore = nil;
}
-
+ }
// If the connection failed and the connection is permitted to retry,
// then retry the reconnection.
- } else if (canRetry && ![[NSThread currentThread] isCancelled]) {
+ else if (canRetry && ![[NSThread currentThread] isCancelled]) {
// Default to attempting another reconnect
SPMySQLConnectionLostDecision connectionLostDecision = SPMySQLConnectionLostReconnect;
@@ -894,9 +888,9 @@ asm(".desc ___crashreporter_info__, 0x10");
// If the delegate supports the decision process, ask it how to proceed
if (delegateSupportsConnectionLost) {
connectionLostDecision = [self _delegateDecisionForLostConnection];
-
+ }
// Otherwise default to reconnect, but only a set number of times to prevent a runaway loop
- } else {
+ else {
if (reconnectionRetryAttempts < 5) {
connectionLostDecision = SPMySQLConnectionLostReconnect;
} else {
@@ -909,6 +903,7 @@ asm(".desc ___crashreporter_info__, 0x10");
case SPMySQLConnectionLostDisconnect:
[self _updateLastErrorMessage:NSLocalizedString(@"User triggered disconnection", @"User triggered disconnection")];
userTriggeredDisconnect = YES;
+ break;
// By default attempt a reconnect
default:
@@ -985,7 +980,6 @@ asm(".desc ___crashreporter_info__, 0x10");
*/
- (void)_disconnect
{
-
// If state is connection lost, set state directly to disconnected.
if (state == SPMySQLConnectionLostInBackground) {
state = SPMySQLDisconnected;
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLDataTypes.h b/Frameworks/SPMySQLFramework/Source/SPMySQLDataTypes.h
index 31acf6b8..0b89ae66 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLDataTypes.h
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLDataTypes.h
@@ -28,48 +28,48 @@
//
// More info at <https://github.com/sequelpro/sequelpro>
-extern NSString *SPMySQLTinyIntType;
-extern NSString *SPMySQLSmallIntType;
-extern NSString *SPMySQLMediumIntType;
-extern NSString *SPMySQLIntType;
-extern NSString *SPMySQLBigIntType;
-extern NSString *SPMySQLFloatType;
-extern NSString *SPMySQLDoubleType;
-extern NSString *SPMySQLDoublePrecisionType;
-extern NSString *SPMySQLRealType;
-extern NSString *SPMySQLDecimalType;
-extern NSString *SPMySQLBitType;
-extern NSString *SPMySQLSerialType;
-extern NSString *SPMySQLBoolType;
-extern NSString *SPMySQLBoolean;
-extern NSString *SPMySQLDecType;
-extern NSString *SPMySQLFixedType;
-extern NSString *SPMySQLNumericType;
-extern NSString *SPMySQLCharType;
-extern NSString *SPMySQLVarCharType;
-extern NSString *SPMySQLTinyTextType;
-extern NSString *SPMySQLTextType;
-extern NSString *SPMySQLMediumTextType;
-extern NSString *SPMySQLLongTextType;
-extern NSString *SPMySQLTinyBlobType;
-extern NSString *SPMySQLMediumBlobType;
-extern NSString *SPMySQLBlobType;
-extern NSString *SPMySQLLongBlobType;
-extern NSString *SPMySQLBinaryType;
-extern NSString *SPMySQLVarBinaryType;
-extern NSString *SPMySQLEnumType;
-extern NSString *SPMySQLSetType;
-extern NSString *SPMySQLDateType;
-extern NSString *SPMySQLDatetimeType;
-extern NSString *SPMySQLTimestampType;
-extern NSString *SPMySQLTimeType;
-extern NSString *SPMySQLYearType;
-extern NSString *SPMySQLGeometryType;
-extern NSString *SPMySQLPointType;
-extern NSString *SPMySQLLineStringType;
-extern NSString *SPMySQLPolygonType;
-extern NSString *SPMySQLMultiPointType;
-extern NSString *SPMySQLMultiLineStringType;
-extern NSString *SPMySQLMultiPolygonType;
-extern NSString *SPMySQLGeometryCollectionType;
-extern NSString *SPMySQLJsonType;
+extern NSString * const SPMySQLTinyIntType;
+extern NSString * const SPMySQLSmallIntType;
+extern NSString * const SPMySQLMediumIntType;
+extern NSString * const SPMySQLIntType;
+extern NSString * const SPMySQLBigIntType;
+extern NSString * const SPMySQLFloatType;
+extern NSString * const SPMySQLDoubleType;
+extern NSString * const SPMySQLDoublePrecisionType;
+extern NSString * const SPMySQLRealType;
+extern NSString * const SPMySQLDecimalType;
+extern NSString * const SPMySQLBitType;
+extern NSString * const SPMySQLSerialType;
+extern NSString * const SPMySQLBoolType;
+extern NSString * const SPMySQLBoolean;
+extern NSString * const SPMySQLDecType;
+extern NSString * const SPMySQLFixedType;
+extern NSString * const SPMySQLNumericType;
+extern NSString * const SPMySQLCharType;
+extern NSString * const SPMySQLVarCharType;
+extern NSString * const SPMySQLTinyTextType;
+extern NSString * const SPMySQLTextType;
+extern NSString * const SPMySQLMediumTextType;
+extern NSString * const SPMySQLLongTextType;
+extern NSString * const SPMySQLTinyBlobType;
+extern NSString * const SPMySQLMediumBlobType;
+extern NSString * const SPMySQLBlobType;
+extern NSString * const SPMySQLLongBlobType;
+extern NSString * const SPMySQLBinaryType;
+extern NSString * const SPMySQLVarBinaryType;
+extern NSString * const SPMySQLEnumType;
+extern NSString * const SPMySQLSetType;
+extern NSString * const SPMySQLDateType;
+extern NSString * const SPMySQLDatetimeType;
+extern NSString * const SPMySQLTimestampType;
+extern NSString * const SPMySQLTimeType;
+extern NSString * const SPMySQLYearType;
+extern NSString * const SPMySQLGeometryType;
+extern NSString * const SPMySQLPointType;
+extern NSString * const SPMySQLLineStringType;
+extern NSString * const SPMySQLPolygonType;
+extern NSString * const SPMySQLMultiPointType;
+extern NSString * const SPMySQLMultiLineStringType;
+extern NSString * const SPMySQLMultiPolygonType;
+extern NSString * const SPMySQLGeometryCollectionType;
+extern NSString * const SPMySQLJsonType;
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLDataTypes.m b/Frameworks/SPMySQLFramework/Source/SPMySQLDataTypes.m
index d7f54c0e..04fee6cb 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLDataTypes.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLDataTypes.m
@@ -30,48 +30,48 @@
#import "SPMySQLDataTypes.h"
-NSString *SPMySQLTinyIntType = @"TINYINT";
-NSString *SPMySQLSmallIntType = @"SMALLINT";
-NSString *SPMySQLMediumIntType = @"MEDIUMINT";
-NSString *SPMySQLIntType = @"INT";
-NSString *SPMySQLBigIntType = @"BIGINT";
-NSString *SPMySQLFloatType = @"FLOAT";
-NSString *SPMySQLDoubleType = @"DOUBLE";
-NSString *SPMySQLDoublePrecisionType = @"DOUBLE PRECISION";
-NSString *SPMySQLRealType = @"REAL";
-NSString *SPMySQLDecimalType = @"DECIMAL";
-NSString *SPMySQLBitType = @"BIT";
-NSString *SPMySQLSerialType = @"SERIAL";
-NSString *SPMySQLBoolType = @"BOOL";
-NSString *SPMySQLBoolean = @"BOOLEAN";
-NSString *SPMySQLDecType = @"DEC";
-NSString *SPMySQLFixedType = @"FIXED";
-NSString *SPMySQLNumericType = @"NUMERIC";
-NSString *SPMySQLCharType = @"CHAR";
-NSString *SPMySQLVarCharType = @"VARCHAR";
-NSString *SPMySQLTinyTextType = @"TINYTEXT";
-NSString *SPMySQLTextType = @"TEXT";
-NSString *SPMySQLMediumTextType = @"MEDIUMTEXT";
-NSString *SPMySQLLongTextType = @"LONGTEXT";
-NSString *SPMySQLTinyBlobType = @"TINYBLOB";
-NSString *SPMySQLMediumBlobType = @"MEDIUMBLOB";
-NSString *SPMySQLBlobType = @"BLOB";
-NSString *SPMySQLLongBlobType = @"LONGBLOB";
-NSString *SPMySQLBinaryType = @"BINARY";
-NSString *SPMySQLVarBinaryType = @"VARBINARY";
-NSString *SPMySQLEnumType = @"ENUM";
-NSString *SPMySQLSetType = @"SET";
-NSString *SPMySQLDateType = @"DATE";
-NSString *SPMySQLDatetimeType = @"DATETIME";
-NSString *SPMySQLTimestampType = @"TIMESTAMP";
-NSString *SPMySQLTimeType = @"TIME";
-NSString *SPMySQLYearType = @"YEAR";
-NSString *SPMySQLGeometryType = @"GEOMETRY";
-NSString *SPMySQLPointType = @"POINT";
-NSString *SPMySQLLineStringType = @"LINESTRING";
-NSString *SPMySQLPolygonType = @"POLYGON";
-NSString *SPMySQLMultiPointType = @"MULTIPOINT";
-NSString *SPMySQLMultiLineStringType = @"MULTILINESTRING";
-NSString *SPMySQLMultiPolygonType = @"MULTIPOLYGON";
-NSString *SPMySQLGeometryCollectionType = @"GEOMETRYCOLLECTION";
-NSString *SPMySQLJsonType = @"JSON";
+NSString * const SPMySQLTinyIntType = @"TINYINT";
+NSString * const SPMySQLSmallIntType = @"SMALLINT";
+NSString * const SPMySQLMediumIntType = @"MEDIUMINT";
+NSString * const SPMySQLIntType = @"INT";
+NSString * const SPMySQLBigIntType = @"BIGINT";
+NSString * const SPMySQLFloatType = @"FLOAT";
+NSString * const SPMySQLDoubleType = @"DOUBLE";
+NSString * const SPMySQLDoublePrecisionType = @"DOUBLE PRECISION";
+NSString * const SPMySQLRealType = @"REAL";
+NSString * const SPMySQLDecimalType = @"DECIMAL";
+NSString * const SPMySQLBitType = @"BIT";
+NSString * const SPMySQLSerialType = @"SERIAL";
+NSString * const SPMySQLBoolType = @"BOOL";
+NSString * const SPMySQLBoolean = @"BOOLEAN";
+NSString * const SPMySQLDecType = @"DEC";
+NSString * const SPMySQLFixedType = @"FIXED";
+NSString * const SPMySQLNumericType = @"NUMERIC";
+NSString * const SPMySQLCharType = @"CHAR";
+NSString * const SPMySQLVarCharType = @"VARCHAR";
+NSString * const SPMySQLTinyTextType = @"TINYTEXT";
+NSString * const SPMySQLTextType = @"TEXT";
+NSString * const SPMySQLMediumTextType = @"MEDIUMTEXT";
+NSString * const SPMySQLLongTextType = @"LONGTEXT";
+NSString * const SPMySQLTinyBlobType = @"TINYBLOB";
+NSString * const SPMySQLMediumBlobType = @"MEDIUMBLOB";
+NSString * const SPMySQLBlobType = @"BLOB";
+NSString * const SPMySQLLongBlobType = @"LONGBLOB";
+NSString * const SPMySQLBinaryType = @"BINARY";
+NSString * const SPMySQLVarBinaryType = @"VARBINARY";
+NSString * const SPMySQLEnumType = @"ENUM";
+NSString * const SPMySQLSetType = @"SET";
+NSString * const SPMySQLDateType = @"DATE";
+NSString * const SPMySQLDatetimeType = @"DATETIME";
+NSString * const SPMySQLTimestampType = @"TIMESTAMP";
+NSString * const SPMySQLTimeType = @"TIME";
+NSString * const SPMySQLYearType = @"YEAR";
+NSString * const SPMySQLGeometryType = @"GEOMETRY";
+NSString * const SPMySQLPointType = @"POINT";
+NSString * const SPMySQLLineStringType = @"LINESTRING";
+NSString * const SPMySQLPolygonType = @"POLYGON";
+NSString * const SPMySQLMultiPointType = @"MULTIPOINT";
+NSString * const SPMySQLMultiLineStringType = @"MULTILINESTRING";
+NSString * const SPMySQLMultiPolygonType = @"MULTIPOLYGON";
+NSString * const SPMySQLGeometryCollectionType = @"GEOMETRYCOLLECTION";
+NSString * const SPMySQLJsonType = @"JSON";
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLEmptyResult.m b/Frameworks/SPMySQLFramework/Source/SPMySQLEmptyResult.m
index 1b9892aa..a2bb25ed 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLEmptyResult.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLEmptyResult.m
@@ -1,6 +1,4 @@
//
-// $$
-//
// SPMySQLEmptyResult.m
// SPMySQLFramework
//
@@ -47,11 +45,6 @@
return [super init];
}
-- (void)dealloc
-{
- [super dealloc];
-}
-
#pragma mark -
#pragma mark Overrides
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m b/Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m
index 76601779..c0131d0d 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLFastStreamingResult.m
@@ -68,7 +68,6 @@ typedef struct st_spmysqlstreamingrowdata {
*/
+ (void)initialize
{
-
// Cached NSNull singleton reference
if (!NSNullPointer) NSNullPointer = [NSNull null];
}
@@ -81,7 +80,6 @@ typedef struct st_spmysqlstreamingrowdata {
*/
- (id)initWithMySQLResult:(void *)theResult stringEncoding:(NSStringEncoding)theStringEncoding connection:(SPMySQLConnection *)theConnection
{
-
// If no result set was passed in, return nil.
if (!theResult) return nil;
@@ -109,7 +107,6 @@ typedef struct st_spmysqlstreamingrowdata {
*/
- (void)dealloc
{
-
// Ensure all data is processed and the parent connection is unlocked
[self cancelResultLoad];
@@ -131,10 +128,12 @@ typedef struct st_spmysqlstreamingrowdata {
{
return SPMySQLResultGetRow(self, SPMySQLResultRowAsDefault);
}
+
- (NSArray *)getRowAsArray
{
return SPMySQLResultGetRow(self, SPMySQLResultRowAsArray);
}
+
- (NSDictionary *)getRowAsDictionary
{
return SPMySQLResultGetRow(self, SPMySQLResultRowAsDictionary);
@@ -249,7 +248,6 @@ typedef struct st_spmysqlstreamingrowdata {
*/
- (void)cancelResultLoad
{
-
// If data has already been downloaded successfully, no further action is required
if (dataDownloaded && processedRowCount == downloadedRowCount) return;
@@ -300,7 +298,6 @@ typedef struct st_spmysqlstreamingrowdata {
*/
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len
{
-
// To avoid lock issues, return one row at a time.
id nextRow = SPMySQLResultGetRow(self, SPMySQLResultRowAsDefault);
@@ -341,9 +338,7 @@ typedef struct st_spmysqlstreamingrowdata {
while (
(*isConnectedPtr)(parentConnection, isConnectedSelector)
&& (theRow = mysql_fetch_row(resultSet))
- )
- {
-
+ ) {
// Retrieve the lengths of the returned data
fieldLengths = mysql_fetch_lengths(resultSet);
rowDataLength = 0;
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLGeometryData.m b/Frameworks/SPMySQLFramework/Source/SPMySQLGeometryData.m
index b7ced7ab..7ea0418c 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLGeometryData.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLGeometryData.m
@@ -136,16 +136,14 @@ typedef struct st_point_2d_
NSMutableString *wkt = [NSMutableString string];
- if (bufferLength < WKB_HEADER_SIZE)
- return @"";
+ if (bufferLength < WKB_HEADER_SIZE) return @"";
memcpy(&srid, &geoBuffer[0], SIZEOF_STORED_UINT32);
ptr += SIZEOF_STORED_UINT32;
byteOrder = (char)geoBuffer[ptr];
- if (byteOrder != 0x1)
- return @"Byte order not yet supported";
+ if (byteOrder != 0x1) return @"Byte order not yet supported";
ptr++;
geoType = geoBuffer[ptr];
@@ -258,8 +256,7 @@ typedef struct st_point_2d_
byteOrder = (char)geoBuffer[ptr];
- if(byteOrder != 0x1)
- return @"Byte order not yet supported";
+ if(byteOrder != 0x1) return @"Byte order not yet supported";
ptr++;
geoType = geoBuffer[ptr];
@@ -407,16 +404,14 @@ typedef struct st_point_2d_
NSMutableArray *polygoncoordinates = [NSMutableArray array];
NSMutableArray *polygonsubcoordinates = [NSMutableArray array];
- if (bufferLength < WKB_HEADER_SIZE)
- return nil;
+ if (bufferLength < WKB_HEADER_SIZE) return nil;
memcpy(&srid, &geoBuffer[0], SIZEOF_STORED_UINT32);
ptr += SIZEOF_STORED_UINT32;
byteOrder = (char)geoBuffer[ptr];
- if (byteOrder != 0x1)
- return nil;
+ if (byteOrder != 0x1) return nil;
ptr++;
geoType = geoBuffer[ptr];
@@ -752,22 +747,18 @@ typedef struct st_point_2d_
NSUInteger ptr = BUFFER_START; // pointer to geoBuffer while parsing
- if (bufferLength < WKB_HEADER_SIZE)
- return -1;
+ if (bufferLength < WKB_HEADER_SIZE) return -1;
byteOrder = (char)geoBuffer[ptr];
- if (byteOrder != 0x1)
- return -1;
+ if (byteOrder != 0x1) return -1;
ptr++;
geoType = geoBuffer[ptr];
- if (geoType > 0 && geoType < 8)
- return geoType;
- else
- return -1;
-
+ if (geoType > 0 && geoType < 8) return geoType;
+
+ return -1;
}
/**
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Data Conversion.m b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Data Conversion.m
index 3b29fb5e..9eab6ecc 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Data Conversion.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Data Conversion.m
@@ -257,11 +257,10 @@ PRIVATE NSString * _bitStringWithBytes(const char *bytes, NSUInteger length, NSU
*/
PRIVATE NSString * _convertStringData(const void *dataBytes, NSUInteger dataLength, NSStringEncoding aStringEncoding, NSUInteger previewLength)
{
-
// Fast case - if not using a preview length, or if the data length is shorter, return the requested data.
- if (previewLength == NSNotFound || dataLength <= previewLength) {
- return [NSString stringForDataBytes:dataBytes length:dataLength encoding:aStringEncoding];
- }
+ if (previewLength == NSNotFound || dataLength <= previewLength) {
+ return [NSString stringForDataBytes:dataBytes length:dataLength encoding:aStringEncoding];
+ }
NSUInteger i = 0, characterLength = 0, byteLength = previewLength;
uint16_t continuationStart, continuationEnd;
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m
index ec52e0e3..cf7e8a1a 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Field Definitions.m
@@ -46,8 +46,10 @@
const SPMySQLResultCharset SPMySQLCharsetMap[] =
{
{1, "big5","big5_chinese_ci", 1, 2},
+ {2, "latin2", "latin2_czech_cs", 1, 1},
{3, "dec8", "dec8_swedisch_ci", 1, 1},
{4, "cp850", "cp850_general_ci", 1, 1},
+ {5, "latin1", "latin1_german1_ci", 1, 1},
{6, "hp8", "hp8_english_ci", 1, 1},
{7, "koi8r", "koi8r_general_ci", 1, 1},
{8, "latin1", "latin1_swedish_ci", 1, 1},
@@ -56,17 +58,27 @@ const SPMySQLResultCharset SPMySQLCharsetMap[] =
{11, "ascii", "ascii_general_ci", 1, 1},
{12, "ujis", "ujis_japanese_ci", 1, 3},
{13, "sjis", "sjis_japanese_ci", 1, 2},
+ {14, "cp1251", "cp1251_bulgarian_ci", 1, 1},
+ {15, "latin1", "latin1_danish_ci", 1, 1},
{16, "hebrew", "hebrew_general_ci", 1, 1},
+ {17, "filename", "filename", 1, 5},
{18, "tis620", "tis620_thai_ci", 1, 1},
{19, "euckr", "euckr_korean_ci", 1, 2},
+ {20, "latin7", "latin7_estonian_cs", 1, 1},
+ {21, "latin2", "latin2_hungarian_ci", 1, 1},
{22, "koi8u", "koi8u_general_ci", 1, 1},
+ {23, "cp1251", "cp1251_ukrainian_ci", 1, 1},
{24, "gb2312", "gb2312_chinese_ci", 1, 2},
{25, "greek", "greek_general_ci", 1, 1},
{26, "cp1250", "cp1250_general_ci", 1, 1},
+ {27, "latin2", "latin2_croatian_ci", 1, 1},
{28, "gbk", "gbk_chinese_ci", 1, 2},
+ {29, "cp1257", "cp1257_lithunian_ci", 1, 1},
{30, "latin5", "latin5_turkish_ci", 1, 1},
+ {31, "latin1", "latin1_german2_ci", 1, 1},
{32, "armscii8", "armscii8_general_ci", 1, 1},
{33, "utf8", "utf8_general_ci", 1, 3},
+ {34, "cp1250", "cp1250_czech_cs", 1, 1},
{35, "ucs2", "ucs2_general_ci", 2, 2},
{36, "cp866", "cp866_general_ci", 1, 1},
{37, "keybcs2", "keybcs2_general_ci", 1, 1},
@@ -74,38 +86,27 @@ const SPMySQLResultCharset SPMySQLCharsetMap[] =
{39, "macroman", "macroman_general_ci", 1, 1},
{40, "cp852", "cp852_general_ci", 1, 1},
{41, "latin7", "latin7_general_ci", 1, 1},
- {51, "cp1251", "cp1251_general_ci", 1, 1},
- {57, "cp1256", "cp1256_general_ci", 1, 1},
- {59, "cp1257", "cp1257_general_ci", 1, 1},
- {63, "binary", "binary", 1, 1},
- {92, "geostd8", "geostd8_general_ci", 1, 1},
- {95, "cp932", "cp932_japanese_ci", 1, 2},
- {97, "eucjpms", "eucjpms_japanese_ci", 1, 3},
- {2, "latin2", "latin2_czech_cs", 1, 1},
- {5, "latin1", "latin1_german1_ci", 1, 1},
- {14, "cp1251", "cp1251_bulgarian_ci", 1, 1},
- {15, "latin1", "latin1_danish_ci", 1, 1},
- {17, "filename", "filename", 1, 5},
- {20, "latin7", "latin7_estonian_cs", 1, 1},
- {21, "latin2", "latin2_hungarian_ci", 1, 1},
- {23, "cp1251", "cp1251_ukrainian_ci", 1, 1},
- {27, "latin2", "latin2_croatian_ci", 1, 1},
- {29, "cp1257", "cp1257_lithunian_ci", 1, 1},
- {31, "latin1", "latin1_german2_ci", 1, 1},
- {34, "cp1250", "cp1250_czech_cs", 1, 1},
{42, "latin7", "latin7_general_cs", 1, 1},
{43, "macce", "macce_bin", 1, 1},
{44, "cp1250", "cp1250_croatian_ci", 1, 1},
- {45, "utf8", "utf8_general_ci", 1, 1},
- {46, "utf8", "utf8_bin", 1, 1},
+ {45, "utf8", "utf8_general_ci", 1, 4}, //mb4
+ {46, "utf8", "utf8_bin", 1, 4}, //mb4
{47, "latin1", "latin1_bin", 1, 1},
{48, "latin1", "latin1_general_ci", 1, 1},
{49, "latin1", "latin1_general_cs", 1, 1},
{50, "cp1251", "cp1251_bin", 1, 1},
+ {51, "cp1251", "cp1251_general_ci", 1, 1},
{52, "cp1251", "cp1251_general_cs", 1, 1},
{53, "macroman", "macroman_bin", 1, 1},
+
+ {57, "cp1256", "cp1256_general_ci", 1, 1},
{58, "cp1257", "cp1257_bin", 1, 1},
+ {59, "cp1257", "cp1257_general_ci", 1, 1},
+#warning 60 is "utf32_general_ci" and "armascii8" is at 64 in mysql 5.5.59!?
{60, "armascii8", "armascii8_bin", 1, 1},
+
+ {63, "binary", "binary", 1, 1},
+
{65, "ascii", "ascii_bin", 1, 1},
{66, "cp1250", "cp1250_bin", 1, 1},
{67, "cp1256", "cp1256_bin", 1, 1},
@@ -117,13 +118,13 @@ const SPMySQLResultCharset SPMySQLCharsetMap[] =
{73, "keybcs2", "keybcs2_bin", 1, 1},
{74, "koi8r", "koi8r_bin", 1, 1},
{75, "koi8u", "koi8u_bin", 1, 1},
+
{77, "latin2", "latin2_bin", 1, 1},
{78, "latin5", "latin5_bin", 1, 1},
{79, "latin7", "latin7_bin", 1, 1},
{80, "cp850", "cp850_bin", 1, 1},
{81, "cp852", "cp852_bin", 1, 1},
{82, "swe7", "swe7_bin", 1, 1},
- {93, "geostd8", "geostd8_bin", 1, 1},
{83, "utf8", "utf8_bin", 1, 3},
{84, "big5", "big5_bin", 1, 2},
{85, "euckr", "euckr_bin", 1, 2},
@@ -133,10 +134,15 @@ const SPMySQLResultCharset SPMySQLCharsetMap[] =
{89, "tis620", "tis620_bin", 1, 1},
{90, "ucs2", "ucs2_bin", 2, 2},
{91, "ujis", "ujis_bin", 1, 3},
+ {92, "geostd8", "geostd8_general_ci", 1, 1},
+ {93, "geostd8", "geostd8_bin", 1, 1},
{94, "latin1", "latin1_spanish_ci", 1, 1},
+ {95, "cp932", "cp932_japanese_ci", 1, 2},
{96, "cp932", "cp932_bin", 1, 2},
- {99, "cp1250", "cp1250_polish_ci", 1, 1},
+ {97, "eucjpms", "eucjpms_japanese_ci", 1, 3},
{98, "eucjpms", "eucjpms_bin", 1, 3},
+ {99, "cp1250", "cp1250_polish_ci", 1, 1},
+
{128, "ucs2", "ucs2_unicode_ci", 2, 2},
{129, "ucs2", "ucs2_icelandic_ci", 2, 2},
{130, "ucs2", "ucs2_latvian_ci", 2, 2},
@@ -157,6 +163,7 @@ const SPMySQLResultCharset SPMySQLCharsetMap[] =
{145, "ucs2", "ucs2_esperanto_ci", 2, 2},
{146, "ucs2", "ucs2_hungarian_ci", 2, 2},
{147, "ucs2", "ucs2_sinhala_ci", 2, 2},
+
{192, "utf8mb3", "utf8mb3_general_ci", 1, 3},
{193, "utf8mb3", "utf8mb3_icelandic_ci", 1, 3},
{194, "utf8mb3", "utf8mb3_latvian_ci", 1, 3},
@@ -164,7 +171,7 @@ const SPMySQLResultCharset SPMySQLCharsetMap[] =
{196, "utf8mb3", "utf8mb3_slovenian_ci", 1, 3},
{197, "utf8mb3", "utf8mb3_polish_ci", 1, 3},
{198, "utf8mb3", "utf8mb3_estonian_ci", 1, 3},
- {119, "utf8mb3", "utf8mb3_spanish_ci", 1, 3},
+ {199, "utf8mb3", "utf8mb3_spanish_ci", 1, 3},
{200, "utf8mb3", "utf8mb3_swedish_ci", 1, 3},
{201, "utf8mb3", "utf8mb3_turkish_ci", 1, 3},
{202, "utf8mb3", "utf8mb3_czech_ci", 1, 3},
@@ -177,27 +184,30 @@ const SPMySQLResultCharset SPMySQLCharsetMap[] =
{209, "utf8mb3", "utf8mb3_esperanto_ci", 1, 3},
{210, "utf8mb3", "utf8mb3_hungarian_ci", 1, 3},
{211, "utf8mb3", "utf8mb3_sinhala_ci", 1, 3},
- {224, "utf8", "utf8_unicode_ci", 1, 3},
- {225, "utf8", "utf8_icelandic_ci", 1, 3},
- {226, "utf8", "utf8_latvian_ci", 1, 3},
- {227, "utf8", "utf8_romanian_ci", 1, 3},
- {228, "utf8", "utf8_slovenian_ci", 1, 3},
- {229, "utf8", "utf8_polish_ci", 1, 3},
- {230, "utf8", "utf8_estonian_ci", 1, 3},
- {231, "utf8", "utf8_spanish_ci", 1, 3},
- {232, "utf8", "utf8_swedish_ci", 1, 3},
- {233, "utf8", "utf8_turkish_ci", 1, 3},
- {234, "utf8", "utf8_czech_ci", 1, 3},
- {235, "utf8", "utf8_danish_ci", 1, 3},
- {236, "utf8", "utf8_lithuanian_ci", 1, 3},
- {237, "utf8", "utf8_slovak_ci", 1, 3},
- {238, "utf8", "utf8_spanish2_ci", 1, 3},
- {239, "utf8", "utf8_roman_ci", 1, 3},
- {240, "utf8", "utf8_persian_ci", 1, 3},
- {241, "utf8", "utf8_esperanto_ci", 1, 3},
- {242, "utf8", "utf8_hungarian_ci", 1, 3},
- {243, "utf8", "utf8_sinhala_ci", 1, 3},
+
+ {224, "utf8", "utf8_unicode_ci", 1, 4}, //mb4
+ {225, "utf8", "utf8_icelandic_ci", 1, 4}, //mb4
+ {226, "utf8", "utf8_latvian_ci", 1, 4}, //mb4
+ {227, "utf8", "utf8_romanian_ci", 1, 4}, //mb4
+ {228, "utf8", "utf8_slovenian_ci", 1, 4}, //mb4
+ {229, "utf8", "utf8_polish_ci", 1, 4}, //mb4
+ {230, "utf8", "utf8_estonian_ci", 1, 4}, //mb4
+ {231, "utf8", "utf8_spanish_ci", 1, 4}, //mb4
+ {232, "utf8", "utf8_swedish_ci", 1, 4}, //mb4
+ {233, "utf8", "utf8_turkish_ci", 1, 4}, //mb4
+ {234, "utf8", "utf8_czech_ci", 1, 4}, //mb4
+ {235, "utf8", "utf8_danish_ci", 1, 4}, //mb4
+ {236, "utf8", "utf8_lithuanian_ci", 1, 4}, //mb4
+ {237, "utf8", "utf8_slovak_ci", 1, 4}, //mb4
+ {238, "utf8", "utf8_spanish2_ci", 1, 4}, //mb4
+ {239, "utf8", "utf8_roman_ci", 1, 4}, //mb4
+ {240, "utf8", "utf8_persian_ci", 1, 4}, //mb4
+ {241, "utf8", "utf8_esperanto_ci", 1, 4}, //mb4
+ {242, "utf8", "utf8_hungarian_ci", 1, 4}, //mb4
+ {243, "utf8", "utf8_sinhala_ci", 1, 4}, //mb4
+
{254, "utf8mb3", "utf8mb3_general_cs", 1, 3},
+
{0, NULL, NULL, 0, 0}
};
@@ -289,18 +299,18 @@ const SPMySQLResultCharset SPMySQLCharsetMap[] =
[eachField setObject:[self _charsetNameForMySQLNumber:mysqlField.charsetnr] forKey:@"charset_name"];
[eachField setObject:[self _charsetCollationForMySQLNumber:mysqlField.charsetnr] forKey:@"charset_collation"];
- /* Table type */
+ // Table type
[eachField setObject:[self _mysqlTypeToStringForType:mysqlField.type
- withCharsetNr:mysqlField.charsetnr
- withFlags:mysqlField.flags
- withLength:mysqlField.length
- ] forKey:@"type"];
+ withCharsetNr:mysqlField.charsetnr
+ withFlags:mysqlField.flags
+ withLength:mysqlField.length]
+ forKey:@"type"];
- /* Table type group*/
+ // Table type group
[eachField setObject:[self _mysqlTypeToGroupForType:mysqlField.type
- withCharsetNr:mysqlField.charsetnr
- withFlags:mysqlField.flags
- ] forKey:@"typegrouping"];
+ withCharsetNr:mysqlField.charsetnr
+ withFlags:mysqlField.flags]
+ forKey:@"typegrouping"];
[theFieldDefinitions addObject:eachField];
}
@@ -324,8 +334,7 @@ const SPMySQLResultCharset SPMySQLCharsetMap[] =
const SPMySQLResultCharset *c = SPMySQLCharsetMap;
do {
- if (c->nr == charsetnr)
- return c->char_maxlen;
+ if (c->nr == charsetnr) return c->char_maxlen;
++c;
} while (c[0].nr != 0);
@@ -340,8 +349,7 @@ const SPMySQLResultCharset SPMySQLCharsetMap[] =
const SPMySQLResultCharset *c = SPMySQLCharsetMap;
do {
- if (c->nr == charsetnr)
- return [NSString stringWithCString:c->name encoding:stringEncoding];
+ if (c->nr == charsetnr) return [NSString stringWithCString:c->name encoding:NSUTF8StringEncoding];
++c;
} while (c[0].nr != 0);
@@ -356,8 +364,7 @@ const SPMySQLResultCharset SPMySQLCharsetMap[] =
const SPMySQLResultCharset *c = SPMySQLCharsetMap;
do {
- if (c->nr == charsetnr)
- return [NSString stringWithCString:c->collation encoding:stringEncoding];
+ if (c->nr == charsetnr) return [NSString stringWithCString:c->collation encoding:NSUTF8StringEncoding];
++c;
} while (c[0].nr != 0);
@@ -369,7 +376,6 @@ const SPMySQLResultCharset SPMySQLCharsetMap[] =
*/
- (NSString *)_mysqlTypeToStringForType:(NSUInteger)type withCharsetNr:(NSUInteger)charsetnr withFlags:(NSUInteger)flags withLength:(unsigned long long)length
{
-
switch (type) {
case MYSQL_TYPE_BIT:
@@ -491,7 +497,7 @@ const SPMySQLResultCharset SPMySQLCharsetMap[] =
{
switch(type){
- case FIELD_TYPE_BIT:
+ case MYSQL_TYPE_BIT:
return @"bit";
case MYSQL_TYPE_TINY:
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLResult.m b/Frameworks/SPMySQLFramework/Source/SPMySQLResult.m
index 88b27aad..e4be1103 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLResult.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLResult.m
@@ -48,7 +48,6 @@ static id NSNullPointer;
+ (void)initialize
{
-
// Cached NSNull singleton reference
if (!NSNullPointer) NSNullPointer = [NSNull null];
@@ -85,7 +84,6 @@ static id NSNullPointer;
*/
- (instancetype)initWithMySQLResult:(void *)theResult stringEncoding:(NSStringEncoding)theStringEncoding
{
-
// If no result set was passed in, return nil.
if (!theResult) return nil;
@@ -275,7 +273,6 @@ static id NSNullPointer;
*/
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len
{
-
// If the start index is out of bounds, return 0 to indicate end of results
if (state->state >= numberOfRows) return 0;
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResult.m b/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResult.m
index 230fe01a..1a133ea7 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResult.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResult.m
@@ -65,7 +65,6 @@
*/
- (instancetype)initWithMySQLResult:(void *)theResult stringEncoding:(NSStringEncoding)theStringEncoding connection:(SPMySQLConnection *)theConnection
{
-
// If no result set was passed in, return nil.
if (!theResult) return nil;
@@ -94,7 +93,6 @@
*/
- (void)dealloc
{
-
// Ensure all data is processed and the parent connection is unlocked
[self cancelResultLoad];
@@ -140,10 +138,12 @@
{
return SPMySQLResultGetRow(self, SPMySQLResultRowAsDefault);
}
+
- (NSArray *)getRowAsArray
{
return SPMySQLResultGetRow(self, SPMySQLResultRowAsArray);
}
+
- (NSDictionary *)getRowAsDictionary
{
return SPMySQLResultGetRow(self, SPMySQLResultRowAsDictionary);
@@ -160,7 +160,6 @@
// Ensure that the connection is still up before performing a row fetch
if ((*isConnectedPtr)(parentConnection, isConnectedSelector)) {
-
// The core of result fetching in streaming mode is still based around mysql_fetch_row,
// so use the super to perform normal processing.
theRow = [super getRowAsType:theType];
@@ -193,7 +192,6 @@
*/
- (void)cancelResultLoad
{
-
// If data has already been downloaded successfully, no further action is required
if (dataDownloaded) return;
@@ -227,7 +225,6 @@
*/
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len
{
-
// If all rows have been retrieved, return 0 to stop iteration.
if (dataDownloaded) return 0;
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.h b/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.h
index 5fa6f406..cbcb82a9 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.h
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.h
@@ -40,15 +40,14 @@ typedef char SPMySQLStreamingResultStoreRowData;
BOOL loadCancelled;
id <SPMySQLStreamingResultStoreDelegate> delegate;
- // Data storage and allocation
- NSUInteger rowCapacity;
+ // Data storage and allocation
+ NSUInteger rowCapacity;
NSUInteger rowDownloadIterator;
malloc_zone_t *storageMallocZone;
- SPMySQLStreamingResultStoreRowData **dataStorage;
-
- // Thread safety
- pthread_mutex_t dataLock;
+ SPMySQLStreamingResultStoreRowData **dataStorage;
+ // Thread safety
+ pthread_mutex_t dataLock;
}
@property (readwrite, assign) id <SPMySQLStreamingResultStoreDelegate> delegate;
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.m b/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.m
index d3e2580d..1a0b6b25 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.m
@@ -30,7 +30,6 @@
#import "SPMySQLStreamingResultStore.h"
#import "SPMySQL Private APIs.h"
-#import "SPMySQLArrayAdditions.h"
#include <pthread.h>
static id NSNullPointer;
@@ -92,7 +91,6 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult
*/
+ (void)initialize
{
-
// Cached NSNull singleton reference
if (!NSNullPointer) NSNullPointer = [NSNull null];
}
@@ -176,11 +174,9 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult
// the large memory savings for small rows make this extra work worth it.
switch (sizeOfMetadata) {
case SPMySQLStoreMetadataAsChar:
-
// The length of the data is stored in the last end-position slot
dataLength = ((unsigned char *)(oldRow + 1))[previousNumberOfFields - 1];
break;
-
case SPMySQLStoreMetadataAsShort:
dataLength = ((unsigned short *)(oldRow + 1))[previousNumberOfFields - 1];
break;
@@ -269,7 +265,6 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult
*/
- (void)dealloc
{
-
// Ensure all data is processed and the parent connection is unlocked
[self cancelResultLoad];
@@ -310,7 +305,6 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult
*/
- (NSMutableArray *)rowContentsAtIndex:(NSUInteger)rowIndex
{
-
// Throw an exception if the index is out of bounds
if (rowIndex >= numberOfRows) {
[NSException raise:NSRangeException format:@"Requested storage index (%llu) beyond bounds (%llu)", (unsigned long long)rowIndex, (unsigned long long)numberOfRows];
@@ -335,7 +329,6 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult
*/
- (id)cellDataAtRow:(NSUInteger)rowIndex column:(NSUInteger)columnIndex
{
-
// Wrap the preview method, passing in a length limit of NSNotFound
return SPMySQLResultStorePreviewAtRowAndColumn(self, rowIndex, columnIndex, NSNotFound);
}
@@ -403,7 +396,6 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult
dataLength = ((unsigned long *)rowData)[columnIndex] - dataStart;
break;
}
-
}
// If the data length is empty, check whether the cell is null and return null if so
@@ -450,7 +442,6 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult
// Check whether the cell is null
return (((BOOL *)(rowData + (sizeOfMetadata * numberOfFields)))[columnIndex]);
-
}
#pragma mark - Data retrieval overrides
@@ -462,14 +453,17 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult
{
return SPMySQLResultGetRow(self, SPMySQLResultRowAsDefault);
}
+
- (NSArray *)getRowAsArray
{
return SPMySQLResultGetRow(self, SPMySQLResultRowAsArray);
}
+
- (NSDictionary *)getRowAsDictionary
{
return SPMySQLResultGetRow(self, SPMySQLResultRowAsDictionary);
}
+
- (id)getRowAsType:(SPMySQLResultRowType)theType
{
[NSException raise:NSInternalInconsistencyException format:@"Streaming SPMySQL result store sets should be used directly as result stores."];
@@ -482,7 +476,6 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult
*/
- (void)cancelResultLoad
{
-
// Track that loading has been cancelled, allowing faster result download without processing
loadCancelled = YES;
@@ -532,7 +525,6 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult
*/
- (void) addDummyRow
{
-
// Currently only support editing after loading is finished; thi could be addressed by checking rowDownloadIterator vs numberOfRows etc
if (!dataDownloaded) {
[NSException raise:NSInternalInconsistencyException format:@"Streaming SPMySQL result editing is currently only supported once loading is complete."];
@@ -599,7 +591,6 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult
*/
- (void) removeRowAtIndex:(NSUInteger)anIndex
{
-
// Throw an exception if the index is out of bounds
if (anIndex > numberOfRows) {
[NSException raise:NSRangeException format:@"Requested storage index (%llu) beyond bounds (%llu)", (unsigned long long)anIndex, (unsigned long long)numberOfRows];
@@ -627,7 +618,6 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult
*/
- (void) removeRowsInRange:(NSRange)rangeToRemove
{
-
// Throw an exception if the range is out of bounds
if (NSMaxRange(rangeToRemove) > numberOfRows) {
[NSException raise:NSRangeException format:@"Requested storage index (%llu) beyond bounds (%llu)", (unsigned long long)(NSMaxRange(rangeToRemove)), (unsigned long long)numberOfRows];
@@ -657,7 +647,6 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult
*/
- (void) removeAllRows
{
-
// Lock the data mutex
pthread_mutex_lock(&dataLock);
@@ -697,11 +686,9 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult
// Loop through the rows until the end of the data is reached - indicated via a NULL
while (
- (*isConnectedPtr)(parentConnection, isConnectedSelector)
- && (theRow = mysql_fetch_row(resultSet))
- )
- {
-
+ (*isConnectedPtr)(parentConnection, isConnectedSelector)
+ && (theRow = mysql_fetch_row(resultSet))
+ ) {
// If the load has been cancelled, skip any processing - we're only interested
// in ensuring that mysql_fetch_row is called for all rows.
if (loadCancelled) {
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLStringAdditions.m b/Frameworks/SPMySQLFramework/Source/SPMySQLStringAdditions.m
index f987c98b..191b216e 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLStringAdditions.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLStringAdditions.m
@@ -57,13 +57,13 @@
*/
+ (NSString *) stringForDataBytes:(const void *)dataBytes length:(NSUInteger)dataLength encoding:(NSStringEncoding)aStringEncoding
{
- NSString * string = [[[NSString alloc] initWithBytes:dataBytes length:dataLength encoding:aStringEncoding] autorelease];
-
- if (string == nil) {
- return [[[NSString alloc] initWithBytes:dataBytes length:dataLength encoding:NSASCIIStringEncoding] autorelease];
- }
-
- return string;
+ NSString *string = [[[NSString alloc] initWithBytes:dataBytes length:dataLength encoding:aStringEncoding] autorelease];
+
+ if (string == nil) {
+ return [[[NSString alloc] initWithBytes:dataBytes length:dataLength encoding:NSASCIIStringEncoding] autorelease];
+ }
+
+ return string;
}
@end