aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/PostgresKit/Source
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2013-06-18 13:38:26 +0000
committerstuconnolly <stuart02@gmail.com>2013-06-18 13:38:26 +0000
commit80c152501303c0ed7bd530f5e05bc7e5a6fba7f5 (patch)
tree4b1e7106a4b32a21a9aa9e050c9851908949484b /Frameworks/PostgresKit/Source
parent33dbe8d35c3e681c5a8cfd223be50ae7c769cf15 (diff)
downloadsequelpro-80c152501303c0ed7bd530f5e05bc7e5a6fba7f5.tar.gz
sequelpro-80c152501303c0ed7bd530f5e05bc7e5a6fba7f5.tar.bz2
sequelpro-80c152501303c0ed7bd530f5e05bc7e5a6fba7f5.zip
PostgresKit: Add a new property to return the number of rows affected by the last executed query.
Diffstat (limited to 'Frameworks/PostgresKit/Source')
-rw-r--r--Frameworks/PostgresKit/Source/PGPostgresConnection.h4
-rw-r--r--Frameworks/PostgresKit/Source/PGPostgresConnection.m3
-rw-r--r--Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m40
3 files changed, 29 insertions, 18 deletions
diff --git a/Frameworks/PostgresKit/Source/PGPostgresConnection.h b/Frameworks/PostgresKit/Source/PGPostgresConnection.h
index bf1f51d0..f68b17ae 100644
--- a/Frameworks/PostgresKit/Source/PGPostgresConnection.h
+++ b/Frameworks/PostgresKit/Source/PGPostgresConnection.h
@@ -49,6 +49,8 @@
NSUInteger _timeout;
NSUInteger _keepAliveInterval;
+ unsigned long long _lastQueryAffectedRowCount;
+
BOOL _useSocket;
BOOL _useKeepAlive;
BOOL _lastQueryWasCancelled;
@@ -77,6 +79,8 @@
@property (readonly) NSStringEncoding stringEncoding;
@property (readonly) PGPostgresConnectionParameters *parameters;
+@property (readonly) unsigned long long lastQueryAffectedRowCount;
+
@property (readwrite, assign) BOOL useSocket;
@property (readwrite, assign) BOOL useKeepAlive;
@property (readwrite, assign) BOOL lastQueryWasCancelled;
diff --git a/Frameworks/PostgresKit/Source/PGPostgresConnection.m b/Frameworks/PostgresKit/Source/PGPostgresConnection.m
index 920fc626..600be9a0 100644
--- a/Frameworks/PostgresKit/Source/PGPostgresConnection.m
+++ b/Frameworks/PostgresKit/Source/PGPostgresConnection.m
@@ -65,6 +65,7 @@ static void _PGPostgresConnectionNoticeProcessor(void *arg, const char *message)
@synthesize stringEncoding = _stringEncoding;
@synthesize parameters = _parameters;
@synthesize applicationName = _applicationName;
+@synthesize lastQueryAffectedRowCount = _lastQueryAffectedRowCount;
#pragma mark -
#pragma mark Initialisation
@@ -93,6 +94,8 @@ static void _PGPostgresConnectionNoticeProcessor(void *arg, const char *message)
_useKeepAlive = YES;
_keepAliveInterval = PGPostgresConnectionDefaultKeepAlive;
+ _lastQueryAffectedRowCount = 0;
+
_lastError = nil;
_connection = nil;
_connectionError = nil;
diff --git a/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m b/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m
index 3de02350..7e0aa18a 100644
--- a/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m
+++ b/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m
@@ -199,18 +199,18 @@ PGQueryParamData;
}
// Execute the command - return data in binary
- PGresult *result = nil;
+ PGresult *pgResult = nil;
if ([query isKindOfClass:[NSString class]]) {
- result = PQexecParams(_connection,
- [(NSString *)query UTF8String],
- paramData->paramNum,
- paramData->paramTypes,
- (const char **)paramData->paramValues,
- (const int *)paramData->paramLengths,
- (const int *)paramData->paramFormats,
- PGPostgresResultsAsBinary);
+ pgResult = PQexecParams(_connection,
+ [(NSString *)query UTF8String],
+ paramData->paramNum,
+ paramData->paramTypes,
+ (const char **)paramData->paramValues,
+ (const int *)paramData->paramLengths,
+ (const int *)paramData->paramFormats,
+ PGPostgresResultsAsBinary);
}
else if ([query isKindOfClass:[PGPostgresStatement class]]) {
PGPostgresStatement *statement = (PGPostgresStatement *)query;
@@ -222,20 +222,24 @@ PGQueryParamData;
if (!prepareResult || ![statement name]) return nil;
}
- result = PQexecPrepared(_connection,
- [statement UTF8Name],
- paramData->paramNum,
- (const char **)paramData->paramValues,
- (const int *)paramData->paramLengths,
- (const int *)paramData->paramFormats,
- PGPostgresResultsAsBinary);
+ pgResult = PQexecPrepared(_connection,
+ [statement UTF8Name],
+ paramData->paramNum,
+ (const char **)paramData->paramValues,
+ (const int *)paramData->paramLengths,
+ (const int *)paramData->paramFormats,
+ PGPostgresResultsAsBinary);
}
[self _destroyParamDataStructure:paramData];
- if (!result || [self _queryDidError:result]) return nil;
+ if (!pgResult || [self _queryDidError:pgResult]) return nil;
+
+ PGPostgresResult *result = [[[PGPostgresResult alloc] initWithResult:pgResult connection:self] autorelease];
- return [[[PGPostgresResult alloc] initWithResult:result connection:self] autorelease];
+ _lastQueryAffectedRowCount = [result numberOfRows];
+
+ return result;
}
/**