aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/PostgresKit/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Frameworks/PostgresKit/Source')
-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];
}