aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/PostgresKit
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2012-09-06 09:35:29 +0000
committerstuconnolly <stuart02@gmail.com>2012-09-06 09:35:29 +0000
commit669d45c54dc297d3a553f93f9ff62b4705f43427 (patch)
tree81ba2189d5db3baca86fcdc400dc940e7d87cbcb /Frameworks/PostgresKit
parenteff50abf96c5a9f5cc887433b626d8d28f8ddde9 (diff)
downloadsequelpro-669d45c54dc297d3a553f93f9ff62b4705f43427.tar.gz
sequelpro-669d45c54dc297d3a553f93f9ff62b4705f43427.tar.bz2
sequelpro-669d45c54dc297d3a553f93f9ff62b4705f43427.zip
Add a new connection error property.
Diffstat (limited to 'Frameworks/PostgresKit')
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresConnection.h2
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresConnection.m9
2 files changed, 10 insertions, 1 deletions
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresConnection.h b/Frameworks/PostgresKit/Source/FLXPostgresConnection.h
index 51a6f9e5..6b96d624 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresConnection.h
+++ b/Frameworks/PostgresKit/Source/FLXPostgresConnection.h
@@ -38,6 +38,7 @@
NSString *_password;
NSString *_socketPath;
NSString *_encoding;
+ NSString *_connectionError;
const char **_connectionParamNames;
const char **_connectionParamValues;
@@ -70,6 +71,7 @@
@property (readwrite, retain) NSString *socketPath;
@property (readonly) NSString *encoding;
+@property (readonly) NSString *connectionError;
@property (readonly) FLXPostgresError *lastError;
@property (readonly) NSStringEncoding stringEncoding;
@property (readonly) FLXPostgresConnectionParameters *parameters;
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresConnection.m b/Frameworks/PostgresKit/Source/FLXPostgresConnection.m
index 8e0fba79..d9060a5f 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresConnection.m
+++ b/Frameworks/PostgresKit/Source/FLXPostgresConnection.m
@@ -77,6 +77,7 @@ static void _FLXPostgresConnectionNoticeProcessor(void *arg, const char *message
@synthesize lastQueryWasCancelled = _lastQueryWasCancelled;
@synthesize lastError = _lastError;
@synthesize encoding = _encoding;
+@synthesize connectionError = _connectionError;
@synthesize stringEncoding = _stringEncoding;
@synthesize parameters = _parameters;
@@ -109,6 +110,7 @@ static void _FLXPostgresConnectionNoticeProcessor(void *arg, const char *message
_lastError = nil;
_connection = nil;
+ _connectionError = nil;
_lastQueryWasCancelled = NO;
_stringEncoding = FLXPostgresConnectionDefaultStringEncoding;
@@ -189,6 +191,10 @@ static void _FLXPostgresConnectionNoticeProcessor(void *arg, const char *message
if (!_connection || PQstatus(_connection) == CONNECTION_BAD) {
+ if (_connectionError) [_connectionError release];
+
+ _connectionError = [[NSString alloc] initWithUTF8String:PQerrorMessage(_connection)];
+
// TODO: implement reconnection attempt
return NO;
}
@@ -303,7 +309,7 @@ static void _FLXPostgresConnectionNoticeProcessor(void *arg, const char *message
BOOL connected = NO;
while (!connected && !failed)
- {
+ {
switch (PQconnectPoll(_connection))
{
case PGRES_POLLING_READING:
@@ -455,6 +461,7 @@ static void _FLXPostgresConnectionNoticeProcessor(void *arg, const char *message
if (_lastError) [_lastError release], _lastError = nil;
if (_parameters) [_parameters release], _parameters = nil;
+ if (_connectionError) [_connectionError release], _connectionError = nil;
[super dealloc];
}