diff options
author | rowanbeentje <rowan@beent.je> | 2012-02-23 02:13:56 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2012-02-23 02:13:56 +0000 |
commit | 05f1612cbb7e33cf9135a346fc2505cc0e87e853 (patch) | |
tree | 785824be4e44a61389271343d958851fa4ff7dd0 /Frameworks/SPMySQLFramework | |
parent | a889340b9cb1eca0d3ff022e8e6e2c718480bf44 (diff) | |
download | sequelpro-05f1612cbb7e33cf9135a346fc2505cc0e87e853.tar.gz sequelpro-05f1612cbb7e33cf9135a346fc2505cc0e87e853.tar.bz2 sequelpro-05f1612cbb7e33cf9135a346fc2505cc0e87e853.zip |
Warning: this branch commit is largely untested, and known to throw exceptions as database structure retrieval is currently missing!
Further work on SPMySQLFramework integration:
- Improve SPMySQL framework build settings including correct ppc builds and a Distribution configuration for the build distributions to match
- Add new convenience querying and result methods to the framework
- Amend Sequel Pro source to use the new SPMySQL.framework methods everywhere, replacing MCPKit methods where they differ and improving some functions
- Remove MCPKit from the source
- Fix a number of warnings on Release-style builds
Diffstat (limited to 'Frameworks/SPMySQLFramework')
11 files changed, 218 insertions, 8 deletions
diff --git a/Frameworks/SPMySQLFramework/SPMySQLFramework.xcodeproj/project.pbxproj b/Frameworks/SPMySQLFramework/SPMySQLFramework.xcodeproj/project.pbxproj index 344a498b..a9f8db0d 100644 --- a/Frameworks/SPMySQLFramework/SPMySQLFramework.xcodeproj/project.pbxproj +++ b/Frameworks/SPMySQLFramework/SPMySQLFramework.xcodeproj/project.pbxproj @@ -30,6 +30,8 @@ 584294FF14CB8002000F8438 /* Server Info.m in Sources */ = {isa = PBXBuildFile; fileRef = 584294FD14CB8002000F8438 /* Server Info.m */; }; 586A99FB14F02E21007F82BF /* SPMySQLStreamingResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 586A99F914F02E21007F82BF /* SPMySQLStreamingResult.h */; settings = {ATTRIBUTES = (Public, ); }; }; 586A99FC14F02E21007F82BF /* SPMySQLStreamingResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 586A99FA14F02E21007F82BF /* SPMySQLStreamingResult.m */; }; + 586AA16714F30C5F007F82BF /* Convenience Methods.h in Headers */ = {isa = PBXBuildFile; fileRef = 586AA16514F30C5F007F82BF /* Convenience Methods.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 586AA16814F30C5F007F82BF /* Convenience Methods.m in Sources */ = {isa = PBXBuildFile; fileRef = 586AA16614F30C5F007F82BF /* Convenience Methods.m */; }; 5884127714CC63830078027F /* SPMySQL.h in Headers */ = {isa = PBXBuildFile; fileRef = 5884127614CC63830078027F /* SPMySQL.h */; settings = {ATTRIBUTES = (Public, ); }; }; 588412A814CC7A4D0078027F /* Locking.h in Headers */ = {isa = PBXBuildFile; fileRef = 588412A614CC7A4D0078027F /* Locking.h */; }; 5884133C14CCEC6B0078027F /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5884133B14CCEC6B0078027F /* libz.dylib */; }; @@ -92,6 +94,8 @@ 586A99F914F02E21007F82BF /* SPMySQLStreamingResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SPMySQLStreamingResult.h; path = Source/SPMySQLStreamingResult.h; sourceTree = "<group>"; }; 586A99FA14F02E21007F82BF /* SPMySQLStreamingResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SPMySQLStreamingResult.m; path = Source/SPMySQLStreamingResult.m; sourceTree = "<group>"; }; 586AA0E714F1CEC8007F82BF /* Readme.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Readme.txt; sourceTree = "<group>"; }; + 586AA16514F30C5F007F82BF /* Convenience Methods.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Convenience Methods.h"; path = "Source/SPMySQLResult Categories/Convenience Methods.h"; sourceTree = "<group>"; }; + 586AA16614F30C5F007F82BF /* Convenience Methods.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "Convenience Methods.m"; path = "Source/SPMySQLResult Categories/Convenience Methods.m"; sourceTree = "<group>"; }; 5884127614CC63830078027F /* SPMySQL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SPMySQL.h; path = Source/SPMySQL.h; sourceTree = "<group>"; }; 588412A614CC7A4D0078027F /* Locking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Locking.h; path = "Source/SPMySQLConnection Categories/Locking.h"; sourceTree = "<group>"; }; 588412A714CC7A4D0078027F /* Locking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Locking.m; path = "Source/SPMySQLConnection Categories/Locking.m"; sourceTree = "<group>"; }; @@ -335,6 +339,8 @@ children = ( 58C7C1E614DB6E8600436315 /* Field Definitions.h */, 58C7C1E714DB6E8600436315 /* Field Definitions.m */, + 586AA16514F30C5F007F82BF /* Convenience Methods.h */, + 586AA16614F30C5F007F82BF /* Convenience Methods.m */, ); name = "Result Categories"; sourceTree = "<group>"; @@ -376,6 +382,7 @@ 58C00BD114E7459600AC489A /* Databases & Tables.h in Headers */, 58C00CA514E845D800AC489A /* SPMySQL Private APIs.h in Headers */, 586A99FB14F02E21007F82BF /* SPMySQLStreamingResult.h in Headers */, + 586AA16714F30C5F007F82BF /* Convenience Methods.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -458,6 +465,7 @@ 58C00AB614E4892E00AC489A /* Delegate & Proxy.m in Sources */, 58C00BD214E7459600AC489A /* Databases & Tables.m in Sources */, 586A99FC14F02E21007F82BF /* SPMySQLStreamingResult.m in Sources */, + 586AA16814F30C5F007F82BF /* Convenience Methods.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -526,7 +534,11 @@ 1DEB91B208733DA50010E9CD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + ARCHS = ( + i386, + ppc, + x86_64, + ); GCC_C_LANGUAGE_STANDARD = gnu99; GCC_OPTIMIZATION_LEVEL = 0; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; @@ -555,7 +567,11 @@ 1DEB91B308733DA50010E9CD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + ARCHS = ( + i386, + ppc, + x86_64, + ); GCC_C_LANGUAGE_STANDARD = gnu99; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -579,6 +595,60 @@ }; name = Release; }; + 586AA55214F5D599007F82BF /* Distribution */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + i386, + ppc, + x86_64, + ); + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_MISSING_PARENTHESES = YES; + GCC_WARN_PROTOTYPE_CONVERSION = YES; + GCC_WARN_SHADOW = YES; + GCC_WARN_SIGN_COMPARE = YES; + GCC_WARN_STRICT_SELECTOR_MATCH = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACH_O_TYPE = mh_dylib; + PREBINDING = NO; + SDKROOT = macosx10.5; + VALID_ARCHS = "i386 ppc x86_64"; + }; + name = Distribution; + }; + 586AA55314F5D599007F82BF /* Distribution */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + DEAD_CODE_STRIPPING = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + FRAMEWORK_VERSION = A; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_MODEL_TUNING = G5; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Source/SPMySQLFramework_Prefix.pch; + INFOPLIST_FILE = Resources/Info.plist; + INSTALL_PATH = "@executable_path/../Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/MySQL Client Libraries/lib\"", + ); + PRODUCT_NAME = SPMySQL; + WRAPPER_EXTENSION = framework; + }; + name = Distribution; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -587,6 +657,7 @@ buildConfigurations = ( 1DEB91AE08733DA50010E9CD /* Debug */, 1DEB91AF08733DA50010E9CD /* Release */, + 586AA55314F5D599007F82BF /* Distribution */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; @@ -596,6 +667,7 @@ buildConfigurations = ( 1DEB91B208733DA50010E9CD /* Debug */, 1DEB91B308733DA50010E9CD /* Release */, + 586AA55214F5D599007F82BF /* Distribution */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQL.h b/Frameworks/SPMySQLFramework/Source/SPMySQL.h index a9150f46..3c4c78f8 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQL.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQL.h @@ -57,6 +57,7 @@ #import "SPMySQLStreamingResult.h" #import "SPMySQLFastStreamingResult.h" #import "Field Definitions.h" +#import "Convenience Methods.h" // Result data objects -#import "SPMySQLGeometryData.h"
\ No newline at end of file +#import "SPMySQLGeometryData.h" diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.h index ff55f796..9ab8bc6a 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.h @@ -45,6 +45,10 @@ - (id)streamingQueryString:(NSString *)theQueryString useLowMemoryBlockingStreaming:(BOOL)fullStreaming; - (id)queryString:(NSString *)theQueryString usingEncoding:(NSStringEncoding)theEncoding withResultType:(SPMySQLResultType)theReturnType; +// Query convenience functions +- (NSArray *)getAllRowsFromQuery:(NSString *)theQueryString; +- (id)getFirstFieldFromQuery:(NSString *)theQueryString; + // Query information - (unsigned long long)rowsAffectedByLastQuery; - (unsigned long long)lastInsertID; @@ -100,4 +104,4 @@ static inline id SPMySQLConnectionQueryString(SPMySQLConnection* self, NSString if (!cachedMethodPointer) cachedMethodPointer = (SPMySQLConnectionQueryStringMethodPtr)[self methodForSelector:cachedSelector]; return cachedMethodPointer(self, cachedSelector, theQueryString, theEncoding, theReturnType); -}
\ No newline at end of file +} diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m index 4134880c..e3ce599a 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m @@ -357,6 +357,27 @@ } #pragma mark - +#pragma mark Query convenience functions + +/** + * Run a query and retrieve the entire result set as an array of dictionaries. + * Returns nil if there was a problem running the query or retrieving any results. + */ +- (NSArray *)getAllRowsFromQuery:(NSString *)theQueryString +{ + return [[self queryString:theQueryString] getAllRows]; +} + +/** + * Run a query and retrieve the first field of any response. Returns nil if there + * was a problem running the query or retrieving any results. + */ +- (id)getFirstFieldFromQuery:(NSString *)theQueryString +{ + return [[[self queryString:theQueryString] getRowAsArray] objectAtIndex:0]; +} + +#pragma mark - #pragma mark Query information /** diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h index db6dc0af..5d1a5d11 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h @@ -174,4 +174,4 @@ + (NSString *)findSocketPath; -@end
\ No newline at end of file +@end diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnectionDelegate.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConnectionDelegate.h index f1a1f911..97e94170 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnectionDelegate.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnectionDelegate.h @@ -30,6 +30,8 @@ // // More info at <http://code.google.com/p/sequel-pro/> +#import "SPMySQLConstants.h" + @protocol SPMySQLConnectionDelegate <NSObject> @optional diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnectionProxy.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConnectionProxy.h index afd7c95a..2da553c6 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnectionProxy.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnectionProxy.h @@ -74,4 +74,4 @@ typedef enum { */ - (BOOL)setConnectionStateChangeSelector:(SEL)theStateChangeSelector delegate:(id)theDelegate; -@end
\ No newline at end of file +@end diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConstants.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConstants.h index 6fb3d279..b1689569 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConstants.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConstants.h @@ -73,4 +73,4 @@ typedef enum { SPMySQLResultAsResult = 0, SPMySQLResultAsFastStreamingResult = 1, SPMySQLResultAsLowMemStreamingResult = 2 -} SPMySQLResultType;
\ No newline at end of file +} SPMySQLResultType; diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Convenience Methods.h b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Convenience Methods.h new file mode 100644 index 00000000..7d870a93 --- /dev/null +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Convenience Methods.h @@ -0,0 +1,38 @@ +// +// $Id$ +// +// Convenience Methods.h +// SPMySQLFramework +// +// Created by Rowan Beentje (rowan.beent.je) on February 20, 2012 +// Copyright (c) 2012 Rowan Beentje. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// More info at <http://code.google.com/p/sequel-pro/> + + +@interface SPMySQLResult (Convenience_Methods) + +- (NSArray *)getAllRows; + +@end diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Convenience Methods.m b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Convenience Methods.m new file mode 100644 index 00000000..7e3619e1 --- /dev/null +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLResult Categories/Convenience Methods.m @@ -0,0 +1,71 @@ +// +// $Id$ +// +// Convenience Methods.h +// SPMySQLFramework +// +// Created by Rowan Beentje (rowan.beent.je) on February 20, 2012 +// Copyright (c) 2012 Rowan Beentje. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// More info at <http://code.google.com/p/sequel-pro/> + +#import "Convenience Methods.h" + +@implementation SPMySQLResult (Convenience_Methods) + +/** + * Iterates over the result set, retrieving all the rows, and returns them + * as an array. + * The rows are in the default format for this instance, as controlled via + * -setDefaultRowReturnType:. + * Returns nil if there are no rows to return. + */ +- (NSArray *)getAllRows +{ + unsigned long long previousSeekPosition = currentRowIndex; + + NSMutableArray *rowsToReturn; + + // If the number of rows is known, pre-set the size; otherwise just create an array + if (numberOfRows != NSNotFound) { + rowsToReturn = [[NSMutableArray alloc] initWithCapacity:numberOfRows]; + } else { + rowsToReturn = [[NSMutableArray alloc] init]; + } + + // Loop through the rows in the instance-specified return format + for (id eachRow in self) { + [rowsToReturn addObject:eachRow]; + } + + // Seek to the previous position if appropriate + if (previousSeekPosition) [self seekToRow:previousSeekPosition]; + + // Instead of empty arrays, return nil if there are no rows. + if (![rowsToReturn count]) return nil; + + return rowsToReturn; +} + +@end diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLResult.h b/Frameworks/SPMySQLFramework/Source/SPMySQLResult.h index baddf8aa..29518b5d 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLResult.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLResult.h @@ -73,6 +73,7 @@ typedef enum { // Result set information - (NSUInteger)numberOfFields; - (unsigned long long)numberOfRows; +- (double)queryExecutionTime; // Column information - (NSArray *)fieldNames; @@ -117,4 +118,4 @@ static inline id SPMySQLResultGetRow(SPMySQLResult* self, SPMySQLResultRowType r if (!cachedMethodPointer) cachedMethodPointer = (SPMySQLResultGetRowMethodPtr)[self methodForSelector:cachedSelector]; return cachedMethodPointer(self, cachedSelector, rowType); -}
\ No newline at end of file +} |