aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2013-03-11 23:03:28 +0000
committerrowanbeentje <rowan@beent.je>2013-03-11 23:03:28 +0000
commitf4967d21057a1363cacc9607b5ace0149a45ca11 (patch)
tree987e9786303429596420858cec43702f5957790b /Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories
parente88ea3b18a1e9bd1f1e5bef51d982992ce211933 (diff)
downloadsequelpro-f4967d21057a1363cacc9607b5ace0149a45ca11.tar.gz
sequelpro-f4967d21057a1363cacc9607b5ace0149a45ca11.tar.bz2
sequelpro-f4967d21057a1363cacc9607b5ace0149a45ca11.zip
- Add a new SPMySQLEmptyResult class to SPMySQLFrameowkr, returning it instead of nil if a query produces no result set. This allows per-result-set properties to be preserved, fixing issues where information like query execution time was lost - addressing Issue #1577
Diffstat (limited to 'Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories')
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m56
1 files changed, 30 insertions, 26 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
index 22e35648..c007a07e 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
@@ -322,34 +322,38 @@
id theResult = nil;
// On success, if there is a query result, retrieve the result data type
- if (!queryStatus && mysql_field_count(mySQLConnection)) {
- MYSQL_RES *mysqlResult;
-
- switch (theReturnType) {
-
- // For standard result sets, retrieve all the results now, and afterwards
- // update the affected row count.
- case SPMySQLResultAsResult:
- mysqlResult = mysql_store_result(mySQLConnection);
- theResult = [[SPMySQLResult alloc] initWithMySQLResult:mysqlResult stringEncoding:theEncoding];
- theAffectedRowCount = mysql_affected_rows(mySQLConnection);
- break;
-
- // For fast streaming and low memory streaming result sets, set up the result
- case SPMySQLResultAsLowMemStreamingResult:
- mysqlResult = mysql_use_result(mySQLConnection);
- theResult = [[SPMySQLStreamingResult alloc] initWithMySQLResult:mysqlResult stringEncoding:theEncoding connection:self];
- break;
+ if (!queryStatus) {
+ if (mysql_field_count(mySQLConnection)) {
+ MYSQL_RES *mysqlResult;
+
+ switch (theReturnType) {
+
+ // For standard result sets, retrieve all the results now, and afterwards
+ // update the affected row count.
+ case SPMySQLResultAsResult:
+ mysqlResult = mysql_store_result(mySQLConnection);
+ theResult = [[SPMySQLResult alloc] initWithMySQLResult:mysqlResult stringEncoding:theEncoding];
+ theAffectedRowCount = mysql_affected_rows(mySQLConnection);
+ break;
+
+ // For fast streaming and low memory streaming result sets, set up the result
+ case SPMySQLResultAsLowMemStreamingResult:
+ mysqlResult = mysql_use_result(mySQLConnection);
+ theResult = [[SPMySQLStreamingResult alloc] initWithMySQLResult:mysqlResult stringEncoding:theEncoding connection:self];
+ break;
+
+ case SPMySQLResultAsFastStreamingResult:
+ mysqlResult = mysql_use_result(mySQLConnection);
+ theResult = [[SPMySQLFastStreamingResult alloc] initWithMySQLResult:mysqlResult stringEncoding:theEncoding connection:self];
+ break;
+ }
- case SPMySQLResultAsFastStreamingResult:
- mysqlResult = mysql_use_result(mySQLConnection);
- theResult = [[SPMySQLFastStreamingResult alloc] initWithMySQLResult:mysqlResult stringEncoding:theEncoding connection:self];
- break;
+ // Update the error message, if appropriate, to reflect result store errors or overall success
+ theErrorMessage = [self _stringForCString:mysql_error(mySQLConnection)];
+ theErrorID = mysql_errno(mySQLConnection);
+ } else {
+ theResult = [[SPMySQLEmptyResult alloc] init];
}
-
- // Update the error message, if appropriate, to reflect result store errors or overall success
- theErrorMessage = [self _stringForCString:mysql_error(mySQLConnection)];
- theErrorID = mysql_errno(mySQLConnection);
}
// Update the connection's stored insert ID if available