diff options
Diffstat (limited to 'Frameworks/PostgresKit')
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; } /** |