From ad016807a908e6bec3174f9e5eae9524e6243d57 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Tue, 15 Jan 2013 21:50:30 +0000 Subject: - When requesting the server vesion with no current connection, return -1 instead of zero. - When executing a query, perform the query checks before the connection check to avoid performing unnecessary library calls. --- Frameworks/PostgresKit/Source/PGPostgresConnection.m | 4 ++-- .../PostgresKit/Source/PGPostgresConnectionQueryExecution.m | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Frameworks/PostgresKit/Source/PGPostgresConnection.m b/Frameworks/PostgresKit/Source/PGPostgresConnection.m index 3063db84..dda021fe 100644 --- a/Frameworks/PostgresKit/Source/PGPostgresConnection.m +++ b/Frameworks/PostgresKit/Source/PGPostgresConnection.m @@ -231,11 +231,11 @@ static void _PGPostgresConnectionNoticeProcessor(void *arg, const char *message) /** * Returns the version of the server we're connected to. * - * @return The server version (e.g. version 9.1 is 90100). Zero is returned if there's no connection. + * @return The server version (e.g. version 9.1 is 90100). -1 is returned if there's no connection. */ - (NSUInteger)serverVersion { - if (![self isConnected]) return 0; + if (![self isConnected]) return -1; return PQserverVersion(_connection); } diff --git a/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m b/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m index 4dec74a6..ee8853c7 100644 --- a/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m +++ b/Frameworks/PostgresKit/Source/PGPostgresConnectionQueryExecution.m @@ -117,7 +117,13 @@ PGQueryParamData; { _lastQueryWasCancelled = NO; - if (![self isConnected] || !query || ![query isKindOfClass:[NSString class]] || [query isKindOfClass:[PGPostgresStatement class]]) return nil; + if (!query || + ![query isKindOfClass:[NSString class]] || + ![query isKindOfClass:[PGPostgresStatement class]] || + ![self isConnected]) + { + return nil; + } // Notify the delegate if (_delegate && _delegateSupportsWillExecute) { -- cgit v1.2.3